Handle the 3DS details when captured & authorized

This commit is contained in:
Narek Zakarian 2024-01-23 19:03:36 +04:00
parent fc270805e2
commit 39f648b084
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -11,10 +11,11 @@ namespace WooCommerce\PayPalCommerce\WcGateway;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Throwable; use Throwable;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Authorization;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache; use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint; use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint;
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\WcGateway\Processor\ThreeDSecureHandlingTrait;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider; use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface; use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WC_Order; use WC_Order;
@ -56,6 +57,8 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
*/ */
class WCGatewayModule implements ModuleInterface { class WCGatewayModule implements ModuleInterface {
use ThreeDSecureHandlingTrait;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -92,7 +95,7 @@ class WCGatewayModule implements ModuleInterface {
add_action( add_action(
'woocommerce_paypal_payments_order_captured', 'woocommerce_paypal_payments_order_captured',
function ( WC_Order $wc_order, Capture $capture ) { function ( WC_Order $wc_order, Capture $capture ) use ( $c ) {
$breakdown = $capture->seller_receivable_breakdown(); $breakdown = $capture->seller_receivable_breakdown();
if ( $breakdown ) { if ( $breakdown ) {
$wc_order->update_meta_data( PayPalGateway::FEES_META_KEY, $breakdown->to_array() ); $wc_order->update_meta_data( PayPalGateway::FEES_META_KEY, $breakdown->to_array() );
@ -141,6 +144,19 @@ class WCGatewayModule implements ModuleInterface {
); );
$wc_order->add_order_note( $cvv_response_order_note ); $wc_order->add_order_note( $cvv_response_order_note );
} }
$order = $c->get( 'session.handler' )->order();
$this->handle_three_d_secure( $order, $wc_order );
},
10,
2
);
add_action(
'woocommerce_paypal_payments_order_authorized',
function ( WC_Order $wc_order, Authorization $authorization ) use ( $c ) {
$order = $c->get( 'session.handler' )->order();
$this->handle_three_d_secure( $order, $wc_order );
}, },
10, 10,
2 2