Payments
A payment is one customer attempt to pay an order: they picked a rail, got a quote, and have a payment window to send the money. An order can have several, because an attempt can expire or be cancelled and the customer can start again.
Create a payment
POST /api/v1/orders/:orderId/create-payment requires refundTo for every crypto payment funded from a wallet.
Use a wallet the buyer controls on the origin payment chain. See
CLI payment creation for the request options.
An order created from a checkout grant accepts a payment only with its
order token in X-Order-Token; without it the request returns HTTP 401. That token stays in the
browser that created the order and is never sent to your server.
| Payment chain | refundTo |
|---|---|
| Zcash, Bitcoin, Solana, Tron | Required; must be a valid address on that chain. Zcash requires a mainnet transparent address. |
| EVM chains | Required; must be non-zero 0x + 40 hexadecimal characters. Mixed-case EVM addresses must have a valid EIP-55 checksum; all-lowercase and all-uppercase addresses are accepted. Leading and trailing whitespace is trimmed. |
Peer (Apple Pay or Balance) (coinbase_apple_pay) | Must omit refundTo; sending it is rejected. Funding uses Relay's sender-refund placeholder together with the server-configured recovery address. |
For every wallet-funded crypto rail, a missing refund address returns HTTP 400 with
CRYPTO_REFUND_ADDRESS_MISSING; an invalid address (including the EVM zero address)
returns HTTP 400 with CRYPTO_REFUND_ADDRESS_INVALID. Peer (Apple Pay or Balance) rejects a supplied
refundTo with the validation message Apple Pay payments must not include refundTo.
On an order past its expiresAt, starting a payment
returns HTTP 410 with ORDER_EXPIRED, including a replacement for a payment that is still
open. Payments already started are unaffected.
Payment status
| Status | Meaning |
|---|---|
CREATED | In progress. The customer is inside their payment window (quoteExpiresAt) and the quote in quote is reserved for them |
SETTLED | The payment was verified (fiat) or the transfer arrived (crypto), and the net USDC was paid to you or is held for you. payout.status says which; fulfillTransaction is the settlement transaction hash |
EXPIRED | The window closed without a verified payment. The order stays open |
CANCELLED | The customer switched payment method or backed out before paying |
FAILED | The attempt could not be started onchain, or a crypto transfer failed or never arrived. A rejected verification leaves the payment CREATED so the customer can retry. errorMessage says why when known |
Only SETTLED is always final: a late settlement can still land on an expired attempt. On
Relay crypto payments, the fee and amount fields of a SETTLED payment can be refined for a few
minutes after settlement. Transitions and their webhooks are in
payment status.
A chargeback on a settled payment never changes status; it lands in chargeback and
chargebackStatus. See chargeback status.
List payments
GET /api/v1/merchants/me/payments
X-API-Key: <your key>
Every payment attempt across your orders, newest first.
Query parameters
| Parameter | Type | Description |
|---|---|---|
status | CheckoutPaymentStatus | CREATED, SETTLED, EXPIRED, CANCELLED, or FAILED |
payoutStatus | CheckoutPaymentPayoutStatus | PAID, HELD, RELEASED, or DISPUTED; see deferred payout state |
chargebackStatus | PaymentChargebackStatus | NONE or CHARGEBACKED |
page and limit follow the shared pagination rules. There is no order
filter; use list payments for an order.
Response
responseObject is a page of CheckoutPayment rows. On this list
only, quote is null for an older settled payment whose quote was not kept.
type MerchantPaymentList = {
payments: Array<Omit<CheckoutPayment, 'quote'> & { quote: CheckoutPayment['quote'] | null }>;
total: number;
page: number;
limit: number;
};
The fields that matter for reconciliation:
| Field | Description |
|---|---|
orderId | The order this attempt belongs to |
rail | Payment platform the customer used, for example venmo. See payment platforms |
paymentAmount, currency | What the customer paid. paymentAmount is "0" until the attempt settles. currency is a fiat code on fiat rails and a token symbol (USDC, ETH, ZEC) on crypto rails, where settlement sets it to the token that arrived |
currencyPerUsdRate | The exchange rate for currency captured at quote time on fiat rails. Crypto rails show "1" until settlement writes the effective rate |
penalties | PaymentPenalty[], always present. A non-empty array explains a netSettledUsdcAmount lower than expected |
payout | { status, releaseEligibleAt, releasedAt }; see deferred payout state |
netSettledUsdcAmount | Net USDC after all fees, including funds still held. null until SETTLED |
totalUsdcFeeAmount | Fees taken from the settlement, in USDC |
referralFees | Per-recipient referral fees, when any applied |
railIdentifier | Opaque reference for the attempt: the onchain intent on fiat rails, the transfer request on crypto rails. null until the attempt is registered. A recreate replaces it on fiat rails, and settlement can replace it on crypto rails. id never changes, so key your own records on id |
fulfillTransaction | Settlement transaction hash. null until SETTLED |
quoteExpiresAt | When the customer's window closes |
buyerCancelBlock | MARKED_PAID or EXTENDED while the customer can no longer cancel an open fiat attempt from checkout; null otherwise. See the customer payment window |
buyerMayHavePaid | true while a CREATED attempt has been marked paid in checkout or the customer started a verification for it, even if they later took the mark back; false otherwise. Lookups Pay runs on its own, such as the pre-expiry memo lookup, do not set it. See the customer payment window |
completedAt | When the payment settled or the customer cancelled it. null on EXPIRED and FAILED |
errorCode is always null on list rows; only the hosted order read
sets it.
Example
Every settled payment, most recent first:
curl "https://api.pay.peer.xyz/api/v1/merchants/me/payments?status=SETTLED&limit=100" \
-H "X-API-Key: $ZKPAY_API_KEY"
Walking every page to total what settled. Envelope<T> is the shared
response envelope.
// "12.5" -> 12500000n. Scale to integers instead of parseFloat.
const toMicroUsdc = (amount: string): bigint => {
const [whole, fraction = ''] = amount.split('.');
return BigInt(whole) * 1_000_000n + BigInt(fraction.padEnd(6, '0').slice(0, 6));
};
async function sumSettledMicroUsdc(): Promise<bigint> {
let page = 1;
let settled = 0n;
for (;;) {
const url = new URL('https://api.pay.peer.xyz/api/v1/merchants/me/payments');
url.searchParams.set('status', 'SETTLED');
url.searchParams.set('page', String(page));
url.searchParams.set('limit', '100');
const response = await fetch(url, {
headers: { 'X-API-Key': process.env.ZKPAY_API_KEY! },
signal: AbortSignal.timeout(8_000),
});
const body = (await response.json()) as Envelope<MerchantPaymentList>;
if (!body.success || body.responseObject === null) {
throw new Error(`${body.statusCode}: ${body.message}`);
}
for (const payment of body.responseObject.payments) {
settled += toMicroUsdc(payment.netSettledUsdcAmount ?? '0');
}
if (page * body.responseObject.limit >= body.responseObject.total) break;
page += 1;
}
return settled;
}
Every charged-back payment:
curl "https://api.pay.peer.xyz/api/v1/merchants/me/payments?chargebackStatus=CHARGEBACKED" \
-H "X-API-Key: $ZKPAY_API_KEY"
Errors
Only the common errors.
List payments for an order
GET /api/v1/merchants/me/orders/{orderId}/payments
X-API-Key: <your key>
Every attempt on one of your orders, newest first, as full
CheckoutPayment rows, without pagination. When a customer says
they paid, railIdentifier identifies the attempt and quoteExpiresAt is its window. payTo
is an opaque recipient identifier, not a readable handle. Remediation acts
on these rows.
type OrderPayments = { payments: CheckoutPayment[] };
curl "https://api.pay.peer.xyz/api/v1/merchants/me/orders/cmf5k2x9d0001abcd1234efgh/payments" \
-H "X-API-Key: $ZKPAY_API_KEY" \
| jq '.responseObject.payments[] | {id, status, rail, railIdentifier, quoteExpiresAt}'
Errors
| Status | Cause |
|---|---|
404 | The order does not exist, belongs to another merchant, or is in the other environment |
The common errors also apply. This read also counts toward the per-merchant remediation read limit.
Deferred payout state
With deferred payouts, a settled payment's
USDC can be held before it reaches you. Every payment carries
payout: { status, releaseEligibleAt, releasedAt }, all null before settlement:
payout.status | Meaning |
|---|---|
PAID | Paid to you at settlement |
HELD | Settled with funds still held. releaseEligibleAt is the current eligibility estimate |
RELEASED | The held USDC was released to you at releasedAt |
DISPUTED | A dispute affected the held payout |
For a payment protected by V3, payout.heldUsdcAmount is the current deferred balance and
payout.paidUsdcAmount is the amount actually paid. Each is a decimal USDC string when
applicable, otherwise null. A share award reduces the held balance. A proof can shorten the
wait, and backing or waiver can pay the recipient before the estimate. Use releasedAt for the
observed payment time. netSettledUsdcAmount continues to describe the original sale.
A HELD payment is still SETTLED and still completes its order. A conversion to another
chain or token starts only after release, with a fresh quote, and
PAYMENT_PAYOUT_RELEASED fires on release.
GET /api/v1/merchants/me/payouts/summary
X-API-Key: <your key>
| Field | Description |
|---|---|
heldUsdcAmount | Net USDC currently held |
heldCount | Number of held payments |
nextReleaseEligibleAt | Earliest releaseEligibleAt among held payments, or null |
releasedUsdcAmountLast30Days | USDC released to you in the last 30 days |
Notes
- Payment rows are the same objects that arrive as
data.paymentin webhook events, so one parser handles both. - Sandbox settlements are simulated: no money moves, so a sandbox
fulfillTransactionis not on any block explorer. - Parse amounts with a decimal library or scale to integers, as the example does, not with
parseFloat.