Author End-to-End Tests in Natural Language with KaneAI

Plan, Author, and Evolve E2E Tests for Web and Mobile Apps in Natural Language.

Square Sandbox: How to Set It Up and Test Every Checkout Outcome

Set up the Square Sandbox, copy the official test card numbers for approvals, declines and CVV errors, and automate checkout tests without code.

Summarise with AI

The Square Sandbox is a free isolated copy of the Square APIs where test payments are never actually charged. Every app in the Square Developer Console comes with Sandbox credentials (a test seller account and a Sandbox dashboard). You make your requests to connect.squareupsandbox.com and use the test cards (e.g. Visa 4111 1111 1111 1111 with CVV 111).

A fairly common Square bug is not "payment failed"; it's "payment failed, and the store said it worked" or "the decline message never appeared". That's where the Sandbox comes in, and this guide walks you through setting it up, what the Square test cards give you and how you can in fact turn the entire checkout matrix into a repeatable test using KaneAI from TestMu AI. It's part of our wider guide to ecommerce testing.

TL;DR

The Square Sandbox is Square's free test environment: requests go to connect.squareupsandbox.com with a Sandbox Access token, and only Square's published test values work there. Use Visa 4111 1111 1111 1111 with CVV 111 for an approval and 4000 0000 0000 0002 for a decline, with any future expiry date.

Square Sandbox Test Cards by Outcome

  • Approved payment: The Square test card 4111 1111 1111 1111 is a Visa that tokenizes and completes in the Sandbox with CVV 111, any future expiry date and a valid postal code such as 94103. Postal code required for USD: Yes.
  • Declined payment: The Square Sandbox card 4000 0000 0000 0002 tokenizes in the card form and fails only when your server calls CreatePayment, so the checkout must read that response and show the decline.
  • Incorrect CVV: CVV 911 is a Square Sandbox test value that returns "Card CVV incorrect" from CreatePayment, although the card form accepts it and returns a payment token.
  • Incorrect postal code: Postal code 99999 returns "Card postal code incorrect" from CreatePayment in the Square Sandbox, so the checkout should ask the buyer to correct the postal code.
  • Incorrect expiration date: Expiration 01/40 returns "Card expiration date incorrect" from CreatePayment in the Square Sandbox, even though the card form accepts 01/40 as a future date.
  • Strong Customer Authentication: The Square Sandbox test card Visa EU 4310 0000 0020 1019 opens a verification modal that accepts the code 123456, and the Sandbox shows that challenge in every region. Verification challenge: Yes.

Square Live Mode vs Sandbox Mode

  • Separate credentials: Sandbox tokens fail in production and production tokens fail in the Sandbox with an UNAUTHORIZED error. Square test credit card numbers are rejected in production, and the Sandbox rejects real cards. Works with live keys: No.
  • KaneAI: KaneAI by TestMu AI runs the five-row Square checkout matrix from plain-English steps, with the card values as parameters and one dataset row per outcome, so each row reports its own result. Code required: No.

What Is the Square Sandbox?

The Square Sandbox is a separate server environment in which you can test Square APIs without any real money or real seller data being involved. It's automatically provisioned by Square for every app that you register in the Developer Console, and comes with its own Sandbox Square Dashboard for each test account (Square Sandbox overview).

Four facts decide how you test against it:

  • Separate base URL. Sandbox requests go to https://connect.squareupsandbox.com; production goes to https://connect.squareup.com.
  • Separate credentials. Sandbox tokens and resources won't work in production and production tokens won't work in the Sandbox. A mismatch will result in an UNAUTHORIZED error.
  • Test values only. The Sandbox will reject real cards, and Square's test values are rejected in production.
  • Free. Unlimited Sandbox API calls and Sandbox payments are completely free as no actual payment is processed.

For a quick visual walkthrough of this concept, watch the video below from TestMu AI.

Youtube thumbnail

Subscribe to the TestMu AI YouTube channel for more tutorials on testing and automation.

How Do You Set Up the Square Sandbox and Get Your Test Credentials?

