BchainPayBchainPay

Generate address

POST/v1/payment-intents/:id/generate-address

Assigns a blockchain address for the customer to pay into and calculates the crypto amount at current market rates. The intent remains in requires_action status.

This endpoint is idempotent: if an address has already been generated for this intent, the existing address and crypto amount are returned without side effects.

Path parameters

FieldTypeRequiredDescription
idstringrequiredPayment intent ID (e.g. pi_3L9kX42).

Request body

No request body is required.

Example

curl -X POST https://api.bchainpay.com/v1/payment-intents/pi_3L9kX42/generate-address \
  -H "Authorization: Bearer $BCHAINPAY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Response — 200 OK

Returns the full PaymentIntentResponse with crypto fields populated. The blockchain address is available in metadata.blockchain_address.

{
  "id": "pi_3L9kX42",
  "merchant_id": "merch_abc123",
  "amount_cents": 4999,
  "received_amount_cents": 0,
  "remaining_amount_cents": 4999,
  "currency": "USD",
  "network": "ethereum",
  "token": "USDC",
  "crypto_amount": "4990000",
  "crypto_amount_decimal": "4.99",
  "token_price_cents": 100,
  "status": "requires_action",
  "reference": "order_2026_001",
  "metadata": {
    "blockchain_address": "0x9f3a...b41C"
  },
  "created_at": "2026-04-27T12:00:00Z",
  "updated_at": "2026-04-27T12:00:05Z"
}

Key fields after generation

FieldDescription
statusTransitions to requires_action — the intent is now waiting for on-chain payment.
crypto_amountRaw amount in the token's smallest unit (e.g. 4990000 for 4.99 USDC with 6 decimals).
crypto_amount_decimalHuman-readable amount (e.g. "4.99"). Display this to the customer.
token_price_centsSnapshot of the token price at generation time, in minor fiat units.
metadata.blockchain_addressThe on-chain address the customer should send funds to.

Errors

StatusCodeMeaning
400missing_idempotency_keyIdempotency-Key header was not provided.
401unauthorizedInvalid or missing API key.
404not_foundPayment intent does not exist.
409invalid_state_transitionThe intent is not in a state that allows address generation (e.g. already succeeded or canceled).
503price_unavailablePricing is temporarily unavailable. Retry with backoff.
503no_wallets_availableNo wallets are available in the pool for the requested network. Contact support or retry later.
Last updated Edit on GitHub