Skip to content
Terra WalletDevelopers

Early access. The Terra API and SDKs may change before launch, and the SDK packages are not published yet.

View as Markdown

Terra Pay

Early access

Payment intents

A payment intent is one payment for one amount. Your server creates it, your customer pays it on hosted checkout, and Terra marks it succeeded only when the chain proves the payment.

Create one#

POST /v1/payment_intents with your secret key and an Idempotency-Key:

FieldTypeRequiredNotes
amountdecimal stringyesFor example "10.50". Never a float
currencystringyesA fiat ISO code: USD, EUR, INR and so on
accepted_assetsarray of assetsyesWhat the customer may pay with (see below)
descriptionstringnoPlain text shown to the customer
metadataobjectnoUp to 20 keys; string values up to 500 characters. Never shown on checkout
expires_in_sintegerno300 to 86400 seconds. Default 900 (15 minutes)
success_urlURLnoWhere checkout sends the customer after paying
cancel_urlURLnoWhere checkout sends the customer if they leave
customer_emailstringnoThe customer's email

Unknown fields are rejected, so a typo fails loudly instead of being ignored.

Assets#

An asset names a token by chain and contract:

JSON

{ "chain": "tron", "symbol": "USDT", "contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "decimals": 6 }
  • chain is a chain id such as tron, bsc, ethereum, polygon, base, arbitrum or solana.
  • contract is the token contract or mint, or null for the chain's native coin.
  • Terra matches tokens by contract, never by symbol. A token called "USDT" at another address is not USDT.
  • Copy contracts from Supported networks and assets or the MCP tool list_supported_networks. Never type them by hand.

Example#

JavaScript

// Preview: create a payment intent (Node 18 or later).const res = await fetch("https://terrawallet.us/api/v1/payment_intents", {  method: "POST",  headers: {    Authorization: `Bearer ${process.env.TERRA_SECRET_KEY}`,    "Content-Type": "application/json",    "Idempotency-Key": `order-${order.id}-checkout`,  },  body: JSON.stringify({    amount: order.total,            // "120.00"    currency: "USD",    accepted_assets: [      { chain: "tron", symbol: "USDT", contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", decimals: 6 },      { chain: "solana", symbol: "USDC", contract: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", decimals: 6 },    ],    description: `Order ${order.id}`,    metadata: { order_id: String(order.id) },    success_url: `https://shop.example.com/orders/${order.id}/thanks`,    cancel_url: "https://shop.example.com/cart",  }),});const intent = await res.json();// Redirect the customer to intent.checkout_url

The response#

JSON

{  "id": "pi_...",  "status": "requires_payment",  "checkout_url": "https://pay.terrawallet.us/c/pi_...",  "amount": "120.00",  "currency": "USD",  "quotes": [    {      "asset": { "chain": "tron", "symbol": "USDT", "contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "decimals": 6 },      "amount_base_units": "...",      "pay_address": "...",      "expires_at": "..."    }  ]}
  • quotes holds one exact amount per accepted asset. amount_base_units is an integer string in the token's smallest unit; divide by 10^decimals to display it. Never use floats for money.
  • pay_address is where that asset is paid: your payout wallet on that chain.
  • Each quote is valid until expires_at.

Statuses#

StatusMeaning
requires_paymentWaiting for the customer to pay
processingA matching payment was seen and is waiting for the chain's confirmation policy
succeededPaid in full and verified on chain
expiredThe window ended without a full payment
canceledThe intent was canceled
underpaidThe customer paid less than the quote
overpaidThe customer paid more than the quote

How verification works#

  • An exact, unique amount per intent. That is what ties a payment to one intent, so nobody watching your wallet can claim another customer's payment.
  • A confirmation policy per chain. For example, EVM payments wait for a number of blocks, Tron payments wait until solidified and Solana payments until confirmed.
  • One transaction per intent. A transaction can never pay two intents.
  • Chain truth only. A transaction hash sent by a client is a hint to look, never proof. A network error leaves a payment pending: it never accepts or rejects it.

Edge cases#

  • Underpaid: the intent becomes underpaid and you get payment_intent.underpaid. Checkout can offer the customer a top-up for the remainder.
  • Overpaid: the intent becomes overpaid and is flagged for a refund. See Refunds.
  • Paid after expiry: re-quoted, or accepted under your rule.

Webhooks for payment intents#

payment_intent.succeeded, payment_intent.expired and payment_intent.underpaid. See Webhooks.