Quickstart
Create an order on your backend, send the customer to the hosted checkout, and fulfill on the webhook.
You need:
- A merchant account and its sandbox API key, from Settings, Developer with Sandbox Mode on. Keep the key on your server.
- A Node.js 18+ backend. Other languages can call
POST /api/v1/ordersdirectly.
To try orders and signed webhooks on localhost without an account, use the Peer Pay CLI.
1. Install
npm install @zkp2p/pay-sdk@9
2. Create an order
import { createCheckout } from '@zkp2p/pay-sdk';
const checkout = await createCheckout(
{
requestedUsdcAmount: '50.00',
successUrl: 'https://yoursite.com/success',
notes: { merchantOrderId: 'order_123' },
},
{
apiBaseUrl: 'https://api.pay.peer.xyz',
checkoutBaseUrl: 'https://pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY!,
},
);
// Store checkout.order.id with your order, then send the customer to checkout.checkoutUrl.
Omitted fields use your dashboard settings, so the payment settles as USDC on Base to your account's wallet unless you change that. To price in fiat, send requestedFiatAmount and requestedFiatCurrency instead; to let the customer type the amount, send openAmount. All fields are in createCheckout.
3. Send the customer to checkout
Return checkoutUrl to the browser and redirect to it:
window.location.assign(checkoutUrl);
A new tab or an embedded iframe also work; see integration options.
4. Handle the webhook
Register an HTTPS endpoint for ORDER_FULFILLED under Settings, Developer or with the webhooks API, and store the signing secret it returns. In the handler, verify the signature over the raw request body, then mark the order paid. Webhook verification has handlers in Node, Python and Go. Never fulfill on the customer returning to your successUrl.
5. Test end to end
- Create an order with your sandbox key and open its
checkoutUrl. - Pay it. No money moves in sandbox: checkout lists sample payments to verify, or accepts any transaction ID. To settle it from your code instead, call
POST /api/v1/sandbox/test-orderwith{ "orderId": "<order id>" }; see let a coding agent integrate. - Confirm your handler received
ORDER_FULFILLEDand marked the order paid.
Go live
- Verify your identity and activate your plan under Settings, Billing. New accounts start on Pro, not yet activated. Until your plan is activated (
planActivatedAtis set on the merchant profile), live orders fail with403 MERCHANT_TIER_FORBIDDEN; a tier alone is not enough. - Switch to your live API key.
- Register your webhook again with the live key and store its new signing secret. Sandbox and live have separate keys, webhooks and secrets.
Failed calls throw PayApiError; the codes are under createCheckout errors. To have a coding agent do this integration, see let a coding agent integrate.