Skip to content

Commit 2f29de7

Browse files
authored
Using the existing instantiation method for OC (#4577)
* Using the existing instantiation method for OC * Changelog and readme entries
1 parent 1ba4b15 commit 2f29de7

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.9.0 - xxxx-xx-xx =
4+
* Dev - Replaces some payment method instantiation logic for the Optimized Checkout with calls to the `get_payment_method_instance` method
45
* Dev - Multiple lint fixes in preparation for the Node 20 upgrade
56
* Dev - Introduces a new helper method to identify Stripe orders
67
* Add - Setting to allow merchants to control the layout of the Optimized Checkout payment element on the checkout page

includes/payment-methods/class-wc-stripe-upe-payment-gateway.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,12 +1068,7 @@ private function process_payment_with_payment_method( int $order_id ) {
10681068
$response_args = [];
10691069

10701070
if ( $this->oc_enabled && isset( $payment_method_details->type ) ) {
1071-
foreach ( self::UPE_AVAILABLE_METHODS as $payment_method_class ) {
1072-
$payment_method = new $payment_method_class();
1073-
if ( $payment_method->get_id() === $payment_method_details->type ) {
1074-
$upe_payment_method = $payment_method;
1075-
}
1076-
}
1071+
$upe_payment_method = self::get_payment_method_instance( $payment_method_details->type );
10771072
}
10781073

10791074
// Make sure that we attach the payment method and the customer ID to the order meta data.
@@ -2234,12 +2229,7 @@ public function create_token_from_setup_intent( $setup_intent_id, $user ) {
22342229
if ( $this->oc_enabled ) {
22352230
$payment_method_type = $payment_method_details['type'] ?? $payment_method_details->type ?? null;
22362231
if ( ! empty( $payment_method_type ) ) {
2237-
foreach ( self::UPE_AVAILABLE_METHODS as $payment_method_class ) {
2238-
$payment_method_instance = new $payment_method_class();
2239-
if ( $payment_method_instance->get_id() === $payment_method_type ) {
2240-
$payment_method = $payment_method_instance;
2241-
}
2242-
}
2232+
$payment_method = self::get_payment_method_instance( $payment_method_type );
22432233
}
22442234
} else {
22452235
$payment_method = $this->payment_methods[ $payment_method_type ] ?? null;

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.9.0 - xxxx-xx-xx =
114+
* Dev - Replaces some payment method instantiation logic for the Optimized Checkout with calls to the `get_payment_method_instance` method
114115
* Dev - Multiple lint fixes in preparation for the Node 20 upgrade
115116
* Dev - Introduces a new helper method to identify Stripe orders
116117
* Add - Setting to allow merchants to control the layout of the Optimized Checkout payment element on the checkout page

0 commit comments

Comments
 (0)