Quickstart
Integrate checkout in minutes.
Prerequisites
- Merchant API key
- Backend runtime (Node.js 18+)
- Destination wallet for settlement
1. Install
npm install @zkp2p/pay-sdk
2. Create Checkout
import { createCheckout } from '@zkp2p/pay-sdk';
const checkout = await createCheckout(
{
requestedUsdcAmount: '50.00',
destinationChainId: 8453,
destinationToken: 'USDC',
destinationAddress: '0xYourWalletAddress',
successUrl: 'https://yoursite.com/success',
cancelUrl: 'https://yoursite.com/cancel',
notes: {
merchantOrderId: 'order_123',
customerId: 'cust_456',
},
},
{
apiBaseUrl: 'https://api.pay.peer.xyz',
checkoutBaseUrl: 'https://pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY!,
}
);
console.log(checkout.order.id);
console.log(checkout.checkoutUrl);
3. Redirect User
window.location.href = checkout.checkoutUrl;
// or: window.open(checkout.checkoutUrl, '_blank')
4. Handle Webhooks
switch (event.type) {
case 'ORDER_FULFILLED':
// mark paid/completed
break;
case 'PAYMENT_SETTLED':
// optional: mark payment settled (order fulfillment follows ORDER_FULFILLED)
break;
case 'PAYMENT_FAILED':
case 'PAYMENT_EXPIRED':
// mark failed/expired
break;
}
5. Verify End-to-End
- Create checkout.
- Complete payment in checkout UI.
- Confirm webhook delivery.
- Confirm settlement at destination wallet.
Notes
- Checkout supports multi-currency quote selection and payment FX snapshots.