Skip to main content

Quickstart

Create a checkout, redirect the customer, and handle the webhook.

Test locally first​

Use the Peer Pay CLI to test orders and signed webhooks on localhost, without a merchant account or tunnel:

npm install -g @zkp2p/peer-pay-cli
peer-pay-cli serve

Follow the local testing walkthrough. For hosted checkout, complete the steps below. You can create and configure your merchant from the terminal.

Prerequisites​

  • Merchant API key
  • Backend runtime (Node.js 18+)
  • Destination wallet for settlement

1. Install​

npm install @zkp2p/pay-sdk@7

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. Send the Customer to Checkout​

window.location.href = checkout.checkoutUrl;

A new tab and an embedded iframe work too. See integration options.

4. Handle Webhooks​

Register an endpoint, verify the signature over the raw body, and mark the order paid on ORDER_FULFILLED. Webhook verification has the handler in Node, Python, and Go; events lists what each one means.

5. Verify End-to-End​

  1. Create checkout.
  2. Complete payment in checkout UI.
  3. Confirm webhook delivery.
  4. Confirm settlement at destination wallet.

Notes​

Next​