k I’ll try to figure out how to convert the payment in to an order later on. Thank for the advice
I am 1000% that I use the correct (production) location ID and application ID.
Do you see ANYthing wrong i a ny shape form with this code (sqpaymentform.js) below?
(I replaced the last 5 characters with stars)
PS: I’m pretty curious to when I’m supposed to use “Production Application Secret”. I have not used this in ANY of my codes.
var paymentForm = new SqPaymentForm({
applicationId: "sq0idp-vgCGDav9Nw5b5ghGV*****",
locationId: "LZC6Y0W4*****",
inputClass: 'sq-input',
inputStyles: [{
fontSize: '.9em'
}],
cardNumber: {
elementId: 'sq-card-number',
placeholder: '•••• •••• •••• ••••'
},
cvv: {
elementId: 'sq-cvv',
placeholder: 'CVV'
},
expirationDate: {
elementId: 'sq-expiration-date',
placeholder: 'MM/YY'
},
postalCode: {
elementId: 'sq-postal-code'
},
callbacks: {
/*
* callback function: cardNonceResponseReceived
* Triggered when: SqPaymentForm completes a card nonce request
*/
cardNonceResponseReceived: function(errors, nonce, cardData) {
if (errors) {
// Log errors from nonce generation to the Javascript console
console.log("Encountered errors:");
errors.forEach(function(error) {
alert('error: sqpaymentform.js: ' + error.message);
});
return;
}
// Assign the nonce value to the hidden form field
document.getElementById('card-nonce').value = nonce;
// POST the nonce form to the payment processing page
document.getElementById('nonce-form').submit();
}
}
});
/*
* -----------------------------------------------------------
* function: requestCardNonce
*
* requestCardNonce is triggered when the "Pay with credit card" button is
* clicked
*
* Modifying this function is not required, but can be customized if you
* wish to take additional action when the form button is clicked.
*/
//function requestCardNonce(event) { // removed this for now
function onGetCardNonce(event) {
// Don't submit the form until SqPaymentForm returns with a nonce
event.preventDefault();
// Request a nonce from the SqPaymentForm object
paymentForm.requestCardNonce();
}