diff --git a/modules/ppcp-vaulting/src/VaultedCreditCardHandler.php b/modules/ppcp-vaulting/src/VaultedCreditCardHandler.php index dd0b93224..7f305ba45 100644 --- a/modules/ppcp-vaulting/src/VaultedCreditCardHandler.php +++ b/modules/ppcp-vaulting/src/VaultedCreditCardHandler.php @@ -118,8 +118,7 @@ class VaultedCreditCardHandler public function handle_payment( string $saved_credit_card, - WC_Order $wc_order, - WC_Customer $customer + WC_Order $wc_order ): WC_Order { $change_payment = filter_input( INPUT_POST, 'woocommerce_change_payment', FILTER_SANITIZE_STRING ); @@ -146,8 +145,7 @@ class VaultedCreditCardHandler } $purchase_unit = $this->purchase_unit_factory->from_wc_order( $wc_order ); - $payer = $this->payer_factory->from_customer( $customer ); - + $payer = $this->payer_factory->from_wc_order( $wc_order); $shipping_preference = $this->shipping_preference_factory->from_state( $purchase_unit, '' diff --git a/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php b/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php index 8578ac072..6b269f4fe 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php @@ -361,12 +361,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { $saved_credit_card = filter_input( INPUT_POST, 'saved_credit_card', FILTER_SANITIZE_STRING ); if($saved_credit_card) { try { - $customer = new WC_Customer( $wc_order->get_customer_id() ); - $wc_order = $this->vaulted_credit_card_handler->handle_payment( $saved_credit_card, - $wc_order, - $customer + $wc_order ); return $this->handle_payment_success( $wc_order ); diff --git a/tests/PHPUnit/Vaulting/VaultedCreditCardHandlerTest.php b/tests/PHPUnit/Vaulting/VaultedCreditCardHandlerTest.php index 7060bf8be..379b00f00 100644 --- a/tests/PHPUnit/Vaulting/VaultedCreditCardHandlerTest.php +++ b/tests/PHPUnit/Vaulting/VaultedCreditCardHandlerTest.php @@ -105,7 +105,7 @@ class VaultedCreditCardHandlerTest extends TestCase $customer = Mockery::mock(WC_Customer::class); $payer = Mockery::mock(Payer::class); - $this->payerFactory->shouldReceive('from_customer') + $this->payerFactory->shouldReceive('from_wc_order') ->andReturn($payer); $this->shippingPreferenceFactory->shouldReceive('from_state') ->andReturn('some_preference'); diff --git a/tests/PHPUnit/WcGateway/Gateway/CreditCardGatewayTest.php b/tests/PHPUnit/WcGateway/Gateway/CreditCardGatewayTest.php index 4f751a924..e6f9c5697 100644 --- a/tests/PHPUnit/WcGateway/Gateway/CreditCardGatewayTest.php +++ b/tests/PHPUnit/WcGateway/Gateway/CreditCardGatewayTest.php @@ -90,6 +90,7 @@ class CreditCardGatewayTest extends TestCase public function testProcessPaymentVaultedCard() { $wc_order = Mockery::mock(WC_Order::class); + $wc_order->shouldReceive('get_customer_id')->andReturn(1); when('wc_get_order')->justReturn($wc_order); $savedCreditCard = 'abc123';