From 96461780ad6f5d0296e94ef27784c58d84d4b3d5 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 12 Aug 2025 11:41:48 -0300 Subject: [PATCH] Using the existing instantiation method for OC --- .../class-wc-stripe-upe-payment-gateway.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php index 11d0f2b29e..dbcdac0007 100644 --- a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php +++ b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php @@ -1020,12 +1020,7 @@ private function process_payment_with_payment_method( int $order_id ) { $response_args = []; if ( $this->oc_enabled && isset( $payment_method_details->type ) ) { - foreach ( self::UPE_AVAILABLE_METHODS as $payment_method_class ) { - $payment_method = new $payment_method_class(); - if ( $payment_method->get_id() === $payment_method_details->type ) { - $upe_payment_method = $payment_method; - } - } + $upe_payment_method = self::get_payment_method_instance( $payment_method_details->type ); } // Make sure that we attach the payment method and the customer ID to the order meta data. @@ -2179,12 +2174,7 @@ public function create_token_from_setup_intent( $setup_intent_id, $user ) { if ( $this->oc_enabled ) { $payment_method_type = $payment_method_details['type'] ?? $payment_method_details->type ?? null; if ( ! empty( $payment_method_type ) ) { - foreach ( self::UPE_AVAILABLE_METHODS as $payment_method_class ) { - $payment_method_instance = new $payment_method_class(); - if ( $payment_method_instance->get_id() === $payment_method_type ) { - $payment_method = $payment_method_instance; - } - } + $payment_method = self::get_payment_method_instance( $payment_method_type ); } } else { $payment_method = $this->payment_methods[ $payment_method_type ] ?? null;