Testing

Sandbox Test Values

Test credit card numbers and payment nonces you can use to make test payments.

Sandbox test values are used to test payments in the Square Sandbox. You can use test credit cards with the payment form and In-App Payments SDK to input a fake credit card that will generate a testable payment nonce.

If you are using the Connect v2 Payments API to generate payments in the sandbox, you can use one of the sandbox test nonces as the source_id in the payment request.

Note

For information about test values for the deprecated legacy Sandbox, see Legacy Sandbox Test Values.

Test credit card
Permalink Get a link to this section

The sandbox supports a collection of special credit card values you can use to simulate payment scenarios.


Use the information below to get started quickly to generate a valid sandbox nonce with the Square payment form or In-App Payments SDK.

Card informationValue
Card number4111 1111 1111 1111
Expiration date12/21
CVV111

Generating success states
Permalink Get a link to this section

Test values
Permalink Get a link to this section

You can use the following test credit card numbers to generate a sandbox card nonce with the Square payment form or In-App Payments SDK.

BrandNumberCVVVerification Code
Visa4111 1111 1111 1111111N/A
Visa EU4310 0000 0000 0007111123456
MasterCard5105 1051 0510 5100111N/A
MasterCard EU5500 0000 0000 0004111123456
Discover6011 0000 0000 0004111N/A
Diners Club3000 0000 0000 04111N/A
JCB3569 9900 1009 5841111N/A
American Express3400 000000 000091111N/A
American Express EU37000 00000 000021111123456
China UnionPay6222 9888 1234 0000123N/A

Note

When testing the SCA flow with one of the European Union test cards, the Verification Code simulates the SMS verification code sent to the buyer mobile phone during an actual transaction.

Other credit card information
Permalink Get a link to this section

  • To test a successful payment, provide any future-dated expiration date.

  • American Express cards have a four digit CVV.

Important

Payments in USD (United States), CAD (Canada), or GBP (United Kingdom) also require a valid postal code.

CreatePayment and CreateCustomerCard endpoint test values
Permalink Get a link to this section

Sandbox test nonces
Permalink Get a link to this section

If you do not want to generate a nonce with the Square Payment Form or In-App Payments SDK, you can generate a successful response from the payment endpoint supported in the sandbox that you are using.

v2 Sandbox
Permalink Get a link to this section

Use the Payments.CreatePayment endpoint for card and card on file (CoF) payments with the following test values:

API CallField NameValue
Payments API
(card)
card_noncecnon:card-nonce-ok
Payments API
(card on file)
customer_card_idccof:customer-card-id-ok
Customers API
(save card)
billing_address.postal_code94103

If you provide a sandbox nonce value to the CreateCustomerCard endpoint, you must provide "94103" as the postal code in the billing_address field or the request will fail and return an with an invalid postal code error.

Payment form test values for SCA
Permalink Get a link to this section

Use the SqPaymentForm.verifyBuyer function for card and card on file (CoF) SCA challenges with the following test values:

API CallField NameValueVerification Code
SqPaymentForm.verifyBuyer
(card)
card_noncecnon:card-nonce-requires-verification123456
SqPaymentForm.verifyBuyer
(card on file)
customer_card_idccof:customer-card-id-requires-verification123456

The SCA flow requires that the buyer provides a code sent to their mobile phone in an SMS message. When testing in the sandbox use the Verification Code to simulate the code sent via SMS.

Important

When testing the SCA flow in v2 Sandbox, be sure to initialize SqPaymentForm with a UK location ID.

The SCA flow and these test values are not supported in the legacy sandbox.

Generating error states
Permalink Get a link to this section

You can reproduce certain error states in the sandbox by providing special values in the Square payment form, In-App Payments SDK, or the CreatePayment endpoint.

Test values
Permalink Get a link to this section

If you use one of the following values in the Square payment form or In-App Payments SDK, the nonce returned will trigger an error when it is processed by the CreatePayment endpoint:

Desired error stateTest values
Card CVV incorrectCVV: 911
Card postal code incorrectPostal code: 99999
Card expiration date incorrectExpiration date: 01/40
Card declined numberCard number: 4000000000000002
Card on file auth declinedPAN: 4000000000000010

CreatePayment and CreateCustomerCard test values
Permalink Get a link to this section

If you do not want to generate a nonce with the Square payment form or In-App Payments SDK, you can generate errors directly in your request to the Payments.CreatePayment endpoint.

Important

If you send a sandbox card_nonce value to CreateCustomerCard, you must provide 94103 as the postal code in the billing_address field or the request will fail and return an invalid postal code error.

v2 Sandbox
Permalink Get a link to this section

Use the CreatePayment endpoint.

Error statecard_noncecustomer_card_id
Bad CVVcnon:card-nonce-rejected-cvvccof:customer-card-id-rejected-cvv
Bad postal codecnon:card-nonce-rejected-postalcodeccof:customer-card-id-rejected-postalcode
Bad expiration datecnon:card-nonce-rejected-expirationccof:customer-card-id-rejected-expiration
Card declinedcnon:card-nonce-declinedccof:customer-card-id-declined
Card nonce already usedcnon:card-nonce-rejected-cvvN/A

Working with sandbox locations
Permalink Get a link to this section

Your sandbox account comes with 1 mock location per application. This location is unrelated to the production locations listed in the Square Dashboard

The sandbox location ID for a given application is listed on the Locations tab of the application control panel in the Application Dashboard. You can also fetch the location ID programmatically by calling ListLocations with a sandbox access token.