Problem/Motivation
The Drupal Commerce module, when used with the commerce_quickpay_gateway module, occasionally sends two requests during the payment process, causing an ID collision. This results in QuickPay throwing an error indicating that the order is already taken or exists. The issue stems from JavaScript (jQuery) code in the module that causes an extra form submission, sending multiple requests to create an order with the same ID. To align with Drupal’s direction of phasing out jQuery support, we propose replacing the jQuery-based code with vanilla JavaScript.
Steps to reproduce
- Install Drupal Commerce 3.0.
- Install commerce_quickpay_gateway 2.x-dev@dev.
- Configure a payment gateway for QuickPay.
- Attempt to process a payment for an order.
- Observe that the redirect triggers two requests: the first is treated as a cancel, and the second attempts to load, often resulting in a QuickPay error stating the order is already taken.
Proposed resolution
Use the once method to ensure the payment request is triggered only once, preventing multiple simultaneous requests and eliminating ID collisions. Additionally, replace the jQuery-based code with vanilla JavaScript to align with Drupal’s move away from jQuery support.
Issue fork commerce-3535970
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
matthew10 commentedComment #3
matthew10 commentedComment #5
matthew10 commentedThe issue with duplicate form submissions in the commerce_quickpay_gateway module has been addressed. The changes modify the commercePaymentRedirect behavior to use Drupal's once method, ensuring the payment redirect form is submitted only once and preventing multiple requests that caused order ID collisions.
Comment #6
jsacksick commentedThe code was already not relying on JQuery, but the library stiill depends on it, I think we need to add a dependency on core/once too. Can you make those changes please?
Comment #7
jsacksick commentedComment #9
jsacksick commented