sqpaymentform-nodejs-starterkit icon indicating copy to clipboard operation
sqpaymentform-nodejs-starterkit copied to clipboard

SqPaymentForm results in error without locationId

Open PeterTakahashi opened this issue 5 years ago • 7 comments

<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

PeterTakahashi avatar Oct 28 '19 15:10 PeterTakahashi

Change the document to add locationId to SqPaymentForm

PeterTakahashi avatar Oct 28 '19 15:10 PeterTakahashi

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

bwisem avatar Dec 12 '19 20:12 bwisem

Hi response Thanks

PeterTakahashi avatar Dec 24 '19 08:12 PeterTakahashi

Hi! What is Process-Payment in the code?

BilalKhan1998 avatar Dec 14 '20 07:12 BilalKhan1998

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.

StephenJosey avatar Dec 14 '20 16:12 StephenJosey

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

BilalKhan1998 avatar Dec 15 '20 06:12 BilalKhan1998

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

BilalKhan1998 avatar Dec 15 '20 06:12 BilalKhan1998