A Square Sandbox setup occurs in the Square Developer Console. You'll need a Square developer account and one app.

  • Create or open an app in the Square Developer Console.
  • Switch the environment toggle to Sandbox. The Developer Console, API Explorer and GraphQL Explorer all have this toggle.
  • Copy the Sandbox Access token from the application's Credentials page. Square states that the default test account token is the same as this value and will authorize any Sandbox request. Store it as an environment variable or a secret, never in a URL or a test step.
  • Copy the Sandbox location ID from the Locations page. Each application has its own mock Sandbox location (separate from the production locations), and you can test the Square APIs in the Sandbox.
  • Open the Sandbox dashboard. Head to Sandbox test accounts and select Square Dashboard alongside the account. That's where the Sandbox payments will appear.
  • Optional: add test accounts. You can create up to 10 more Sandbox test accounts (each one simulating a seller in a supported country) so payments will be handled according to that country's rules.
  • Point your client at the Sandbox. For the Web Payments SDK, load https://sandbox.web.squarecdn.com/v1/square.js and initialize Square.payments(appId, locationId) with your Sandbox app ID and location (Web Payments SDK quickstart).

One rule that QA teams often miss: don't store any real personal data (names, emails, phone numbers, birthdays) in the Sandbox. Use completely made-up buyer details in every test.

Which Square Test Card Numbers Should You Use?

All Square test cards for card-not-present payments have a future expiry date. Enter them into the card field of the Web Payments SDK or In-App Payments SDK (Square Sandbox Payments).

BrandCard numberCVV
Visa4111 1111 1111 1111111
Mastercard5105 1051 0510 5100111
Discover6011 0000 0000 0004111
Diners Club3000 000000 0004111
JCB3569 9900 1009 5841111
American Express3400 000000 000091111
China UnionPay6222 9888 1234 0000123
Square Gift Card7783 3200 0000 0000none

USD, CAD and GBP payments all require a valid postal code (the Square Cards API walk-through uses 94103). Japan payments do not use a postal code.

These numbers only work in the Square Sandbox. A Stripe or PayPal test number will not generate scripted results on Square. If you're also testing with Stripe, then use our list of Stripe test cards.

Which Square Sandbox Values Cause the Declines and CVV Errors?

Square triggers Sandbox errors with certain CVV, postal code, expiry and card number values. Each of the values listed below will still produce a token in the card form, and the error is only raised when your server subsequently passes that token to CreatePayment.

Test valueError state
CVV 911Card CVV incorrect
Postal code 99999Card postal code incorrect
Expiration 01/40Card expiration date incorrect
Card number 4000 0000 0000 0002Card declined
Card number 4000 0000 0000 0010Card on file auth declined

That detail is important for testing. The card form will happily accept 4000 0000 0000 0002, so the only place a decline is going to show up is in how your server is processing the CreatePayment response.

If your checkout is showing a success page for that card, then your server is not at all checking the payment result. That is the one absolutely vital Sandbox test you can run.

Kane CLI run on Square's Sandbox Web Payments Showcase: decline test card 4000 0000 0000 0002 typed into the Square card form, Pay now clicked and a Successful Payment message shown

Square also simulates risk levels by charge amount: 2222 (in the smallest currency unit) is MODERATE risk, 3333 is HIGH, and all else is NORMAL.

3D Secure (SCA) Test Cards

The Web Payments SDK has its own SCA test cards. Visa EU 4310 0000 0020 1019 (CVV 111) will open a verification modal; enter 123456. Visa 4800 0000 0000 0004 will pass with no challenge, and Visa 4811 1100 0000 0008 will fail verification with no challenge.

The Sandbox will show buyer challenges in all regions, whereas in production they will only show where they are mandated, so a challenge in the Sandbox doesn't mean that your US buyers will see one.

What's the Difference Between the Square Sandbox and Production?

Square Sandbox and Production run the same APIs, just with different data, credentials and limits. Use this table when a test passes in one and fails in the other.

