Skip to main content

SDK Reference

The @zkp2p-pay/sdk package provides a simple interface for integrating ZKP2P Pay into your application.

Features

  • Type-safe - Full TypeScript support with exported types
  • Lightweight - No dependencies beyond shared types
  • Flexible - Works in both browser and Node.js environments

Quick Example

import { createCheckoutSession, redirectToCheckout } from '@zkp2p-pay/sdk';

// Create a session on your backend
const session = await createCheckoutSession(
{
merchantId: 'merchant_123',
amountUsdc: '100.00',
destinationChainId: 8453,
destinationToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
recipientAddress: '0xYourWallet',
},
{
apiBaseUrl: 'https://api.zkp2p-pay.xyz',
apiKey: 'your_api_key',
}
);

// Redirect the user on your frontend
redirectToCheckout(session.session.id, {
apiBaseUrl: 'https://api.zkp2p-pay.xyz',
checkoutBaseUrl: 'https://checkout.zkp2p-pay.xyz',
apiKey: 'your_api_key',
});

Available Functions

FunctionDescription
createCheckoutSessionCreate a new checkout session
getCheckoutUrlGet the checkout URL for a session
redirectToCheckoutRedirect the browser to checkout
createSessionAndRedirectConvenience function to create and redirect

Configuration

All SDK functions require a CheckoutClientOptions configuration object:

interface CheckoutClientOptions {
apiBaseUrl: string; // Required: API server URL
apiKey: string; // Required: Your merchant API key
checkoutBaseUrl?: string; // Optional: Checkout UI URL
fetcher?: typeof fetch; // Optional: Custom fetch implementation
}

See Configuration for detailed options.

Installation

npm install @zkp2p-pay/sdk

Or with yarn:

yarn add @zkp2p-pay/sdk

See Installation for more details.