BchainPayBchainPay

Node.js SDK


title: "Node.js SDK" description: "Official @bchainpay/node SDK — typed, promise-based, with retry-with-jitter on 429s." section: "SDKs" order: 1 updated: "2026-04-18" sourcePath: "content/docs/sdks/node.mdx"

The @bchainpay/node SDK wraps the REST API with full TypeScript types, automatic retries on 429 and 5xx, and built-in idempotency-key generation.

Install

npm install @bchainpay/node
# or pnpm add @bchainpay/node / yarn add @bchainpay/node

Requires Node.js 18+.

Initialize

import { BchainPay } from "@bchainpay/node";
 
const client = new BchainPay(process.env.BCHAINPAY_API_KEY!, {
  timeoutMs: 10_000,
  maxRetries: 3,
});

Create a payment intent

const intent = await client.paymentIntents.create({
  amount_cents: 4999,
  currency: "USD",
  settlement_currency: "USDC",
  network: "polygon",
  reference: "INV-2026-001",
});
 
console.log(intent.address); // 0x9f3a...b41C

Verify a webhook

import { verifyWebhook } from "@bchainpay/node/webhooks";
 
app.post("/webhooks", express.raw({ type: "*/*" }), (req, res) => {
  const ok = verifyWebhook(
    req.body,
    req.header("BchainPay-Signature")!,
    process.env.BCHAINPAY_WEBHOOK_SECRET!,
  );
  if (!ok) return res.status(400).end();
  // ... handle event
  res.status(200).end();
});
Last updated Edit on GitHub