...
<script> // On checkout form submit var cardNonce = {Set "formCardNonce" value} var cardNoncePostalCode = {Set "formCardNoncePostalCode" value} var billingPostalCode = {Set billing postal code value} cardNonce = $.trim(cardNonce); cardNoncePostalCode = $.trim(cardNoncePostalCode); billingPostalCode = $.trim(billingPostalCode); // Checkout form validation scripts .. .. .. // Before return success if(billingPostalCode == '' || cardNonce != '') { if($.trim(cardNoncePostalCode) != '' && ($.trim(billingPostalCode) != $.trim(cardNoncePostalCode))) { alert('The postal code entered in the credit card form mismatched with the billing address. Please refresh the page and try again.') return false; } // Submit the checkout form } else { var squareURL = {SQPaymentForm URL};
window.open(squareURL,'','height=500,width=500,left=100,top=100 ,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no ,directories=no, status=no'); } </script>
|
Square SQPaymentForm JS Changes
Replace the square application id in "applicationId" const in the JS file.
Alternative Implementation
If you would like to have Square's SQPaymentForm embedded onto your checkout page, you will have to follow Sqaure's documentation, found here and make the required changes to your lander to support this.
Upsells with Square
Add these hidden inputs to your upsell page code.
Code Block |
---|
<input type='hidden' name='prepaidType' value='SQUARE'>
<input type='hidden' name='formCardNonce' id='formCardNonce' value=''> |