Save the session data before proceeding with order payment (#40964)
* Save the session early before proceeding with order payment. As part of the checkout process an order is created and the order id is stored in a session variable right before requesting payment processing to the appropriate payment gateway. Thus if the payment fails and the user submits the order again, the order id will be picked from the session so the existing order can be retrieved and updated. However if the payment process hangs (instead of returning an error) and the request never finishes the session data will never actually be sorted, and the next time the user submits the order a duplicate of the first order will be created. This commit simply does WC()->session->save_data() after the WC()->session->set that stores the order id, so that the session is effectively updated even if the request hangs. * Add changelog file
This commit is contained in:
parent
82b90d07ec
commit
eafc87b453
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Save the session data before proceeding with order payment
|
|
@ -1046,6 +1046,11 @@ class WC_Checkout {
|
||||||
// Store Order ID in session so it can be re-used after payment failure.
|
// Store Order ID in session so it can be re-used after payment failure.
|
||||||
WC()->session->set( 'order_awaiting_payment', $order_id );
|
WC()->session->set( 'order_awaiting_payment', $order_id );
|
||||||
|
|
||||||
|
// We save the session early because if the payment gateway hangs
|
||||||
|
// the request will never finish, thus the session data will neved be saved,
|
||||||
|
// and this can lead to duplicate orders if the user submits the order again.
|
||||||
|
WC()->session->save_data();
|
||||||
|
|
||||||
// Process Payment.
|
// Process Payment.
|
||||||
$result = $available_gateways[ $payment_method ]->process_payment( $order_id );
|
$result = $available_gateways[ $payment_method ]->process_payment( $order_id );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue