Configuration
Checkout and merchant functions take CheckoutClientOptions, documented here. Payout functions
take PayoutClientOptions: apiBaseUrl, a required apiKey, and
optional fetcher and signal.
CheckoutClientOptions
type CheckoutClientOptions = {
apiBaseUrl: string;
checkoutBaseUrl?: string;
apiKey?: string;
fetcher?: typeof fetch;
signal?: AbortSignal;
preselectedMethod?: CheckoutPreselectMethod;
};
| Field | Description |
|---|---|
apiBaseUrl | API host: https://api.pay.peer.xyz. |
checkoutBaseUrl | Host that checkoutUrl is built on: https://pay.peer.xyz. Always set it. It defaults to apiBaseUrl, which sends the customer to the API host instead of checkout. |
apiKey | Your merchant API key, sent as X-API-Key. Required by every function that calls the API; getCheckoutUrl and redirectToCheckout ignore it. |
fetcher | Custom fetch implementation, for tests or your own transport. Defaults to the global fetch. |
signal | AbortSignal that cancels the request. Bound server-side calls, for example with AbortSignal.timeout(8_000), so a slow response cannot block your handler. |
preselectedMethod | Payment method to select on the hosted checkout. See below. |
The checkout URL is {checkoutBaseUrl}/?order={orderId}&token={orderToken}. Any path or query
string on checkoutBaseUrl is dropped.
preselectedMethod
Takes one of the ten fiat PaymentPlatform identifiers, such as
venmo or xmoney, or a Zelle bank: zelle-bofa, zelle-capitalone, zelle-chase or
zelle-citi. The SDK appends it to checkoutUrl as method=<value>; it is not sent to the
API. An invalid value throws a TypeError before any request: createCheckout rejects and
getCheckoutUrl throws. Without the SDK, append &method=<value> to the checkout URL yourself.
const { checkoutUrl } = await createCheckout(params, {
apiBaseUrl: 'https://api.pay.peer.xyz',
checkoutBaseUrl: 'https://pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY!,
preselectedMethod: 'venmo',
});
// https://pay.peer.xyz/?order=...&token=...&method=venmo
Checkout selects the method when it has a quote for the order. If the method has no liquidity for the amount or does not work on the customer's device, checkout selects the first available method instead and shows a notice. If the order does not offer the method, or the method does not support the checkout currency, checkout ignores it.
A Zelle bank selects Zelle with that bank, for a customer who already chose their bank on your
site. Zelle without a bank selects Zelle with its default bank. A bank the order does not accept is
ignored. Read the order's zellePaymentMethodIds before
offering a bank. For Seller Automated Release only, the list is empty when email quotes are
disabled and contains zelle-bofa and zelle-capitalone when enabled. On a phone, zelle-chase and zelle-citi
count as not working on the device.
CheckoutPreselectMethod is not exported from @zkp2p/pay-sdk. Import it from
@zkp2p/pay-shared to annotate the value.
Endpoint Mapping
| Function | Endpoint |
|---|---|
createCheckout | POST {apiBaseUrl}/api/v1/orders |
getMerchant | GET {apiBaseUrl}/api/v1/merchants/me |
checkQuoteAvailability | POST {apiBaseUrl}/api/v1/merchants/me/quotes/availability |
Endpoints with no SDK helper, such as listing orders and payments, are in the API reference.