Create wc order in approval webhook if missing

This commit is contained in:
Alex P 2023-06-14 12:44:06 +03:00
parent 10d99578d6
commit 46ea7621d3
No known key found for this signature in database
GPG key ID: 54487A734A204D71
8 changed files with 302 additions and 44 deletions

View file

@ -173,6 +173,13 @@ class SmartButton implements SmartButtonInterface {
*/
private $pay_now_contexts;
/**
* The sources that do not cause issues about redirecting (on mobile, ...) and sometimes not returning back.
*
* @var string[]
*/
private $funding_sources_without_redirect;
/**
* The logger.
*
@ -208,6 +215,7 @@ class SmartButton implements SmartButtonInterface {
* @param bool $basic_checkout_validation_enabled Whether the basic JS validation of the form iss enabled.
* @param bool $early_validation_enabled Whether to execute WC validation of the checkout form.
* @param array $pay_now_contexts The contexts that should have the Pay Now button.
* @param string[] $funding_sources_without_redirect The sources that do not cause issues about redirecting (on mobile, ...) and sometimes not returning back.
* @param LoggerInterface $logger The logger.
*/
public function __construct(
@ -229,6 +237,7 @@ class SmartButton implements SmartButtonInterface {
bool $basic_checkout_validation_enabled,
bool $early_validation_enabled,
array $pay_now_contexts,
array $funding_sources_without_redirect,
LoggerInterface $logger
) {
@ -250,6 +259,7 @@ class SmartButton implements SmartButtonInterface {
$this->basic_checkout_validation_enabled = $basic_checkout_validation_enabled;
$this->early_validation_enabled = $early_validation_enabled;
$this->pay_now_contexts = $pay_now_contexts;
$this->funding_sources_without_redirect = $funding_sources_without_redirect;
$this->logger = $logger;
}
@ -939,6 +949,7 @@ class SmartButton implements SmartButtonInterface {
'mini_cart_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'mini-cart' ),
'basic_checkout_validation_enabled' => $this->basic_checkout_validation_enabled,
'early_checkout_validation_enabled' => $this->early_validation_enabled,
'funding_sources_without_redirect' => $this->funding_sources_without_redirect,
);
if ( $this->style_for_context( 'layout', 'mini-cart' ) !== 'horizontal' ) {

View file

@ -10,11 +10,30 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Button\Helper;
use WC_Checkout;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
/**
* Class CheckoutFormSaver
*/
class CheckoutFormSaver extends WC_Checkout {
/**
* The Session handler.
*
* @var SessionHandler
*/
private $session_handler;
/**
* CheckoutFormSaver constructor.
*
* @param SessionHandler $session_handler The session handler.
*/
public function __construct(
SessionHandler $session_handler
) {
$this->session_handler = $session_handler;
}
/**
* Saves the form data to the WC customer and session.
*
@ -28,5 +47,7 @@ class CheckoutFormSaver extends WC_Checkout {
$data = $this->get_posted_data();
$this->update_session( $data );
$this->session_handler->replace_checkout_form( $data );
}
}