diff --git a/modules/ppcp-api-client/services.php b/modules/ppcp-api-client/services.php index 689561449..ce363dabc 100644 --- a/modules/ppcp-api-client/services.php +++ b/modules/ppcp-api-client/services.php @@ -361,14 +361,12 @@ return array( $application_context_repository = $container->get( 'api.repository.application-context' ); $application_context_factory = $container->get( 'api.factory.application-context' ); $payment_source_factory = $container->get( 'api.factory.payment-source' ); - $logger = $container->get( 'woocommerce.logger.woocommerce' ); return new OrderFactory( $purchase_unit_factory, $payer_factory, $application_context_repository, $application_context_factory, - $payment_source_factory, - $logger + $payment_source_factory ); }, 'api.factory.payments' => static function ( ContainerInterface $container ): PaymentsFactory { diff --git a/modules/ppcp-api-client/src/Factory/OrderFactory.php b/modules/ppcp-api-client/src/Factory/OrderFactory.php index 7ffbffcb9..50540ea95 100644 --- a/modules/ppcp-api-client/src/Factory/OrderFactory.php +++ b/modules/ppcp-api-client/src/Factory/OrderFactory.php @@ -9,7 +9,6 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\ApiClient\Factory; -use Psr\Log\LoggerInterface; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; @@ -56,13 +55,6 @@ class OrderFactory { */ private $payment_source_factory; - /** - * The logger. - * - * @var LoggerInterface - */ - private LoggerInterface $logger; - /** * OrderFactory constructor. * @@ -71,15 +63,13 @@ class OrderFactory { * @param ApplicationContextRepository $application_context_repository The Application Context repository. * @param ApplicationContextFactory $application_context_factory The Application Context factory. * @param PaymentSourceFactory $payment_source_factory The Payment Source factory. - * @param LoggerInterface $logger The logger. */ public function __construct( PurchaseUnitFactory $purchase_unit_factory, PayerFactory $payer_factory, ApplicationContextRepository $application_context_repository, ApplicationContextFactory $application_context_factory, - PaymentSourceFactory $payment_source_factory, - LoggerInterface $logger + PaymentSourceFactory $payment_source_factory ) { $this->purchase_unit_factory = $purchase_unit_factory; @@ -87,7 +77,6 @@ class OrderFactory { $this->application_context_repository = $application_context_repository; $this->application_context_factory = $application_context_factory; $this->payment_source_factory = $payment_source_factory; - $this->logger = $logger; } /** diff --git a/modules/ppcp-subscription/src/SubscriptionModule.php b/modules/ppcp-subscription/src/SubscriptionModule.php index 099ee18ff..018fbccfe 100644 --- a/modules/ppcp-subscription/src/SubscriptionModule.php +++ b/modules/ppcp-subscription/src/SubscriptionModule.php @@ -123,29 +123,16 @@ class SubscriptionModule implements ModuleInterface { && isset( $data['payment_source']['token'] ) && $data['payment_source']['token']['type'] === 'PAYMENT_METHOD_TOKEN' && isset( $data['payment_source']['token']['source']->card ) ) { - $renewal_order_id = absint( $data['purchase_units'][0]['custom_id'] ); - $subscriptions = wcs_get_subscriptions_for_renewal_order( $renewal_order_id ); - $subscriptions_values = array_values( $subscriptions ); - $latest_subscription = array_shift( $subscriptions_values ); - if ( is_a( $latest_subscription, WC_Subscription::class ) ) { - $related_renewal_orders = $latest_subscription->get_related_orders( 'ids', 'renewal' ); - $latest_order_id_with_transaction = array_slice( $related_renewal_orders, 1, 1, false ); - $order_id = ! empty( $latest_order_id_with_transaction ) ? $latest_order_id_with_transaction[0] : 0; - if ( count( $related_renewal_orders ) === 1 ) { - $order_id = $latest_subscription->get_parent_id(); - } - - $wc_order = wc_get_order( $order_id ); - if ( is_a( $wc_order, WC_Order::class ) ) { - $transaction_id = $wc_order->get_transaction_id(); - $data['application_context']['stored_payment_source'] = array( + $data['payment_source'] = array( + 'card' => array( + 'vault_id' => $data['payment_source']['token']['id'], + 'stored_credential' => array( 'payment_initiator' => 'MERCHANT', 'payment_type' => 'RECURRING', 'usage' => 'SUBSEQUENT', - 'previous_transaction_reference' => $transaction_id, - ); - } - } + ), + ), + ); } return $data;