Pay
View .mdOpen in ClaudeOpen in ChatGPT

Pay

Store payment methods and pay bills. The Pay API mirrors the accept-payments flow: mint a pay token, store a payment method, initiate a payment, and retrieve the resulting payment attempt.

Related guides: Schedule Bill Payments · Pay Sessions

Sandbox simulation; production execution is gated

Environment behavior: POST /v1/pay/payments creates a deterministic synthetic attempt on the sandbox host, including simulated pay.* webhooks. The 201 response includes an attempt id, and the synthetic attempt can be retrieved immediately from the sandbox host. The production host returns 501 PAYMENT_EXECUTION_NOT_AVAILABLE until real money movement is enabled. The hosted Elements .pay() flow is a separate integration surface: it remains gated in both environments and produces no onSuccess value. Track production availability in the changelog.

POST/v1/pay-tokens

Server-to-server. Mint a short-lived pay_token (15-minute TTL) that authorizes the hosted Elements add-payment-method / pay flows. Requires client credentials; the client_id is taken from the credential — a mismatched body value is rejected with 403.

Request body

client_user_id*stringYour unique identifier for the end user
bill_idstringBill to pay (required for the pay flow; omit for add-payment-method only)
amountobject{ value: integer (minor units), currency: string } — the amount to authorize
payment_method_idstringPre-bind a saved payment method
metadata_jsonstringOpaque JSON string echoed back on the token

See the Pay Sessions reference for the full pay-token lifecycle (validate + scope).

Sample uses your_client_id · sign in to auto-fill your sandbox key
curl -X POST https://sandbox.api.billerapi.com/v1/pay-tokens \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $BILLERAPI_API_KEY" \
  -d '{
    "client_user_id": "user_12345",
    "bill_id": "bill_abc123",
    "amount": { "value": 1299, "currency": "USD" }
  }'
Response201 Created
{
  "success": true,
  "pay_token": "payt_5f3c…",
  "pay_token_id": "ptid_789xyz",
  "expires_at": "2026-06-29T12:15:00Z"
}
POST/v1/pay/payment-methods

Store a payment method. In production the PAN is tokenized by the hosted Elements page and never touches your servers; this endpoint accepts the card details from that BillerAPI-hosted surface and returns a reusable payment_method_id. Authenticate with a bearer token, a pay token, or client credentials.

Request body

pan*stringPrimary account number (digits, 13–19 chars)
expiry_month*integerExpiry month (1–12)
expiry_year*integerExpiry year (4-digit)
cvvstringCard verification value (3–4 digits)
bucketstringBucket label, e.g. "primary"

The returned payment_method_id is what you pass to POST /v1/pay/payments. Never send raw card data from your own frontend — use the hosted Elements page.

Sample uses your_client_id · sign in to auto-fill your sandbox key
curl -X POST https://sandbox.api.billerapi.com/v1/pay/payment-methods \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sb_access_tok_c7d4e91a2b6f8035" \
  -d '{
    "pan": "4242424242424242",
    "expiry_month": 12,
    "expiry_year": 2030,
    "cvv": "123",
    "bucket": "primary"
  }'
Response201 Created
{
  "payment_method_id": "pm_abc123",
  "bucket": "primary"
}
POST/v1/pay/payments

Initiate a deterministic synthetic bill payment in sandbox. The attempt transitions from PENDING to a terminal outcome selected by the stored card's test last4. Production returns 501 PAYMENT_EXECUTION_NOT_AVAILABLE while real execution is gated. An idempotency_key is required (via the Idempotency-Key header or the body field).

Request body

bill_id*stringThe bill to pay
payment_method_id*stringA stored payment method id
idempotency_keystringRetry-safe key (or send the Idempotency-Key header)
amount_minor_unitsintegerAmount in minor units (cents). Defaults to the bill amount.
currencystring3-letter ISO currency code

Outcomes are confirmed by the pay.succeeded / pay.failed webhooks. The 201 response confirms that the synthetic attempt was created, not that it settled. The returned attempt is immediately available from GET /v1/pay/payments/:attemptId. See Webhooks.

Sample uses your_client_id · sign in to auto-fill your sandbox key
curl -X POST https://sandbox.api.billerapi.com/v1/pay/payments \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sb_access_tok_c7d4e91a2b6f8035" \
  -H "Idempotency-Key: idem_2026-06-25_bill_abc123" \
  -d '{
    "bill_id": "bill_abc123",
    "payment_method_id": "pm_abc123",
    "amount_minor_units": 1299,
    "currency": "USD"
  }'
Response201 Created (sandbox)
{
  "attempt_id": "patt_01HX5...",
  "status": "PENDING",
  "workflow_id": "sandbox-patt_01HX5...",
  "replayed": false,
  "hint": "Sandbox outcomes are keyed on the card LAST4...",
  "livemode": false,
  "mode": "sandbox"
}
GET/v1/pay/payments/:attemptId

Retrieve a payment attempt by id. A synthetic attempt created by the sandbox POST is available from this sandbox endpoint immediately. Production initiation remains gated and creates no production attempt to retrieve until launch.

Path parameters

attemptId*stringThe payment attempt id
Sample uses your_client_id · sign in to auto-fill your sandbox key
curl https://sandbox.api.billerapi.com/v1/pay/payments/patt_01HX5 \
  -H "Authorization: Bearer sb_access_tok_c7d4e91a2b6f8035"
Response200 OK
{
  "attempt_id": "sb_payatt_01HX5...",
  "bill_id": "bill_abc123",
  "payment_method_id": "sb_pm_01HX4...",
  "status": "PAID",
  "amount_minor_units": 1299,
  "currency": "USD",
  "confirmation_number": "CONF-998877",
  "created_at": "2026-06-29T12:00:00.000Z",
  "updated_at": "2026-06-29T12:00:04.000Z",
  "livemode": false,
  "mode": "sandbox"
}

The Payment Attempt object

A Payment Attempt records a single attempt to pay a bill. It progresses from PENDING through RUNNING to a terminal state, mirrored by the pay.* webhooks.

Attributes

attempt_id*stringUnique identifier for the payment attempt
bill_id*stringThe bill this attempt is paying
payment_method_id*stringStored payment method used for this attempt
status*stringPENDING | RUNNING | PAID | FAILED | NEEDS_HUMAN_REVIEW
amount_minor_unitsintegerAmount in minor currency units, when available
currencystringISO 4217 currency code, e.g. "USD"
confirmation_numberstringBiller-side confirmation / reference number, when the payment succeeds
error_codestringFailure code for a failed attempt
needs_human_review_reasonstringEscalation reason when status is NEEDS_HUMAN_REVIEW
created_at*stringISO 8601 creation timestamp
updated_at*stringISO 8601 update timestamp
The Payment Attempt object
{
  "attempt_id": "sb_payatt_01HX5...",
  "bill_id": "bill_abc123",
  "payment_method_id": "sb_pm_01HX4...",
  "status": "PAID",
  "amount_minor_units": 1299,
  "currency": "USD",
  "confirmation_number": "CONF-998877",
  "created_at": "2026-06-29T12:00:00.000Z",
  "updated_at": "2026-06-29T12:00:04.000Z"
}
Was this page helpful?