AreaSandboxProduction
Base URLconnect.squareupsandbox.comconnect.squareup.com
Web Payments SDK scriptsandbox.web.squarecdn.com/v1/square.jsweb.squarecdn.com/v1/square.js
CredentialsSandbox Access token, Sandbox app IDProduction token and app ID
Cards acceptedSquare test values onlyReal cards only
Money moved / feesNoneReal charges, normal fees
SCA challengesShown in all regionsOnly in mandated regions
DashboardSandbox Square Dashboard per test account: no receipts, refunds viewable but not issuable, no Banking tabFull Square Dashboard
Not availableSquare hardware, Square for Restaurants, Point of Sale, Invoices, Point of Sale API, Snippets API, Sites API, Reader SDKAll

For proper API testing, Square actually recommends API Explorer in Sandbox mode rather than the Sandbox dashboard (which is subject to the above limitations). When you go live, you just swap in the production app ID, a seller location ID from the Locations API, the production access token and the production script as per the Square deploy guide.

Why Isn't My Square Sandbox Payment Appearing in the Dashboard?

A Sandbox payment that 'disappears' is almost invariably in a different location to where you're looking. Check those in that order:

  • You're in the Production dashboard. Sandbox payments only appear in the Sandbox Square dashboard (which you access from your Sandbox test accounts in the Developer Console).
  • You're looking at a different test account. The Sandbox Access token on the Credentials page is for the default test account, so any payments made using it will appear in that account.
  • The request never got to the Sandbox. If you send a production token to the Sandbox URL or vice versa, you get UNAUTHORIZED and nothing else is created.
  • The payment is an ACH test. Sandbox bank transfer payments will start as PENDING and will either go to COMPLETED or FAILED after one minute.
  • You'd expect a dashboard feature that the Sandbox doesn't have. You can't generate receipts, and you can't issue refunds from the Sandbox dashboard.

How Do You Test Square Sandbox Declines Without a Card Form?

Square provides fixed source_id values which act as stand-ins for card tokens so you can test your server's CreatePayment handling completely without any browser. cnon:card-nonce-ok will succeed; cnon:card-nonce-declined, cnon:card-nonce-rejected-cvv, cnon:card-nonce-rejected-postalcode and cnon:card-nonce-rejected-expiration will all fail with the appropriate error and cnon:card-nonce-already-used will simulate a payment token that has already been used. CreatePayment only requires source_id and idempotency_key (max 45 chars); amount_money is in the smallest currency unit and location_id defaults to the primary location if not provided.

This script makes certain that each value gets the correct HTTP outcome. It will fail (exit code 1) if a failure is returned as a success or a success is returned as a failure. It only checks the HTTP status class and will print the body on a mismatch.

#!/usr/bin/env bash
# Square sandbox CreatePayment outcome check. Requires curl and uuidgen.
set -euo pipefail

: "${SQUARE_SANDBOX_TOKEN:?Set SQUARE_SANDBOX_TOKEN to your Sandbox Access token}"
: "${SQUARE_LOCATION_ID:?Set SQUARE_LOCATION_ID to your sandbox location ID}"
: "${SQUARE_VERSION:?Set SQUARE_VERSION to the API version your app targets}"

BASE_URL="https://connect.squareupsandbox.com"
AMOUNT="${AMOUNT:-100}"      # smallest currency unit: 100 = 1.00 USD
CURRENCY="${CURRENCY:-USD}"
FAILED=0

check() {
  local nonce="$1" expect="$2" body status
  body="$(mktemp)"
  status="$(curl -sS -o "$body" -w '%{http_code}' -X POST "$BASE_URL/v2/payments" \
    -H "Authorization: Bearer $SQUARE_SANDBOX_TOKEN" \
    -H "Square-Version: $SQUARE_VERSION" \
    -H "Content-Type: application/json" \
    -d "{\"source_id\":\"$nonce\",\"idempotency_key\":\"$(uuidgen)\",\"location_id\":\"$SQUARE_LOCATION_ID\",\"amount_money\":{\"amount\":$AMOUNT,\"currency\":\"$CURRENCY\"}}")"
  if { [[ "$expect" == success && "$status" == 2* ]] || [[ "$expect" == error && "$status" != 2* ]]; }; then
    echo "PASS  $nonce -> HTTP $status"
  else
    echo "FAIL  $nonce -> HTTP $status (expected $expect)"; cat "$body"; echo
    FAILED=1
  fi
  rm -f "$body"
}

