Open-Amount Orders
An open-amount order has no amount when you create it. The customer types the amount in checkout and sees live prices for each payment method. Use it for deposits, top-ups and donations, where the customer decides how much to pay.
Create an order
Pass openAmount instead of an amount to createCheckout:
import { createCheckout } from '@zkp2p/pay-sdk';
const checkout = await createCheckout(
{
openAmount: {
currency: 'USD',
minAmount: '10',
maxAmount: '2000',
presets: ['25', '50', '100', '250'],
},
destinationChainId: 8453,
destinationToken: 'USDC',
},
{
apiBaseUrl: 'https://api.pay.peer.xyz',
checkoutBaseUrl: 'https://pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY!,
},
);
Or call the API directly:
curl -X POST https://api.pay.peer.xyz/api/v1/orders \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{
"openAmount": {
"currency": "USD",
"minAmount": "10",
"maxAmount": "2000",
"presets": ["25", "50", "100", "250"]
},
"destinationChainId": 8453,
"destinationToken": "USDC"
}'
| Field | Type | Required | Description |
|---|---|---|---|
openAmount.currency | string | Yes | Currency of your limits and presets, for example USD or EUR. Must be a currency Peer Pay can price. |
openAmount.minAmount | string | No | Smallest amount the customer can pay, in currency, with at most 2 decimals. |
openAmount.maxAmount | string | No | Largest amount the customer can pay, in currency, with at most 2 decimals. Must convert to at most 10,000 USDC at the current rate. |
openAmount.presets | string[] | No | 1 to 6 suggested amounts shown under the input, in currency, with at most 2 decimals. |
The response is a normal order with amountMode: "OPEN", requestedUsdcAmount and
remainingUsdcAmount set to null, and amountVersion: 0. The stored openAmount is
normalized: upper-case currency, 2-decimal amounts, presets sorted ascending.
Rules
openAmountis the third amount mode and cannot be combined withrequestedUsdcAmount,requestedFiatAmountorrequestedFiatCurrency. Leaving the amount out never creates an open-amount order.minAmountmust not be greater thanmaxAmount. Presets must be unique ("10"and"10.00"are the same preset).- The allowed range is the tightest of your
minAmountandmaxAmount, the platform minimum, the 10,000 USDC order maximum, and your account's order-size limits, which sandbox does not apply. The range must not be empty, and every preset must fall inside it. Without amaxAmount, the customer can pay up to 10,000 USDC worth ofcurrencyat the current rate. - Each bank or app payment must also fit the per-payment limit, which counts buyer-paid fees and bridge costs. An amount inside the range can exceed it: checkout then lists those methods as unavailable for that amount, and crypto still works.
dynamicOrdersEnabled: trueis not allowed. Open-amount orders are never resized.- An idempotent retry must repeat the same
openAmount. Reusing theidempotencyKeyof an open-amount order for a fixed-amount request, or the reverse, returns409 IDEMPOTENCY_KEY_CONFLICT. - An open-amount order takes one completed payment. Create a new order for each deposit.
Customer experience
Checkout shows an amount input with your presets. The customer types the amount in the
checkout's selected currency, which can differ from openAmount.currency. In your currency they
see your limits and presets as you set them, unless a tighter limit applies. In any other
currency these convert at the live rate and round to whole units, the minimum up and the maximum
down. Whatever the currency, the amount converts to USDC and must fit the rules and
your monthly volume cap.
Nothing is saved while the customer types. When they start a payment, Peer Pay saves the amount
on the order, in the currency they typed it in, and sends
ORDER_AMOUNT_SET.
When the amount can change
The customer can change the amount until a payment exists that can still complete. The
order read returns why the amount is locked as amountLock:
amountLock | Meaning |
|---|---|
null | The customer can change the amount. |
PAYMENT_IN_PROGRESS | A payment is open. Cancelling it unlocks the amount. |
PAYMENT_MAY_SETTLE | A payment can still settle late: an expired payment, a Zcash deposit, or a failed crypto payment the bridge can still deliver. Cancelling does not unlock the amount. |
PAID | A payment settled. |
The same read returns the allowed range as openAmount.effectiveMin and
openAmount.effectiveMax, in openAmount.currency at the current rate. Both are null while the
amount is locked, once the order is fulfilled or cancelled, and while no exchange rate is
available. openAmount.savedInput is the saved amount as { amount, currency }, in the currency
the customer typed it in.
Paying the rest after a partial payment, with the saved amount and currency, does not change the order and sends no event.
Subscribe to ORDER_AMOUNT_SET
Webhooks receive only the events they subscribe to, and existing webhooks do not get
ORDER_AMOUNT_SET until you add it. In the
Merchant Dashboard, open
Settings → Developer, edit the webhook and select Order amount set, or update it through
the API with the full event list:
curl -X PATCH https://api.pay.peer.xyz/api/v1/webhooks/{webhookId} \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{"events": ["ORDER_CREATED", "ORDER_AMOUNT_SET", "PAYMENT_CREATED", "ORDER_FULFILLED"]}'
ORDER_AMOUNT_SET carries the saved order and data.amountChange: previousAmountUsdc,
newAmountUsdc, fiat (the amount and currency the customer typed) and amountVersion.
amountVersion goes up by one each time the amount is saved. Deliveries can arrive out of order,
so keep the highest version you have seen. Use the USDC amounts for accounting. The full payload
is under ORDER_AMOUNT_SET.
Credit on ORDER_FULFILLED
ORDER_AMOUNT_SET is informational, for example to show a pending deposit. Credit the customer
only on ORDER_FULFILLED, using the amounts in its data.order. A customer who cancels a payment
can choose a different amount, so the first amount you see may not be the one they pay:
ORDER_CREATED: no amount,amountVersion0.- The customer tries $100, then $250. No webhook is sent while they type.
- They start a $250 payment:
ORDER_AMOUNT_SET(none to 250, version 1),PAYMENT_CREATED. - They cancel it:
PAYMENT_CANCELLED. - They start a $200 payment:
ORDER_AMOUNT_SET(250 to 200, version 2),PAYMENT_CREATED. - The payment settles:
PAYMENT_SETTLED, thenORDER_FULFILLEDfor 200.
Read the order in TypeScript
CheckoutOrder is a union on amountMode. Narrow it before reading the amounts:
import { OrderAmountMode, type CheckoutOrder } from '@zkp2p/pay-sdk';
function describeAmount(order: CheckoutOrder): string {
if (order.amountMode === OrderAmountMode.OPEN && order.requestedUsdcAmount === null) {
return `Awaiting amount (${order.openAmount.currency})`;
}
return `${order.requestedUsdcAmount} USDC`;
}
Errors
| Status | Code | When |
|---|---|---|
400 | OPEN_AMOUNT_INVALID | Create: openAmount is invalid, its currency cannot be priced, its maxAmount converts to more than 10,000 USDC, the allowed range is empty, a preset is outside it, or it is combined with another amount mode or dynamicOrdersEnabled: true. The message names the field. |
400 | OPEN_AMOUNT_DISABLED | Create: open-amount orders are not available. Orders already created keep working. |
400 | AMOUNT_REQUIRED | Payment start: the order has no saved amount and the request sends none. |
400 | AMOUNT_NOT_ALLOWED | Quotes or payment start: an amount was sent for a fixed-amount order. |
400 | AMOUNT_OUT_OF_RANGE | Quotes or payment start: the amount is outside the allowed range. responseObject carries effectiveMin, effectiveMax and currency, in the currency the amount was typed in. |
400 | INTENT_ABOVE_MAX | Payment start: on a bank or app method, the amount plus buyer-paid fees would settle more than 10,000 USDC. The amount is not saved. Quotes list such methods as unavailable instead. |
400 | RESIZE_NOT_SUPPORTED | Resize: open-amount orders are never resized. |
403 | MERCHANT_MONTHLY_VOLUME_LIMIT_EXCEEDED | Payment start: the new amount would take the month the order was created in past your plan's volume cap. |
409 | AMOUNT_LOCKED | Quotes or payment start: a payment that can still complete locks the amount. responseObject.reason is the amountLock value. |
409 | AMOUNT_CONFLICT | Payment start: the amount was saved from another tab after this checkout loaded. |
429 | Quotes: too many quote requests with an amount for one order. Retry shortly. | |
502 | EXCHANGE_RATE_LOOKUP_FAILED | Create, quotes or payment start: no exchange rate for the order's currency or the currency the amount was typed in. Retry. |
Test locally with the CLI
The Peer Pay CLI local simulator accepts open-amount orders:
peer-pay-cli --local orders create --open-amount --currency USD --min 10 --max 2000 --presets 25,50,100
peer-pay-cli --local simulate ORDER_ID --event ORDER_AMOUNT_SET --amount 100 --amount-currency USD --rail venmo
The simulation starts a payment with the amount in --amount-currency, as checkout does with
its selected currency, so your webhook endpoint receives ORDER_AMOUNT_SET and then
PAYMENT_CREATED.