OPC 2.5.5 working with SquarewebPay with these edits:
CONSOLE ERROR log that promted the fix...
Setting orderConfirmed (1), submitter (null) square.js:3:78284
Form being submitted, submit_type(review square.js:3:78284
setFormSubmitButton, payment-module: square_webPay square.js:3:78284
Showing "review" square.js:3:78284
setFormSubmitButton, enabling Review and Confirm buttons. square.js:3:78284
Form checked, passed (true) square.js:3:78284
Cookie warnings 2
The value of the attribute “expires” for the cookie “_ga_G4K94XL4P6” has been overwritten. index.php
Object { cache: false, type: "POST", traditional: true, dataType: "json", timeout: 5000, data: {…}, url: "ajax.php?act=ajaxOnePageCheckout&method=getOrderTotal", error: error(jqXHR, textStatus, errorThrown) }
square.js:3:78284
setFormSubmitButton, payment-module: square_webPay square.js:3:78284
Showing "review" square.js:3:78284
setFormSubmitButton, enabling Review and Confirm buttons. square.js:3:78284
Setting orderConfirmed (0), submitter (null) square.js:3:78284
jQuery version: 3.7.1 square.js:3:78284
TypeError: MutationObserver.observe: Argument 1 is not an object. web-client-content-script.js:2:1432872
Feature Policy: Skipping unsupported feature name “clipboard-write”. web-client-content-script.js:2:965680
Feature Policy: Skipping unsupported feature name “clipboard-write”. web-client-content-script.js:2:965905
Feature Policy: Skipping unsupported feature name “clipboard-write”. web-client-content-script.js:2:1424162
Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. webclient-infield.html
WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER. main-iframe.js:3:383356
Partitioned cookie or storage access was provided to “https://web.squarecdn.com/1.82.3/main-iframe.html?applicationId=xyxyxyxyxyxyxyxy&hostname=needtoorder.com” because it is loaded in the third-party context and dynamic state partitioning is enabled. main-iframe.js:3:379397
found checkoutOneSubmit button! square.js:3:78284
I’ve patched the One Page Checkout v2.5.5 plugin so it submits via requestSubmit() (with a real submit button) instead of form.submit(). That prevents Square from seeing submitter (null), which is the usual reason the token/nonce never gets attached and your square_webPay.php logs “missing token result”.
I updated both:
includes/modules/pages/checkout_one/jquery.checkout_one.js
includes/modules/pages/checkout_one/jquery.checkout_one.min.js
Each now prefers:
form.requestSubmit(button)
fallback to button.click()
last resort form.submit()
File 1 (unminified)
/includes/modules/pages/checkout_one/jquery.checkout_one.js
Edit A — checkout_confirmation submit (Square “submitter = null” fix)
Find:
jQuery('form[name="checkout_confirmation"]')[0].submit();
Replace with:
(function(){
var form = jQuery('form[name="checkout_confirmation"]')[0];
if (!form) { return; }
var btn = document.getElementById('checkoutOneSubmit') || document.getElementById('card-button');
if (!btn) {
btn = form.querySelector('button[type="submit"], input[type="submit"]');
}
if (typeof form.requestSubmit === 'function') {
form.requestSubmit(btn || undefined);
} else if (btn) {
btn.click();
} else {
form.submit();
}
})();
Edit B — checkout_payment submit (when payment method handles submission)
Find:
jQuery('form[name="checkout_payment"]').submit();
Replace with:
(function(){
var form = jQuery('form[name="checkout_payment"]')[0];
if (!form) { return; }
var btn = document.getElementById('checkoutOneSubmit') || document.getElementById('card-button');
if (!btn) { btn = form.querySelector('button[type="submit"], input[type="submit"]'); }
if (typeof form.requestSubmit === 'function') {
form.requestSubmit(btn || undefined);
} else if (btn) {
btn.click();
} else {
form.submit();
}
})();
Edit C — credit-class submit (same form submit path, different trigger)
Find:
jQuery('form[name="checkout_payment"]').submit();
Replace with the same block as Edit B (above).
This occurs in the “Submitting credit-class request” handler.
File 2 (minified)
/includes/modules/pages/checkout_one/jquery.checkout_one.min.js
This file contains the same functional changes, just compressed. For a forum post, the cleanest note is:
“Updated the 3 programmatic form submissions from .submit() to a requestSubmit()/click fallback so Square receives a non-null submitter, allowing tokenization/nonce injection.”
If they insist on literal paste, here are the three exact replacements by search string, which are quick and reliable even in minified code:
Minified replacement 1 — confirmation form
Search for:
jQuery('form[name="checkout_confirmation"]')[0].submit();
Replace with (minified IIFE):
(function(){var f=jQuery('form[name="checkout_confirmation"]')[0];if(!f)return;var b=document.getElementById('checkoutOneSubmit')||document.getElementById('card-button');if(!b){b=f.querySelector('button[type="submit"], input[type="submit"]')}if(typeof f.requestSubmit==='function'){f.requestSubmit(b||void 0)}else if(b){b.click()}else{f.submit()}})();
Minified replacement 2 — checkout_payment submit (1st occurrence)
Search for:
jQuery('form[name="checkout_payment"]').submit();
Replace with:
(function(){var f=jQuery('form[name="checkout_payment"]')[0];if(!f)return;var b=document.getElementById('checkoutOneSubmit')||document.getElementById('card-button');if(!b){b=f.querySelector('button[type="submit"], input[type="submit"]')}if(typeof f.requestSubmit==='function'){f.requestSubmit(b||void 0)}else if(b){b.click()}else{f.submit()}})();
Minified replacement 3 — checkout_payment submit (2nd occurrence)
Do the same replacement again for the second .submit() occurrence (credit-class submit path).