check "cnon:card-nonce-ok"                   success
check "cnon:card-nonce-declined"             error
check "cnon:card-nonce-rejected-cvv"         error
check "cnon:card-nonce-rejected-postalcode"  error
check "cnon:card-nonce-rejected-expiration"  error
check "cnon:card-nonce-already-used"         error

exit "$FAILED"

Square's CreatePayment reference uses Square-Version: 2026-11-18 in their example, and you should set the version that your app is actually targeting. The token is pulled from the environment; it's never written into the URL or the script.

This proves Square delivers on what you'd expect. It doesn't prove your store is communicating the right message to the buyer. That requires a browser test.

The Five-Row Square Checkout Matrix

The Five-Row Square Checkout Matrix is the minimum set of Sandbox checkout runs you need to complete before you can switch a Square integration over to production. Each row has one input change and one corresponding result that you can see in your own UI.

RowCard numberExpiryCVVPostal codeExpected result
1. Approved4111 1111 1111 111112/3011194103Order confirmation; payment visible in the Sandbox dashboard
2. Declined4000 0000 0000 000212/3011194103A decline message; no confirmation page; cart kept
3. Bad CVV4111 1111 1111 111112/3091194103A CVV error the buyer can fix and retry
4. Bad postal code4111 1111 1111 111112/3011199999A postal code error
5. Bad expiry4111 1111 1111 111101/4011194103An expiration error
Five-row Square checkout matrix: approved, declined, bad CVV, bad postal code and bad expiry rows with the Square Sandbox test values and the expected checkout result for each

Add a sixth row for SCA (Visa EU 4310 0000 0020 1019, code 123456) if you're selling into regions where it's required. Pass the criteria for each row (the buyer never sees a success page for rows 2-5), and the card will be fixed after a decline with exactly one COMPLETED payment in the Sandbox dashboard.

Automate web and mobile tests with KaneAI by TestMu AI

How Do You Automate Square Checkout Tests Without Writing a Line of Code?

KaneAI (the natural language testing agent from TestMu AI) takes the matrix above and turns it into a single test case which runs once per row. You describe the steps in plain English and KaneAI plans and executes them in a real browser.

1. Create parameters for the values that change. In the KaneAI authoring input, type / and select Create Parameter. Create card_number, card_expiry, card_cvv, postal_code and expected_text and reference them as ${card_number} etc (Using Parameters).

2. Write the test in plain English.

Open the staging store and add the "Test T-shirt" product to the cart
Go to checkout and fill in shipping with test buyer details
Type ${card_number} in the card number field
Type ${card_expiry} in the expiration field
Type ${card_cvv} in the CVV field
Type ${postal_code} in the postal code field
Click "Pay"
Assert the page shows "${expected_text}"

Replace the product name and button label with the ones in your own store. Fill expected_text with the exact message your checkout shows for each row (copy it from one manual run per row).

3. Load the five rows as a dataset. KaneAI will create a Default Dataset whenever a test uses parameters. In your Test Manager project, you would open up Datasets and add one row per matrix row as a run will create one test instance per row.

If a cell is blank, KaneAI will enter the blank value and will not fall back to the seed value, so you must populate every cell.

4. Add a network check on desktop web. Type / and select Assert Network Logs to assert on the call that your checkout makes to your own payment endpoint (e.g. that the declined row doesn't return a success status). TestMu AI's docs state: "Network log assertions are currently only supported on desktop web authoring in KaneAI." Mobile runs are reliant on UI assertions.

5. Keep the Sandbox token out of the test. Parameters are visible to all in your organization. If a step is calling the Square API (the KaneAI / → API step will accept a pasted curl command), then store the token as a Secret and select it from the / menu.

The API testing doc's best practice table recommends using {{secret.api_token}} and never hard coding tokens, and its curl examples show the token being sent as Authorization: Bearer {{secret.api_token}}.

What KaneAI's Docs Do and Don't Cover for Square

Be clear on three limits before you rely on this test:

  • Square's card form is completely uncharted territory in TestMu AI's documentation. The Web Payments SDK is loaded from sandbox.web.squarecdn.com and a Square forum thread shows the card form frame being served as main-iframe.html from that host. So the card inputs are in a frame from Square's domain, not yours. TestMu AI's forms doc states "KaneAI handles iFrames automatically in most cases" and provides a JS snippet as a fallback for rich text editors within an iframe (Forms, Inputs & Data Entry). There is absolutely nothing in TestMu AI's forms documentation about KaneAI in a cross-origin payment iframe such as Square's. Run one authoring session on your own checkout and verify that KaneAI gets to the card number field prior to you going ahead and building the dataset.
  • New tabs require an explicit switch; separate windows are not supported. If your store opens a Square payment link in a new tab, you'll need to add a 'switch to tab' step. TestMu AI's documentation also states "Window management is currently not supported on KaneAI" (Finding & Interacting with Elements). A checkout which opens a separate popup window is out of scope.
  • The SCA modal is unconfirmed. There's no TestMu AI doc that covers Square's 3D Secure verification modal. Treat the SCA row in the same way as the card form, i.e., confirm it in an authoring session first.

KaneAI test runs are deterministic. The same steps and the same data will always run the same way. So a row that fails on a re-run is pointing at either your checkout or at a step that you need to change, not at some random variation.

Square Sandbox Testing Checklist

  • Sandbox Access token and location ID are stored as environment variables or secrets
  • Client loads sandbox.web.squarecdn.com/v1/square.js, server calls connect.squareupsandbox.com
  • All five matrix rows pass in the browser; no success page for rows 2-5
  • CreatePayment nonce script exits 0
  • Double-clicking Pay or resending the same attempt creates one payment (same idempotency key)
  • A retry after a decline uses a new idempotency key and ends with exactly one COMPLETED payment
  • Payments for row 1 visible in the Sandbox Square Dashboard of the right test account
  • No real personal data in Sandbox test accounts
  • Post-payment flow checked using the Testing Panel's Test Payment button; card handling is dealt with via the SDK path or API checks
  • Production app ID, seller location ID, production token and web.squarecdn.com script, all swapped together

Watch: Natural-Language Test Authoring

Youtube thumbnail

The video shows KaneAI generating a test from plain English steps (just like the Square checkout test above). For the same concept across a number of gateways, see our guide to testing payment gateways without code.

Conclusion

The Square Sandbox gives you free unlimited test payments, but only proves anything if each test can fail. Set up the credentials once, run the five-row matrix through your own checkout, back it with the CreatePayment nonce script and confirm that KaneAI gets to Square's card form in a single authoring session before you go on to do it with the datasets.

Turn your Square checkout matrix into a repeatable test. Just write it out once in plain English and run every row through KaneAI.

Testing web or mobile apps without writing code? KaneAI by TestMu AI turns plain-English instructions into tests.

To run your first test, start free, or
for a full walkthrough of the product.

Was this helpful?

Authors

Harshit Paul

Harshit Paul

Author · 103 posts

Harshit Paul is Director of Product Marketing at TestMu AI, with over 8 years of experience in product and growth marketing for developer and QA tools, leading the Agentic AI in Quality Engineering space. He has authored 80+ technical articles for TestMu AI on software testing and automation, and hosted webinars on Selenium, automation testing, browser compatibility, DevOps, and continuous testing. He has led go-to-market and technical marketing initiatives across software testing products, contributing to SEO, content strategy, and developer marketing. He began his career as a certified Salesforce developer at Wipro Technologies, where he worked for 2 years before moving into marketing. Harshit holds a degree in computer programming from Vivekananda Institute of Professional Studies.

Srinivasan Sekar

Srinivasan Sekar

Reviewer

Srinivasan Sekar is Director of Engineering at TestMu AI, where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.

Square Sandbox FAQs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests