You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add order locking to payment redirect processing (#4437)
* Add order locking to payment redirect processing
* Remove extra changes from linter
* Add comments
* Add readme and changelog entries
* Add unit test
* Move unlock to finally block
Co-authored-by: Malith Senaweera <[email protected]>
* Add logging for when we bail because order is locked
Co-authored-by: Diego Curbelo <[email protected]>
* Fix spacing
* Fix unit test
---------
Co-authored-by: Malith Senaweera <[email protected]>
Co-authored-by: Diego Curbelo <[email protected]>
Copy file name to clipboardExpand all lines: includes/payment-methods/class-wc-stripe-upe-payment-gateway.php
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1616,13 +1616,21 @@ public function process_upe_redirect_payment( $order_id, $intent_id, $save_payme
1616
1616
return;
1617
1617
}
1618
1618
1619
-
WC_Stripe_Logger::log( "Begin processing UPE redirect payment for order $order_id for the amount of {$order->get_total()}" );
1620
-
1621
1619
try {
1620
+
// First check if the order is already being processed by another request.
1621
+
$locked = $this->lock_order_payment( $order );
1622
+
if ( $locked ) {
1623
+
WC_Stripe_Logger::log( "Skip processing UPE redirect payment for order $order_id for the amount of {$order->get_total()}, order payment is already being processed (locked)" );
1624
+
return;
1625
+
}
1626
+
1627
+
WC_Stripe_Logger::log( "Begin processing UPE redirect payment for order $order_id for the amount of {$order->get_total()}" );
0 commit comments