@@ -1196,7 +1196,12 @@ public function maybe_process_upe_redirect() {
1196
1196
return ;
1197
1197
}
1198
1198
1199
- $ this ->process_upe_redirect_payment ( $ order_id , $ intent_id , $ save_payment_method );
1199
+ $ this ->process_upe_redirect_payment (
1200
+ $ order_id ,
1201
+ $ intent_id ,
1202
+ $ save_payment_method ,
1203
+ isset ( $ _GET ['pay_for_order ' ] ) && 'yes ' === $ _GET ['pay_for_order ' ]
1204
+ );
1200
1205
}
1201
1206
1202
1207
/**
@@ -1246,11 +1251,12 @@ private function is_order_associated_to_setup_intent( int $order_id, string $int
1246
1251
* @param int $order_id The order ID being processed.
1247
1252
* @param string $intent_id The Stripe setup/payment intent ID for the order payment.
1248
1253
* @param bool $save_payment_method Boolean representing whether payment method for order should be saved.
1254
+ * @param bool $is_pay_for_order True if processing payment from Pay for Order page. Optional.
1249
1255
*
1250
1256
* @since 5.5.0
1251
1257
* @version 5.5.0
1252
1258
*/
1253
- public function process_upe_redirect_payment ( $ order_id , $ intent_id , $ save_payment_method ) {
1259
+ public function process_upe_redirect_payment ( $ order_id , $ intent_id , $ save_payment_method, $ is_pay_for_order = false ) {
1254
1260
$ order = wc_get_order ( $ order_id );
1255
1261
1256
1262
if ( ! is_object ( $ order ) ) {
@@ -1276,7 +1282,15 @@ public function process_upe_redirect_payment( $order_id, $intent_id, $save_payme
1276
1282
$ order ->update_status ( 'failed ' , sprintf ( __ ( 'UPE payment failed: %s ' , 'woocommerce-gateway-stripe ' ), $ e ->getMessage () ) );
1277
1283
1278
1284
wc_add_notice ( $ e ->getMessage (), 'error ' );
1279
- wp_safe_redirect ( wc_get_checkout_url () );
1285
+
1286
+ $ redirect_url = '' ;
1287
+ if ( $ is_pay_for_order ) {
1288
+ $ redirect_url = $ order ->get_checkout_payment_url ();
1289
+ } else {
1290
+ $ redirect_url = wc_get_checkout_url ();
1291
+ }
1292
+ wp_safe_redirect ( wp_sanitize_redirect ( $ redirect_url ) );
1293
+
1280
1294
exit ;
1281
1295
}
1282
1296
}
@@ -2384,6 +2398,7 @@ private function get_return_url_for_redirect( $order, $save_payment_method ) {
2384
2398
'wc_payment_method ' => self ::ID ,
2385
2399
'_wpnonce ' => wp_create_nonce ( 'wc_stripe_process_redirect_order_nonce ' ),
2386
2400
'save_payment_method ' => $ save_payment_method ? 'yes ' : 'no ' ,
2401
+ 'pay_for_order ' => parent ::is_valid_pay_for_order_endpoint () ? 'yes ' : 'no ' ,
2387
2402
],
2388
2403
$ this ->get_return_url ( $ order )
2389
2404
)
0 commit comments