Skip to main content

Error Response Format

All API errors return a JSON body with a success: false flag and an error object:

Error Codes


Common Mistakes

Wrong usdcDomainName

Symptom: INVALID_SIGNATURE on every attempt. Cause: Hardcoding "USD Coin" as the EIP-712 domain name. Fix: Always read usdcDomainName from payment_requirements[n]. All testnet chains return "USDC".

Reusing a Nonce

Symptom: INVALID_SIGNATURE on the second attempt with an otherwise valid signature. Cause: The USDC contract records every used nonce permanently. Any reuse — intentional or from copying a previous payload — always fails. Fix: Generate a fresh random bytes32 for every payment.

Wrong chainId in EIP-712 Domain

Symptom: INVALID_SIGNATURE even though the domain name and contract address look correct. Cause: The chainId in the EIP-712 domain does not match the chain in payment_requirements[n].network. Fix: Parse the chain ID directly from the network field at runtime.

Signing value as a Float

Symptom: AMOUNT_MISMATCH or VALIDATION_ERROR. Cause: Passing 29.99 instead of "29990000" as the transfer value. EIP-3009 value is a uint256 — it must be an integer in atomic USDC units. Fix: Convert to atomic units before signing.

Not Polling After Hosted Checkout Redirect

Symptom: Orders fulfilled for payments that never actually settled. Cause: Relying solely on the redirect_url query parameter as proof of payment. Redirects can be interrupted by browser closes or network errors. Fix: Always confirm status: "paid" via GET /api/v1/x402/intents/{id} before fulfilling an order.

Mixing Test and Production Keys

Symptom: INVALID_API_KEY even though the key looks correct. Cause: sk_test_ keys only authenticate against testnetv1.ababilpay.xyz. sk_live_ keys only authenticate against ababilpay.com. Fix: Use the correct key for the environment you are targeting.

Retrying Failed Requests

  • INVALID_SIGNATURE — do not retry with the same signature. Generate a fresh nonce and re-sign.
  • INTENT_EXPIRED — create a new intent; expired intents cannot be reactivated.
  • ALREADY_PAID — do not retry. Check intent status and fulfil the order.
  • SETTLEMENT_FAILED — check buyer USDC balance and relay wallet gas. Retry with a new intent after resolving the underlying issue.
  • RATE_LIMITED — wait until the X-RateLimit-Reset timestamp before retrying.
  • 5xx errors — safe to retry with exponential backoff. Check intent status first to avoid double-charging.