Testing

Troubleshooting Common API problems

Look up solutions to common problems.

General problems

My call returns an EXPECTED_INTEGER error code.

Cause:

The EXPECTED_INTEGER error code means Square was expecting information as an integer but was sent something else (for example, a string or a float). The most common cause is a Money object with an invalid amount value.

Solution:

  • Make sure the amount value is specified in in the smallest denomination of the currency used. For example, the smallest currency denomination for USD is pennies.
  • Make sure the amount value is specified as a positive integer number.
  • Make sure the amount value is greater than, or equal to, the valid minimum amount.Valid minimums are determined by the Location.country associated with the account:
    • United States and Canadaamount values must be integers greater than, or equal to, 1.
    • Australia, Japan, and the United Kingdomamount values must be integers greater than, or equal to, 100.

Read more about working with monetary amounts.

Python errors while parsing with ValueError: No JSON object could be decoded

Cause:

Your client library does not chunk decode the JSON response. Square API endpoints return responses in a Transfer-Encoding: chunked format. Many libraries, including our Connect SDKs, will handle this automatically for you. However, Python's httplib and JSON libraries will return the raw chunked request body.

Solution:

  • We strongly recommend you install and develop using our Connect SDKs. These SDKs add a helper wrapper that make it easier to integrate with Connect APIs.
  • If you do not use our SDKs, you can verify chunk encoding by checking the response for the Transfer-Encoding header. Alternatively, you can also examine the response body. If it alternates lines of hexadecimal numbers and JSON text, then the response is chunked. Learn more about Transfer-Encoding.

Authentication problems

My API call returns an AUTHENTICATION_ERROR error code.

Cause:

Authorization errors are typically caused by typos or mismatched credentials.

Solution:

  • Make sure you have replaced placeholders and default values in sample code with valid application credentials.
  • Make sure you have configured your credentials correctly. For example, if you are testing calls in production, make sure you are not using sandbox credentials.
  • Make sure you are using the right credential type. For example, application IDs are used for OAuth API calls but Personal Access Tokens are used in Transaction API calls.
  • If you are using SqPaymentForm to generate a credit card nonce, make sure the credentials you use in your sqpaymentform.js file match the credentials you use for API calls that use that nonce.
  • For REST calls, make sure you have set the Authorization header key to "Bearer" and a valid access token.

Note: Older APIs sometimes refer to the application ID as a client ID (client_id) .

Transactions API problems

I get a not_found error when calling the Charge endpoint.

Cause:

Receiving a not_found error from the Charge endpoint is most commonly caused by one of the following issues:

  • Not using the payments form to obtain a card nonce before calling the Charge endpoint.
  • Calling the Charge endpoint without providing a card nonce in the request.
  • Attempting to charge a card nonce with credentials different from those used to generate the card nonce. For example, attempting to use a live OAuth access token to charge a card_nonce generated with sandbox credentials will result in a not_found error.

Solution:

  • Use only the Square payment form to generate card nonces. See the Payment form Setup Guide for more information.
  • Be sure to charge a card_nonce with the same credentials used to generate it. You can find your application credentials in the Application Dashboard.

Webhooks problems

I did not receive my webhook notification

Cause:

Square Webhook notifications typically send within 60 seconds of the associated event. Applications must acknowledge the notification by responding within 10 seconds with an HTTP 2xx response code to acknowledge successful delivery. Unsuccessful deliveries are retried for up to 72 but after 72 hours have elapsed, the notification is discarded and will not be sent again.

Solution:

Verify your application is responding to notification deliveries in the required time window with an HTTP 2xx response code. For more information, see the Webhooks guide.

Square Payment Form problems

The SqPaymentForm iFrame is not loading

Cause:

The hosting site does not have HTTPS enabled or the page is rendering with the payment form in a hidden div.

Solution:

  • Secure your site with TLS to enable HTTPS calls or serve your website on localhost to test. See the HTTPS Overview for help getting HTTPS enabled for your site.
  • If you use the payment form in a hidden div, call SqPaymentForm.recalculateSize() when exposing the div to force SqPaymentForm to re-render the iframes.

SqPaymentForm will not generate form fields on a standard, multi-page web application

Cause:

By default, SqPaymentForm automatically generates form fields when it detects a DOMContentLoaded event (when the hosting page finishes loading) and it is properly initialized with a valid application ID and location ID. A failure to load properly typically means 1 of the following is likely true:

  • The application ID, location ID, or both were not provided.
  • The application ID and location ID combination is invalid. For example, the one of the IDs is a sandbox ID and one is a production ID.
  • The application ID is incorrectly set with an access token (e.g., your Sandbox Access Token or Personal Access Token). These values are not the same as the application ID.

Solution:

Check your initialization information and verify the values provided are correct:

 1// Set the application ID
 2var applicationId = "REPLACE_ME";
 3
 4// Set the location ID
 5var locationId = "REPLACE_ME";
 6
 7// Create and initialize a payment form object
 8var paymentForm = new SqPaymentForm({
 9  ...
10});

SqPaymentForm will not generate form fields on a single-page web application

Cause:

By default, SqPaymentForm automatically generates form fields when it detects a DOMContentLoaded event (when the hosting page finishes loading) and it is properly initialized with a valid application ID and location ID. The DOMContentLoaded event may not be triggered in single-page web applications when the form is initialized after the DOMContentLoaded event has fired.

Solution:

To manage the payment form initialization manually, set the autoBuild configuration option to false, and add the following function call to the page where you want to initialize the payment form:

paymentForm.build();

Calling paymentForm.build() when SqPaymentForm has already rendered the iframe fields will log an error to the JavaScript console.

SqPaymentForm listeners persisting on a single-page web application

Cause:

The SqPaymentForm object registers multiple event listeners on your webpage. These listeners go away when control is passed to a new page, but if you have a single-page web application, those listeners might remain longer than you want.

Solution:

To manually remove the listeners from your webpage, add the following function call where you want to clean up after the payment form:

paymentForm.destroy();

Contact Developer Support, join our Slack channel, or ask for help on Stack Overflow