SDK Overview
@pepay/x402flex is the only supported SDK package.
Install
npm install @pepay/x402flex ethers
Mode selection
api: API-only workflows (bnbpay-api)contracts: direct router/session/subscription callshybrid: API-first with direct contract fallback
Initialize examples
What this does: configures one client per integration style.
import { createClient } from '@pepay/x402flex';
const apiSdk = createClient({
mode: 'api',
api: { baseUrl: 'https://api.bnbpay.org' },
});
const contractsSdk = createClient({
mode: 'contracts',
preset: 'bnbpay-testnets',
contracts: { defaultNetwork: 'eip155:97' },
});
const hybridSdk = createClient({
mode: 'hybrid',
preset: 'bnbpay-testnets',
api: { baseUrl: 'https://api.bnbpay.org' },
contracts: { defaultNetwork: 'eip155:97' },
});
Expected result: each client exposes the same top-level namespaces with mode-aware behavior.
Namespace map
sdk.networkssdk.intentssdk.paymentssdk.x402sdk.sessionssdk.subscriptionssdk.relay
Subpath imports
import { createClient } from '@pepay/x402flex';
import { wrapFetchWithPayment } from '@pepay/x402flex/fetch';
import { wrapAxiosWithPayment } from '@pepay/x402flex/axios';
Common initialization errors
- Missing
api.baseUrlinapimode. - Missing contract network config in
contractsmode. - Using unsupported chain reference (must match supported chain IDs/aliases).