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

  1. Install Drupal Commerce 3.0.
  2. Install commerce_quickpay_gateway 2.x-dev@dev.
  3. Configure a payment gateway for QuickPay.
  4. Attempt to process a payment for an order.
  5. 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

Command icon 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

matthew10 created an issue. See original summary.

matthew10’s picture

Category: Feature request » Bug report
matthew10’s picture

Issue summary: View changes

matthew10’s picture

Assigned: matthew10 » Unassigned
Status: Active » Needs review

The 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.

jsacksick’s picture

The 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?

jsacksick’s picture

Version: 3.0.0 » 3.x-dev

  • jsacksick committed cc6d8ba6 on 3.x authored by matthew10
    Issue #3535970 by matthew10, jsacksick: Ensure the offsite redirect form...
jsacksick’s picture

Title: Multiple Payment Requests in commerce_quickpay_gateway Cause Order ID Collisions » Ensure the offsite redirect form is submitted only once
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.