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, orrequestedFiatAmount+requestedFiatCurrency
Available Functions
| Function | Description |
|---|---|
createCheckout | Create an order + checkout URL |
getCheckoutUrl | Build checkout URL |
redirectToCheckout | Redirect browser to checkout |
createCheckoutAndRedirect | Create order + redirect in one call |
getMerchant | Fetch 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.