Skip to content

Commit 1c26a12

Browse files
wjrosadiegocurbelo
andauthored
Throwing exception when saved method cannot be found (#4435)
* Throwing exception when saved method cannot be found * Changelog and readme entries * Including the order ID to the exception message --------- Co-authored-by: Diego Curbelo <[email protected]>
1 parent 5ffd013 commit 1c26a12

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
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.6.0 - xxxx-xx-xx =
4+
* Fix - Throws a specific exception on an edge case where a saved payment method could not be found when processing an order in the new checkout experience
45
* Fix - Checks if the store has other BNPL extensions installed before displaying the promotional banner
56
* Fix - Correctly notifies customers and merchants of a failed refund and reverts the refunded status
67
* Update - Legacy checkout experience has been deprecated, new checkout experience is now the default for all sites

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,17 @@ public function process_payment_with_saved_payment_method( $order_id, $can_retry
13011301
return $this->process_pre_order( $order_id );
13021302
}
13031303

1304-
$token = WC_Stripe_Payment_Tokens::get_token_from_request( $_POST );
1304+
$token = WC_Stripe_Payment_Tokens::get_token_from_request( $_POST );
1305+
if ( ! $token ) {
1306+
throw new WC_Stripe_Exception(
1307+
sprintf(
1308+
/* translators: %s is the order ID */
1309+
__( "We're not able to process this payment. The saved payment method for order %s could not be found.", 'woocommerce-gateway-stripe' ),
1310+
$order_id
1311+
)
1312+
);
1313+
}
1314+
13051315
$payment_method = $this->stripe_request( 'payment_methods/' . $token->get_token(), [], null, 'GET' );
13061316
$prepared_payment_method = $this->prepare_payment_method( $payment_method );
13071317

readme.txt

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

113113
= 9.6.0 - xxxx-xx-xx =
114114

115+
* Fix - Throws a specific exception on an edge case where a saved payment method could not be found when processing an order in the new checkout experience
115116
* Fix - Checks if the store has other BNPL extensions installed before displaying the promotional banner
116117
* Fix - Correctly notifies customers and merchants of a failed refund and reverts the refunded status.
117118
* Update - Legacy checkout experience has been deprecated, new checkout experience is now the default for all sites

0 commit comments

Comments
 (0)