Skip to main content

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 chainrefundTo
Zcash, Bitcoin, Solana, TronRequired; must be a valid address on that chain. Zcash requires a mainnet transparent address.
EVM chainsRequired; 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​

StatusMeaning
CREATEDIn progress. The customer is inside their payment window (quoteExpiresAt) and the quote in quote is reserved for them
SETTLEDThe 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
EXPIREDThe window closed without a verified payment. The order stays open
CANCELLEDThe customer switched payment method or backed out before paying
FAILEDThe 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​

ParameterTypeDescription
statusCheckoutPaymentStatusCREATED, SETTLED, EXPIRED, CANCELLED, or FAILED
payoutStatusCheckoutPaymentPayoutStatusPAID, HELD, RELEASED, or DISPUTED; see deferred payout state
chargebackStatusPaymentChargebackStatusNONE 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:

FieldDescription
orderIdThe order this attempt belongs to
railPayment platform the customer used, for example venmo. See payment platforms
paymentAmount, currencyWhat 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
currencyPerUsdRateThe exchange rate for currency captured at quote time on fiat rails. Crypto rails show "1" until settlement writes the effective rate
penaltiesPaymentPenalty[], always present. A non-empty array explains a netSettledUsdcAmount lower than expected
payout{ status, releaseEligibleAt, releasedAt }; see deferred payout state
netSettledUsdcAmountNet USDC after all fees, including funds still held. null until SETTLED
totalUsdcFeeAmountFees taken from the settlement, in USDC
referralFeesPer-recipient referral fees, when any applied
railIdentifierOpaque 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
fulfillTransactionSettlement transaction hash. null until SETTLED
quoteExpiresAtWhen the customer's window closes
buyerCancelBlockMARKED_PAID or EXTENDED while the customer can no longer cancel an open fiat attempt from checkout; null otherwise. See the customer payment window
buyerMayHavePaidtrue 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
completedAtWhen 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​

StatusCause
404The 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.statusMeaning
PAIDPaid to you at settlement
HELDSettled with funds still held. releaseEligibleAt is the current eligibility estimate
RELEASEDThe held USDC was released to you at releasedAt
DISPUTEDA 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>
FieldDescription
heldUsdcAmountNet USDC currently held
heldCountNumber of held payments
nextReleaseEligibleAtEarliest releaseEligibleAt among held payments, or null
releasedUsdcAmountLast30DaysUSDC released to you in the last 30 days

Notes​

  • Payment rows are the same objects that arrive as data.payment in webhook events, so one parser handles both.
  • Sandbox settlements are simulated: no money moves, so a sandbox fulfillTransaction is not on any block explorer.
  • Parse amounts with a decimal library or scale to integers, as the example does, not with parseFloat.