BchainPayBchainPay

Payment intents

A payment intent represents a single crypto payment you want to collect. You specify the amount in USD, the network, and the token. BchainPay assigns a fresh blockchain address, converts the USD amount to crypto at current market rates, and monitors the chain until the payment settles or the intent expires.

Payment flow

  1. CreatePOST /v1/payment-intents with amount_cents, network, and token. The intent is created and immediately shows as requires_action in the API.
  2. Generate addressPOST /v1/payment-intents/:id/generate-address. BchainPay assigns a blockchain address and calculates the crypto amount from USD at current market rates.
  3. ConfirmPOST /v1/payment-intents/:id/confirm. Transitions the intent to processing.
  4. On-chain settlement — BchainPay detects the transaction on-chain and transitions the intent to completed. A payment_intent.completed webhook fires.

If expires_at passes without payment the intent moves to expired. Cancellation is not currently available via the API — uncollected intents expire automatically.

State machine

Valid transitions:

FromTo
createdrequires_action, cancelled, expired
requires_actionprocessing, cancelled, expired
processingcompleted, failed, expired
completed— (terminal)
failed— (terminal)
cancelled— (terminal)
expired— (terminal)

API statuses

The API exposes these statuses:

StatusDescription
requires_actionIntent created, waiting for address generation or confirmation.
processingPayment detected, awaiting on-chain settlement.
completedPayment settled. Terminal.
failedPayment failed (e.g. insufficient funds received before expiry). Terminal.
cancelledCancelled by the system. Terminal.
expiredExpired before full payment received. Terminal.

Crypto amount calculation

When you call generate-address, BchainPay converts your amount_cents (USD) into the equivalent crypto amount at current market rates. The converted amount is locked at that moment — subsequent price changes do not affect the expected payment.

The intent tracks two fields as payment arrives:

  • received_amount_cents — the USD-equivalent value of crypto received so far.
  • remaining_amount_cents — how much is still outstanding.

One intent per order

  • Every checkout, invoice, or recurring charge gets its own payment intent.
  • Every intent gets a unique blockchain address. Never reuse addresses across orders — this is how BchainPay attributes payments unambiguously.

Expiration

Every intent has an expires_at timestamp. If the full amount has not been received by that time, the intent transitions to expired. Expiration is enforced regardless of the current state (created, requires_action, or processing).

Last updated Edit on GitHub