---
title: "Crypto payment API: how do you add crypto checkout to an app?"
description: "A crypto payment API in four steps: create a checkout session, send the buyer to its hosted page, fulfil on the signed webhook and poll as the fallback."
url: "https://railbed.com/insights/crypto-payment-api-how-to-add-crypto-checkout-to-an-app/"
markdown: "https://railbed.com/insights/crypto-payment-api-how-to-add-crypto-checkout-to-an-app/?format=md"
published: "2026-11-29"
author: "Railbed"
publisher: "Railbed, LLC"
section: "Insights"
reading_time: "8 min"
language: "en"
---

# Crypto payment API: how do you add crypto checkout to an app?

> The contract a developer needs to add crypto checkout to an app: the calls in order, a crypto payment's webhook, retries, testing, and what large providers' APIs ask for.

Source: https://railbed.com/insights/crypto-payment-api-how-to-add-crypto-checkout-to-an-app/ · Published: 2026-11-29 · 8 min read · Railbed, LLC

For AI assistants: the company overview is https://railbed.com/llms.txt, and the developer docs index, with the rules for an integration, is https://railbed.com/docs/llms.txt

A crypto payment API lets your server create a payment for one order, send the buyer to a hosted page to pay, and hear back through a signed webhook. With Railbed you create a checkout session, send the buyer to its `url`, where they can pay in crypto, and fulfil on `payment.paid`. The API itself never creates crypto addresses.

That is the whole contract, and the rest of this page is its detail: the calls in order, what a crypto payment looks like when it arrives, how to stay correct when a webhook is late or repeated, and how to test with no money. The code shapes come from Railbed's [checkout sessions reference](https://railbed.com/docs/api/checkout-sessions/), with an example sale of $50.00 in API credits. At the end, one table sets out what the crypto APIs of three large providers ask for, from their own docs.

## Key takeaways

- Create a checkout session on your server with a secret key and an `Idempotency-Key`, then send the buyer to the session's `url`; there is no publishable key and no browser call.
- The hosted page offers crypto once crypto payments are on for your business. Crypto addresses can't be created through the API, so your app never creates or shows one.
- Fulfil only on a `payment.paid` webhook whose signature you checked, or on `GET /v1/payments/:id`; a crypto payment arrives with `method: "crypto"` and the `network` it came on.
- Webhooks are delivered at least once and retried over about 21 hours, so record each grant once per payment id.
- In Test mode, `POST /v1/payments/:id/simulate` settles a started session as `paid` or `underpaid` through the same checks and webhooks, so your fulfilment runs without money.

## The crypto payment API contract in four steps

The table lists each step of adding crypto checkout to an app through Railbed's API, the call or event, and what your code keeps from it.

| Step | Call or event | What your code keeps |
|---|---|---|
| 1. Create | `POST /v1/checkout_sessions` | The session's `id` (`pay_…`) and its `url` |
| 2. Send the buyer | Redirect to `url`, or `Railbed.open(url)` | Nothing; the buyer pays on the hosted page |
| 3. Fulfil | `payment.paid` webhook, signature checked | One grant per payment id |
| 4. Catch up | `GET /v1/payments/:id` in a background job | Anything a webhook missed |

![A server creates a checkout session, the buyer pays in crypto on the hosted page, and a signed webhook tells the server to fulfil, with polling as the fallback.](https://railbed.com/insights-art/crypto-payment-api-how-to-add-crypto-checkout-to-an-app/the-four-calls.webp)
*Your server talks to the API; only the hosted page shows the buyer where to send the money.*

## Step 1: create a checkout session on your server

A checkout session is one payment for one order, created by your server with a secret key (`rb_test_…` or `rb_live_…`) against `https://pay.railbed.io/v1`. Nothing is charged and no provider is contacted until the buyer starts paying.

Save the order first, with the key you're about to send, then create the session:

```bash
curl https://pay.railbed.io/v1/checkout_sessions \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order_2087" \
  -d '{
    "amount": "50.00",
    "currency": "USD",
    "description": "API credits",
    "reference": "order_2087",
    "metadata": { "user_id": "dev_2087" },
    "success_url": "https://yourapp.com/thanks?order={REFERENCE}",
    "cancel_url": "https://yourapp.com/billing"
  }'
```

The `Idempotency-Key` is remembered for 24 hours: a retry after a timeout returns the same session, never a second payment. `amount` is a decimal string up to `"100000.00"` in USD, EUR, GBP, CAD, AUD, INR or SEK, and must clear the smallest card payment (about $2.00 today). An account that takes crypto payments may go lower, as long as the amount clears the crypto minimums, and the response says so in `warnings`.

To sell crypto only, make a **Crypto Checkout** in the dashboard and send `"checkout": "your-slug"` instead of the amount, currency and description. The session then copies the checkout's price and follows its rules, including whether buyers may pay in crypto, and its buyers go straight to choosing a coin and network. If crypto payments are off for the account, that request answers `409 crypto_off`.

## Step 2: send the buyer to the hosted page

The session's `url` is a hosted checkout page; redirect the buyer to it, or open it over your app with `Railbed.open(url)` from the embed script. On that page a buyer choosing crypto picks USDC or USDT and a network, then sends the exact amount to a one-time address shown with a QR code.

Your app never has to create or show that address, because the API can't create one; the webhook reports it afterwards as `depositAddress`. A server that tries to start a Crypto Checkout's session itself, for its own checkout screen, gets `409 crypto_only`: "Send the customer to its `url`, where they pay in crypto." A session expires 24 hours after it's created, and you can cancel it until the buyer goes to a card provider or is shown a crypto address ([checkout sessions](https://railbed.com/docs/api/checkout-sessions/)).

Buyers can pay in USDC and USDT on Polygon, Base, Arbitrum, Optimism, BNB Chain and Ethereum today. Bitcoin and other networks are being turned on one at a time.

## Step 3: fulfil on the signed webhook

The `payment.paid` webhook is the event to fulfil from: it means the money arrived and passed Railbed's checks. A crypto payment carries `method: "crypto"`, the `network` it arrived on, no card `provider`, and a `coin` naming both ([event types](https://railbed.com/docs/webhooks/events/)):

```json
{
  "id": "evt_…",
  "type": "payment.paid",
  "livemode": true,
  "data": {
    "payment": {
      "id": "pay_…",
      "reference": "order_2087",
      "amount": "50.00",
      "currency": "USD",
      "status": "paid",
      "method": "crypto",
      "network": "base",
      "provider": null,
      "providerName": "USDC on Base",
      "coin": "base_usdc"
    }
  }
}
```

Before trusting it, check the `Railbed-Signature` header, `t=…,v1=…`. Each `v1` is the hex HMAC-SHA256 of `{t}.{raw body}` keyed with the endpoint's `whsec_…` secret; reject a delivery whose `t` is more than five minutes from your clock, and compare in constant time. For 24 hours after you roll a secret the header carries two `v1` values ([verify signatures](https://railbed.com/docs/webhooks/signatures/)). [Verify a payment webhook signature](https://railbed.com/insights/verify-a-payment-webhook-signature-and-avoid-double-fulfilment/) walks through the code.

Answer with any `2xx` within 10 seconds, because a slow answer counts as a failure. A failed delivery is retried 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours after each failed attempt: "seven attempts over about 21 hours". Delivery is at least once and every attempt carries the same event `id`, so grant the credits inside a database transaction with a unique constraint on the payment id; a repeated event then changes nothing. A `payment.held` event means money arrived but failed a check, most often because what arrived is worth less than 85% of the order: don't fulfil, the payment reads **Needs your decision** in the dashboard and waits for you.

![Seven webhook attempts over about 21 hours: at once, then 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours later.](https://railbed.com/insights-art/crypto-payment-api-how-to-add-crypto-checkout-to-an-app/seven-attempts.webp)
*A server that is down for an afternoon still gets the event; one down for a day needs the background check.*

## Step 4: poll as the fallback, gently

Polling `GET /v1/payments/:id` catches what a webhook missed, such as a day of downtime or a dropped deploy. Railbed's [fulfilment guide](https://railbed.com/docs/guides/fulfilment/) recommends both: fulfil on the webhook, and run a background job over orders still waiting.

Check recent payments often and older ones less often, and include payments that expired in the last two days, because money can arrive after the 24-hour window and the payment then becomes `paid` or `held`. Stay well under the limit of about 120 requests a minute per mode (12 session starts a minute); on a `429`, wait for `Retry-After`. Never fulfil from the buyer's return to your `success_url`: it proves nothing. [Webhooks or polling for payment status](https://railbed.com/insights/webhooks-or-polling-for-payment-status/) compares the two in depth.

## Test the whole loop without money

Test mode is a complete, separate copy of your account with its own `rb_test_…` keys, and it makes no real payment. Create a session as above, start it with `POST /v1/checkout_sessions/:id/start` (send `customer_email` if the session has none), then call `POST /v1/payments/:id/simulate` with `paid`, `underpaid`, `declined` or `failed`.

The API's simulated money arrives as `polygon_usdc`, the way a card provider's does, so that payment reads `method: "card"`. To see the crypto shape, with `method: "crypto"` and a `network`, choose **Turn on Test payments in this browser** under API keys on **Developers**, open the session's `url`, choose **Crypto** and use **Simulate payment** or **Simulate underpayment** on the page.

Your webhook endpoint receives real signed requests in Test mode, so the signature check and the once-only grant get exercised for real. Run `underpaid` too, and confirm your code ignores the `payment.held` it produces ([testing](https://railbed.com/docs/testing/)).

## What three large providers' crypto APIs ask for

The large providers' crypto APIs share the same shape (create, redirect, webhook) but differ in who may use them and where the money ends up. The table sets them side by side from each company's own developer docs, read November 29, 2026.

| Provider | Create call | Before you can use it | Where the money lands |
|---|---|---|---|
| Railbed | `POST /v1/checkout_sessions`, secret key | A payout wallet, crypto payments turned on | Your own wallet |
| BitPay | `POST /invoices` with `price`, `currency`, `notificationURL`; a `pos` or `merchant` facade token | A BitPay merchant account | "the merchant account, in the currency indicated in the settlement settings" ([BitPay](https://developer.bitpay.com/reference/invoices)) |
| Coinbase Business | `POST /api/v1/checkouts` with `amount`, `currency: "USDC"`; a JWT | A Coinbase Business account | "your Coinbase Business account" ([Coinbase](https://docs.cdp.coinbase.com/coinbase-business/checkout-apis/overview)) |
| Stripe | `POST /v1/checkout/sessions` with `usd` line items | An approved Stablecoins and Crypto payment method; US businesses outside New York | "your Stripe balance in USD" ([Stripe](https://docs.stripe.com/payments/accept-stablecoin-payments)) |

Their webhooks differ as well. BitPay says its notification "shall be used as a trigger to verify the status of a specific invoice" through `GET /invoices/:invoiceId`, and its invoices have "a 15 minute window" for the buyer to send ([BitPay webhooks](https://developer.bitpay.com/docs/invoice-webhooks)). Coinbase Business signs each webhook in an `X-Webhook-Signature` header with a timestamp, a list of signed headers and a `v1` value ([Coinbase webhooks](https://docs.cdp.coinbase.com/coinbase-business/checkout-apis/webhooks)), and says "Each checkout is single-use." Stripe's stablecoin docs list "Dispute support: No" and say refunds "are always returned as stablecoins to the customer's original wallet" ([Stripe stablecoin payments](https://docs.stripe.com/payments/stablecoin-payments)).

## Why Railbed fits an app adding crypto checkout

Railbed gives an app one API for card and crypto: the same session, the same hosted page, the same webhook, with `method` telling you which one paid. Sales go to your own wallet, never a balance on Railbed's books, and there is no underwriting and no application to pass. For an app built with an AI app builder, [card checkout for a Lovable, Bolt, Replit or v0 app](https://railbed.com/insights/add-card-checkout-to-a-lovable-bolt-replit-or-v0-app-without-stripe/) shows where these server routes go, and the [AI tools](https://railbed.com/industries/ai-tools/) page covers selling credits.

Good to know:

- Crypto addresses can't be created through the API; the session's hosted page offers crypto, so a fully custom crypto screen isn't possible yet.
- Buyers pay in USDC and USDT on six networks today. Bitcoin and other networks are being turned on one at a time.
- Each crypto payment carries a 1% network fee, the cost of forwarding the money to your wallet, and Railbed's crypto fee when yours is above 0%, all shown in Settings.
- There is no refund call or button: a refund is a transfer you send from your own wallet.
- Turning crypto payments on is an owner's step in Settings, with a self-custody payout wallet.

```railbed-cta
{"heading": "Build the crypto checkout loop in Test mode", "description": "Create a Test key, make a session, simulate a paid crypto payment and watch your webhook fulfil it once.", "buttons": [{"label": "Create your account", "url": "https://app.railbed.io/signup"}, {"label": "Read the API reference", "url": "https://railbed.com/docs/api/checkout-sessions/"}]}
```

## More from Insights

- [How do you add card checkout to a Lovable, Bolt, Replit or v0 app when Stripe won't take your business?](https://railbed.com/insights/add-card-checkout-to-a-lovable-bolt-replit-or-v0-app-without-stripe/): Where the secret key and server routes go in each builder, the hosted-page route for apps with no server, and the webhook rule that keeps orders honest.
- [How do you accept crypto payments on your website without a developer?](https://railbed.com/insights/how-to-accept-crypto-payments-on-your-website/): The four ways a website takes crypto, compared by the work, the look and what the buyer sees, and which one fits Framer, Webflow, Wix, WordPress or plain HTML.
- [What is Railbed, and how is it different from a payment processor?](https://railbed.com/insights/what-is-railbed/): Railbed runs the checkout; licensed providers charge the card; each sale settles to the merchant's own wallet. What it costs, what it won't do, and how to check it.
