Configuration
All SDK functions accept CheckoutClientOptions.
CheckoutClientOptions
interface CheckoutClientOptions {
apiBaseUrl: string;
checkoutBaseUrl?: string;
apiKey?: string;
fetcher?: typeof fetch;
}
Fields
apiBaseUrl (required)
Base URL for API requests.
{
apiBaseUrl: 'https://api.pay.peer.xyz'
}
apiKey (required for authenticated endpoints)
Used as X-API-Key when creating orders and reading merchant data.
{
apiKey: process.env.ZKPAY_API_KEY
}
checkoutBaseUrl (optional)
Overrides checkout URL generation. Defaults to apiBaseUrl.
{
apiBaseUrl: 'https://api.pay.peer.xyz',
checkoutBaseUrl: 'https://pay.peer.xyz'
}
fetcher (optional)
Custom fetch implementation for tests or custom transport.
{
fetcher: customFetch
}
Example
import { createCheckout, type CheckoutClientOptions } from '@zkp2p/pay-sdk';
const config: CheckoutClientOptions = {
apiBaseUrl: process.env.ZKPAY_API_URL || 'https://api.pay.peer.xyz',
checkoutBaseUrl: process.env.ZKPAY_CHECKOUT_URL || 'https://pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY,
};
await createCheckout(
{
requestedUsdcAmount: '20.00',
destinationChainId: 8453,
destinationToken: 'USDC',
},
config,
);
Endpoint Mapping
| Function | Endpoint |
|---|---|
createCheckout | POST {apiBaseUrl}/api/v1/orders |
getMerchant | GET {apiBaseUrl}/api/v1/merchants/me |
getCheckoutUrl builds {checkoutBaseUrl}/?order={orderId}&token={orderToken}.