@lntpay/sdk
v0.1.5
Published
Official LNTPay SDK for Node.js
Downloads
27
Maintainers
Readme
@lntpay/sdk
Official LNTPay SDK for Node.js (TypeScript-first).
Installation
npm install @lntpay/sdkAuthentication
import LNTPay from "@lntpay/sdk";
const client = new LNTPay({
apiKey: process.env.LNTPAY_API_KEY!
});Create a charge (BOLT11)
const charge = await client.charges.create({
amount_sats: 2500,
memo: "Coffee"
});
console.log(charge.bolt11);Create a withdrawal
const withdrawal = await client.withdrawals.create({
amount: 5000,
currency: "USD",
description: "Refund"
});Webhook signature validation
import type { WebhookEvent } from "@lntpay/sdk";
const rawBody = req.body; // Buffer
const signatureHeader = req.headers["lntpay-signature"] as string;
const event = client.webhooks.constructEvent<WebhookEvent>(
rawBody,
signatureHeader,
process.env.LNTPAY_WEBHOOK_SECRET!
);
console.log(event.type);Idempotency
await client.charges.create(
{ amount_sats: 1000 },
{ idempotencyKey: "charge-2026-02-02-0001" }
);Request options and retries
RequestOptions supports retries for GET requests only. POST retries are ignored.
const charge = await client.charges.retrieve("ch_123", { retries: 2 });Examples
Examples live in /examples.
export LNTPAY_API_KEY="..."
export LNTPAY_WEBHOOK_SECRET="..."
# optional
export LNTPAY_BASE_URL="https://api.lntpay.com"
npm install
npm run build
node examples/node-pay-per-request.mjsWebhook receiver example:
node examples/webhook-receiver.mjsLicense
MIT
