Get payer from order instead of customer

This commit is contained in:
dinamiko 2022-08-12 10:38:42 +02:00
parent 0e24b1d0f8
commit 76a81b535b
4 changed files with 5 additions and 9 deletions

View file

@ -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,
''

View file

@ -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 );