mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Add order intent from settings on check saved payment scheduled action
This commit is contained in:
parent
89001f6533
commit
25ca7451e7
3 changed files with 9 additions and 8 deletions
|
@ -20,7 +20,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PaymentTokenChecker
|
* Class PaymentTokenChecker
|
||||||
|
@ -98,17 +97,18 @@ class PaymentTokenChecker {
|
||||||
/**
|
/**
|
||||||
* Check if payment token exist and updates order accordingly.
|
* Check if payment token exist and updates order accordingly.
|
||||||
*
|
*
|
||||||
* @param int $order_id The order ID.
|
* @param int $order_id The order ID.
|
||||||
* @param int $customer_id The customer ID.
|
* @param int $customer_id The customer ID.
|
||||||
|
* @param string $intent The intent from settings when order was created.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function check_and_update( int $order_id, int $customer_id ):void {
|
public function check_and_update( int $order_id, int $customer_id, string $intent ):void {
|
||||||
$wc_order = wc_get_order( $order_id );
|
$wc_order = wc_get_order( $order_id );
|
||||||
if ( ! is_a( $wc_order, WC_Order::class ) ) {
|
if ( ! is_a( $wc_order, WC_Order::class ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $wc_order->get_status() === 'processing' ) {
|
if ( $wc_order->get_status() === 'processing' || 'capture' !== $intent ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,12 +132,12 @@ class VaultingModule implements ModuleInterface {
|
||||||
|
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_paypal_payments_check_saved_payment',
|
'woocommerce_paypal_payments_check_saved_payment',
|
||||||
function ( int $order_id, int $customer_id ) use ( $container ) {
|
function ( int $order_id, int $customer_id, string $intent ) use ( $container ) {
|
||||||
$payment_token_checker = $container->get( 'vaulting.payment-token-checker' );
|
$payment_token_checker = $container->get( 'vaulting.payment-token-checker' );
|
||||||
$payment_token_checker->check_and_update( $order_id, $customer_id );
|
$payment_token_checker->check_and_update( $order_id, $customer_id, $intent );
|
||||||
},
|
},
|
||||||
10,
|
10,
|
||||||
2
|
3
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,7 @@ trait ProcessPaymentTrait {
|
||||||
array(
|
array(
|
||||||
'order_id' => $order_id,
|
'order_id' => $order_id,
|
||||||
'customer_id' => $wc_order->get_customer_id(),
|
'customer_id' => $wc_order->get_customer_id(),
|
||||||
|
'intent' => $this->config->has( 'intent' ) ? $this->config->get( 'intent' ) : '',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue