blockpay
02 · REST API 10 MIN SETUP

Hosted Checkout REST API Reference

Create onchain payment intents from any backend, redirect shoppers to blockpaynow.com/checkout/:id, and verify settlement state programmatically.

Base URLhttps://blockpaynow.com
AuthAuthorization: Bearer bp_live_…
Min / Max order$0.01 (1 cent) – $100,000.00
Quote window5 minutes locked via Chainlink

Authentication & API key scope

All server-side payment creation requests authenticate with a workspace Secret API key passed in the HTTP Authorization header. Generate or rotate your key anytime inside Dashboard → Developers → API keys.

API keys are strictly least-privilege: they are scoped exclusively to POST /api/payments and cannot modify payout wallets, business approval settings, or webhook endpoints. Never expose your bp_live_ key in frontend browser bundles or mobile apps.

HTTPREQUIRED REQUEST HEADERS
Authorization: Bearer bp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
Idempotency-Key: order_1043_attempt_1

Create a payment intent (POST /api/payments)

Call POST https://blockpaynow.com/api/payments from your backend when a shopper clicks Pay with crypto. Blockpay returns a payment object and a hosted checkoutUrl on https://blockpaynow.com/checkout/pay_… where the shopper selects USDC, USDT, or ETH and executes the transfer.

FieldTypeRequiredDescription
amountCentsintegerYesUSD order total in cents. Safe integer between 1 ($0.01) and 10000000 ($100,000).
descriptionstringYesOrder summary shown on the hosted checkout screen (max 120 bytes).
orderNumberstringOptionalYour store order reference (max 64 bytes). Defaults to BP-XXXXXXXXXXXX.
returnUrlstring (HTTPS)OptionalURL on your approved merchant website origin where buyers return after settlement.
channelstringOptionalSales channel tag: api, woocommerce, shopify, magento, bigcommerce, pos, invoice.
customerstringOptionalOptional label stored in workspace ledger (max 120 chars; avoid PII if unnecessary).
modestringOptionalMust be "mainnet" when provided. All Blockpay settlements execute on Ethereum Mainnet.
BASHCURL · CREATE HOSTED CHECKOUT
curl -X POST https://blockpaynow.com/api/payments \
  -H "Authorization: Bearer $BLOCKPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order_1043_v1" \
  -d '{
    "amountCents": 15000,
    "description": "Studio order #1043",
    "orderNumber": "ORD-1043",
    "channel": "api",
    "returnUrl": "https://your-store.com/thank-you/ORD-1043",
    "mode": "mainnet"
  }'
JAVASCRIPTNODE.JS · SERVER-SIDE REDIRECT HANDLER
export async function createCryptoCheckout(order) {
  const res = await fetch('https://blockpaynow.com/api/payments', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.BLOCKPAY_API_KEY}`,
      'Content-Type': 'application/json',
      'Idempotency-Key': `order-${order.id}-v1`,
    },
    body: JSON.stringify({
      amountCents: order.totalCents,
      description: `Order #${order.number}`,
      orderNumber: order.number,
      channel: 'api',
      returnUrl: `https://your-store.com/orders/${order.number}/thanks`,
      mode: 'mainnet',
    }),
  });

  if (!res.ok) {
    const err = await res.json().catch(() => ({}));
    throw new Error(err.error || `Blockpay API error (${res.status})`);
  }

  const { payment, checkoutUrl } = await res.json();
  // Save payment.id alongside order.id before redirecting shopper
  return { paymentId: payment.id, checkoutUrl };
}
JSON201 CREATED · RESPONSE PAYLOAD
{
  "payment": {
    "id": "pay_449be60499b54b559e8d722911460dd2",
    "merchantId": "m_8c2a1f94...",
    "orderNumber": "ORD-1043",
    "amountCents": 15000,
    "feeCents": 104,
    "status": "pending",
    "chain": "ethereum",
    "token": "USDC",
    "tokenUnits": "0",
    "decimals": 6,
    "description": "Studio order #1043",
    "source": "api",
    "createdAt": 1764258120412
  },
  "checkoutUrl": "https://blockpaynow.com/checkout/pay_449be60499b54b559e8d722911460dd2"
}

Idempotency & retry safety

Pass an Idempotency-Key header (8–128 characters) on every POST /api/payments request. If a network timeout causes your backend to retry with the same key and identical order parameters, Blockpay returns the original checkout without creating a duplicate invoice. Reusing an idempotency key with different order parameters returns HTTP 409 Conflict.

Never fulfill solely from returnUrl

A buyer can close their tab before returning, or manually visit your thank-you URL. Always fulfill orders when your server verifies a signed payment.settled webhook (or confirms status === "settled" via GET /api/checkouts/:id).

Checkout endpoints & status lifecycle

The hosted checkout UI handles asset selection, live pricing, wallet invocation, and transaction confirmation automatically. If you need to poll status or reconcile an order from your backend, query the public checkout status endpoint.

Method & PathAuthPurpose
POST /api/paymentsBearer API keyCreate a new hosted checkout intent and receive checkoutUrl
GET /api/checkouts/:idPublic (by pay_ ID)Fetch current checkout status, quote details, and finalized settlementHash
POST /api/checkouts/:id/pricePublic (hosted UI)Fetch live offchain Chainlink/Kraken price offer for ETH, USDC, or USDT
POST /api/checkouts/:id/invoicePublic (hosted UI)Lock a 5-minute quote and compute the deterministic EIP-1167 deposit vault
POST /api/checkouts/:id/transactionPublic (hosted UI)Submit buyer Ethereum tx hash for immediate onchain receipt verification
PYTHONPYTHON · VERIFY FINALIZED PAYMENT STATUS
import requests

def fetch_payment_status(payment_id: str) -> dict:
    resp = requests.get(
        f"https://blockpaynow.com/api/checkouts/{payment_id}",
        timeout=15,
    )
    resp.raise_for_status()
    payload = resp.json()["payment"]
    return {
        "status": payload["status"],               # pending | confirming | settled | expired | review
        "tx_hash": payload.get("settlementHash"),
        "token": payload.get("token"),
        "token_units": payload.get("tokenUnits"),
    }

HTTP status codes & rate limits

StatusMeaningCommon Cause
200 / 201SuccessCheckout fetched or created cleanly
400 Bad RequestValidation failedamountCents out of range, non-HTTPS returnUrl, or returnUrl origin differs from approved website
401 UnauthorizedMissing/invalid keySecret API key invalid or rotated
403 ForbiddenScope or approval errorBusiness awaiting approval or API key used on non-payment route
409 ConflictState conflictIdempotency-Key reused with mismatched payload or quote already locked
429 Too Many RequestsQuote rate limitPer-IP (6/hr) or per-business (30/hr) quote creation limit exceeded