sqpaymentform-nodejs-starterkit
sqpaymentform-nodejs-starterkit copied to clipboard
SqPaymentForm results in error without locationId
<script type="text/javascript">
// Create and initialize a payment form object
const paymentForm = new SqPaymentForm({
// Initialize the payment form elements
//TODO: Replace with your sandbox application ID
applicationId: "xxxxxxxxxx",
locationId: "xxxxxxxxxxx",
inputClass: 'sq-input',
autoBuild: false,
// Customize the CSS for SqPaymentForm iframe elements
inputStyles: [{
fontSize: '16px',
lineHeight: '24px',
padding: '16px',
placeholderColor: '#a0a0a0',
backgroundColor: 'transparent',
}],
// Initialize the credit card placeholders
cardNumber: {
elementId: 'sq-card-number',
placeholder: 'Card Number'
},
cvv: {
elementId: 'sq-cvv',
placeholder: 'CVV'
},
expirationDate: {
elementId: 'sq-expiration-date',
placeholder: 'MM/YY'
},
postalCode: {
elementId: 'sq-postal-code',
placeholder: 'Postal'
},
// SqPaymentForm callback functions
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 browser developer console.
console.error('Encountered errors:');
errors.forEach(function (error) {
console.error(' ' + error.message);
});
alert('Encountered errors, check browser developer console for more details');
return;
}
alert(`The generated nonce is:\n${nonce}`);
//TODO: Replace alert with code in step 2.1
}
}
});
paymentForm.build();
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();
}
//TODO: paste code from step 1.2.4
Change the document to add locationId to SqPaymentForm
Hi!
Thanks for reaching out.
With the SqPaymentForm the locationId isn't required to render the form or process a payment. We definitely recommend passing a location to the payment for better tracking but it's not currently required. The locationId is however required when using digital wallets.
We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team.
Thanks
Hi response Thanks
Hi! What is Process-Payment in the code?
Hi @BilalKhan1998 can you clarify what you mean? process-payment
is the route where you actually create the payment in Square's APIs: https://github.com/square/sqpaymentform-nodejs-starterkit/blob/master/server.js#L35.
Hi @BilalKhan1998 can you clarify what you mean?
process-payment
is the route where you actually create the payment in Square's APIs: https://github.com/square/sqpaymentform-nodejs-starterkit/blob/master/server.js#L35.
I am creating Application in Webform Asp.net not in Mvc , But i am stuck where it use Fetch api, In word Fetch it wrotes Process-Payments, What was that ?i didn't see any code of Process-Payment, IF THAT WAS a page where is that? what we have to code there? can you please explain
Hi @BilalKhan1998 can you clarify what you mean?
process-payment
is the route where you actually create the payment in Square's APIs: https://github.com/square/sqpaymentform-nodejs-starterkit/blob/master/server.js#L35.
https://github.com/square/sqpaymentform-nodejs-starterkit/blob/master/server.js#L35 check this code please , i am taking help from this