Skip to content

Payment‐Module Interoperation

lat9 edited this page Feb 23, 2024 · 1 revision

The primary interoperability issue between OPC (or any checkout-page "consolidator") and a payment-method centers on the collective javascript/jQuery implementation. Newer payment-processors' APIs have become more complicated, resulting in additional jQuery/AJAX constructs within the associated Zen Cart payment-method.

That issue arises when the checkout-page and the payment-method bind to the same DOM event, whether it's the submission of the form or a click of a submit-button. The net result is that some jQuery fragment is not run which, in turn, causes the page/payment-method integration to fail (i.e. orders cannot be placed).

The following guidelines are assumed by One-Page Checkout in support of interoperation with the varied payment-methods, identifying which selectors each class of module binds to. This will serve to reduce those jQuery event conflicts and lessen the integration headaches for payment-method developers.

Common Page Elements

There are four (4) elements on the "normal" checkout-payment page that have bearing on the page's form submissions:

  1. The form itself, named checkout_payment.
  2. The form's submit button.
  3. The form's optional credit-class modules' (e.g. coupons, vouchers or reward-points) submit buttons.
  4. A global javascript/jQuery variable named submitter. This variable is set by the page to identify whether (0) or not (1) the form's submission requires a payment-method's intervention. This value is set to 1 (no payment-method required) by the page's processing when one or more of the following conditions is met:
  • The order's total value is 0.
  • A credit-class order-total module's submit-button was clicked.
  • A gift-certificate has been applied to the order and its associated value "covers" the cost of the order.

One-Page Checkout Operations

OPC renders its data-gathering page (checkout_one) with no button that actually submits the form. All form submittals are handled via its jQuery processing (/includes/modules/pages/checkout_one/jscript_main.php), allowing OPC to properly sequence the checkout processing.

Instead, the page's jQuery processing binds to a click of the form's pseudo-submit buttons (both order-confirmation and credit-class modules' "Apply" buttons). Upon detecting such a click, the jQuery sets the value of the submitter variable in a manner similar to the checkout_payment page. Additionally, that processing disables the Enter button from acting as a default form-submittal. If that jQuery processing detects that no non-payment-related issues are present, that processing issues a programmatic submit of the page's form.

Payment-Method Operations

If a payment method requires some special action on the submittal of the checkout_payment form, that payment method should bind only to the form's submit event, performing its actions only when the value of submitter is 0 and the payment-method is currently selected.

Clone this wiki locally