Skip to content

Error handling

Pass onError and show the message. Most failures are recoverable by the customer, and silence just makes them try again blindly.

onError={(error) => {
console.error('[stablezact]', error);
showBanner(String(error));
}}

“A checkout reference is required.” The SDK was opened without a reference, or with one that is not a ckr_ reference. Create a checkout on your server first and pass what it returns. See The checkout reference.

“Checkout expired” or “Checkout is no longer available”. The reference was older than its expiry (15 minutes by default) or has already been used. Create a new checkout and pass the new reference.

“Invalid API credentials” when creating the checkout. The checkout is created with your secret key from your server. A public key is rejected.

Wrong network. The wallet is on a different chain from the payment. The SDK prompts to switch; some wallets refuse programmatic switching and the customer must change it themselves.

Not enough gas. The customer holds the stablecoin but no native currency to pay for the transfer. Caught before submission by the balance check.

Rejected in the wallet. The customer declined the signature. Not an error to apologise for. Let them try again.

Payment expired. Payments do not stay open indefinitely. Create a new one.

Chain not configured. Creating a payment on a chain with no settlement wallet is rejected, naming the chain. Fix this in your merchant settings, not in code.

Do not create a second checkout for the same order just because the first call timed out without checking it. Send the same orderId so you can tell one purchase from two, and use the Idempotency-Key header on direct payment creation. See Retrying safely.

Do not treat a 500 from a payment read as an outage before checking the ID. An unknown payment ID currently returns 500 rather than 404. See Errors.