Skip to content
Snippets Groups Projects
Commit 208efeb1 authored by jose's avatar jose
Browse files

Issue #3418378 by Redwan Jamous: Use loadForUpdate when creating payments inside onNotify

parent e0319921
No related branches found
No related tags found
No related merge requests found
......@@ -222,7 +222,7 @@ class OffsiteRedirect2C2P extends OffsitePaymentGatewayBase {
$this->getLogger('commerce_2c2p')->debug('2C2P Payload Response notify ' . serialize($pt_res_payload));
/** @var \Drupal\commerce_order\entity\OrderInterface $order */
list(, $order_id) = explode('-', $pt_res_payload->invoiceNo);
$order = $this->entityTypeManager->getStorage('commerce_order')->loadUnchanged($order_id);
$order = $this->entityTypeManager->getStorage('commerce_order')->loadForUpdate($order_id);
if (!$order) {
$this->getLogger('commerce_2c2p')->error('Invalid order ID from gateway: @reference', ['@reference' => $pt_res_payload->invoiceNo]);
throw new PaymentGatewayException('Invalid order ID from gateway.');
......@@ -249,6 +249,11 @@ class OffsiteRedirect2C2P extends OffsitePaymentGatewayBase {
catch (\UnexpectedValueException|PaymentGatewayException) {
return new Response('', 200);
}
finally {
if ($order ?? NULL) {
$order->save();
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment