Checkout
This guide connects an existing application to hosted crypto checkout on Mainnet or Testnet3, using a TypeScript backend and browser frontend. You will create a session for an application order, send the buyer to checkout, and read the payment result on your backend.
The snippets are integration functions, not a complete web application. Your application supplies login, order storage, and HTTP routes. For a fixed-price QuickPay product, you can open the product page without writing session-creation code. The page can offer Crypto, Card, or both, depending on the methods enabled for your merchant account and selected for that product. See Product checkout.
1. Prepare the merchant
Choose an environment. The SDKs and integration steps below are the same for both:
| Environment | Use | Merchant Portal |
|---|---|---|
| Mainnet | Real payments | Mainnet Merchant Portal |
| Testnet3 | Integration testing | Testnet3 Merchant Portal |
Merchant approval, receiving configuration, PayKit activation, API credentials, and fee balance are specific to each environment. Complete these steps in the portal for your selected environment:
- Register and obtain approval for an enabled DIRECT merchant.
- Configure a receiving address for an available crypto chain/token. In updated portals, activate PayKit under Payment Setup → PayKit Settings (the underlying capability is still named QuickPay in the API). Check the fees and merchant fee-balance requirements.
- Create API credentials under Developer → API & Checkout Settings and save the secret on your backend. Older portal labels are shown in the Merchant Guide.
Fund the buyer's wallet with a token enabled for your merchant and native gas on the same chain. On GOAT, gas is paid in BTC. For Testnet3, get test BTC from the faucet. Find the RPC and explorer for each environment in Networks and RPC. Mainnet payments use real funds. Portal instructions are in the Merchant Guide.
2. Install and configure
Use Node.js 18 or later on the backend. Install in the corresponding applications:
Set backend environment variables using one of the following configurations. Supply the credentials and merchant ID from that environment.
Mainnet
Testnet3
Your backend checks the session URL against GOATX402_CHECKOUT_ORIGIN before
sending the checkout ID and origin to the browser. Step 5 uses the same origin
to read the session status.
Keep the API secret out of frontend environment variables and browser bundles. Use credentials, products, and checkout origins from the same environment; see the environment table.
3. Create and save a session on the backend
Connect this function to your own authenticated route, for example
POST /api/orders/:id/checkout. That route must:
- Load the application order and check that the signed-in buyer owns it.
- Read its price from your database and allocate one stable payment-intent ID. Serialize creation for that intent so double-clicks cannot create two payments.
- Call
createPaymentSessiononce for a new intent. Supply asaveSessioncallback that savescheckoutId,url,expiresAt, environment, and expected price against the order. If saving or URL validation fails, withhold the link and reconcile the attempt before creating a replacement. - On repeat requests, call
checkoutForBrowseron the saved session only if it is still payable. Otherwise return{ action: 'status', message: '…' }with the current buyer-facing order status, such as “Confirming payment” or “Paid”. Reconcile expired or unresolved attempts before replacing them.
A duplicate clientReferenceId returns a conflict, not the previous session.
If creation times out or the response is lost, mark the attempt unresolved and
reconcile it; do not generate a new ID and immediately request payment again.
The SDK has no lookup by client reference or session-renewal helper. See
published SDK limits.
This example omits return URLs. To add successUrl or cancelUrl, first
configure Checkout return URLs.
4. Open checkout in the browser
Call startPayment from your Pay button with the order ID and the element
where buyers see their order status. Use your framework's authentication
and CSRF protection on the application route from step 3.
Open hosted checkout in a top-level tab or window. Iframe embedding is unsupported.
A full-page redirect
works after the asynchronous session request. If using a popup instead,
open() must run synchronously inside a user gesture; see the
browser SDK.
5. Read the payment result on the backend
Load the checkout ID and environment saved in step 3. Use the matching backend
configuration for that environment and the saved ID, not an ID supplied by the
browser. The session's status endpoint supplies the linked order_id after
crypto binding. Then read that order through the authenticated server SDK:
The raw status call is an HTTP endpoint, not an SDK method. Its response and deployment boundary are documented in Checkout status. Treat the opaque checkout ID as a bearer capability and keep it out of logs.
Run confirmation in a backend job and save the result for the buyer's order-status page.
When the Crypto session has no order_id, readCryptoPayment returns its
session state in checkoutStatus.
- For
OPEN, show “Awaiting payment” and check again later. - For
EXPIREDorCANCELLED, show “Checkout expired” or “Checkout cancelled” and stop polling this session. Reconcile any reported transfer before offering another payment.
If the status request fails, keep the last known state or show “Checking payment status” on the first read. Retry transient errors and investigate persistent errors before requesting another payment.
Confirm the Crypto payment. When the authenticated order reaches INVOICED,
verify its proof against the saved purchase. See payment order statuses.
For Card, follow the Card payment checks.
The example retries a proof 404 only for the verified order. If it returns
needsReconciliation, record that state on the purchase and
check the saved order ID and environment. Show “Confirming payment” on
refresh without restarting the retry window.
Once the proof is available, match its order and transaction to the saved
purchase. Verify the merchant, chain, and token contract. Use your trusted
receiving address and token decimals for that chain and token to compare
proof.payload.to_addr and proof.payload.amount_wei with the expected
recipient and price in base units.
The proof's signature is a digest, not a signed attestation; see
Read proof.
After those checks pass, record the completed payment once. A browser callback or return URL only updates the UI. If using webhooks, implement the deployment-confirmed verification contract.
6. Verify the complete path
- Complete a payment in your selected environment and find the same order in that environment's Merchant Portal. Mainnet payments use real funds.
- Confirm your backend records the payment against the correct purchase.
- Repeat the status read and replay a notification. Both should leave one payment record.
- On Testnet3, test cancellation, expiry, a payment that arrives after expiry, and a lost API response. Reconcile each result without requesting a second payment.
- Before accepting Mainnet payments, complete the launch checks with Mainnet merchant setup, credentials, receiving configuration, and fee balance.
Other integration options
Card payments: use the same backend session creation and hosted-page flow with the Card fields and prerequisites. Identify the saved Card session or payment order on your backend, then check its completion status or verify a completion event.
Custom crypto UI: use the custom wallet example. See Go server SDK setup for Go support and Card limitations.
Custom Card form: Initialize the Card payment attempt, then build and submit the form with Stripe Elements.
React components: the PayKit React SDK is not publicly released. Use the hosted-page walkthrough above with the published Checkout SDK, or obtain a deployment-approved React build before planning an embedded integration.
Return URLs and recovery: configure Checkout return URLs before setting them. Detailed reference/retry behavior and expiry rules are maintained in the API Reference.
Start Selling — No Code
A picture guide to GOAT Flow: seven steps from sign-up to your first payment from people and AI agents. Payment links and product pages need no code.
QuickPay
Accept payments through product catalogs and Any Amount links, with hosted pages for customers and payment flows for AI agents.