Skip to main content

SDK Reference

The @zkp2p/pay-sdk package provides checkout order helpers.

Quick Example

import { createCheckout } from '@zkp2p/pay-sdk';

const checkout = await createCheckout(
{
requestedFiatAmount: '100.00',
requestedFiatCurrency: 'EUR',
destinationChainId: 8453,
destinationToken: 'USDC',
destinationAddress: '0xYourWallet',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
},
{
apiBaseUrl: 'https://api.pay.peer.xyz',
checkoutBaseUrl: 'https://pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY!,
}
);

window.location.href = checkout.checkoutUrl;

createCheckout supports either:

  • requestedUsdcAmount, or
  • requestedFiatAmount + requestedFiatCurrency

Available Functions

FunctionDescription
createCheckoutCreate an order + checkout URL
getCheckoutUrlBuild checkout URL
redirectToCheckoutRedirect browser to checkout
createCheckoutAndRedirectCreate order + redirect in one call
getMerchantFetch merchant profile

getMerchant

function getMerchant(opts: CheckoutClientOptions): Promise<MerchantInfo>
import { getMerchant } from '@zkp2p/pay-sdk';

const merchant = await getMerchant({
apiBaseUrl: 'https://api.pay.peer.xyz',
apiKey: process.env.ZKPAY_API_KEY!,
});

console.log(merchant.name);
console.log(merchant.merchantConfig?.enabledRails);

Configuration

All SDK functions use CheckoutClientOptions:

interface CheckoutClientOptions {
apiBaseUrl: string;
checkoutBaseUrl?: string;
apiKey?: string;
fetcher?: typeof fetch;
}

See Configuration for details.