@peltier/node
v0.2.0
Published
Peltier backend SDK — HTTP 402 payment gate (Express/Fetch adapters), webhook verification, subscriptions, payment sessions, plus the full @peltier/core flow surface. Runtime-neutral: Node 18+, Bun, Deno, edge.
Readme
@peltier/node
The Peltier backend SDK — HTTP 402 payment gate, webhook verification, and
subscriptions, plus a full re-export of @peltier/core
so every flow drives from one server package.
React-free by construction (viem + Web Crypto only). "node" is the deployment tier,
not a runtime requirement: Node 18+, Bun, Deno, and edge all work. Never ship it
to the browser — it handles your sk_ secret key.
npm install @peltier/node viem402 payment gate in three lines
import { peltier402Express } from '@peltier/node'
app.use('/paid', peltier402Express({
apiUrl: 'https://api.peltier.dev',
secretKey: process.env.PELTIER_SK!,
price: '0.10',
}))Unpaid requests receive an x402-shaped 402 challenge carrying a checkout session.
Paid requests pass through with a stateless pt_ access token in X-PAYMENT-TOKEN.
Also exported:
peltier402Fetch— the same gate for Fetch-style handlers (Next.js route handlers, Hono,Bun.serve).createPaymentGate— the framework-agnostic core, if you're wiring a different server.parse402(via the core re-export) — the agent/client side of the handshake.
Webhooks
import { verifyWebhookSignature } from '@peltier/node'
const ok = await verifyWebhookSignature(rawBody, signatureHeader, webhookSecret)Verifies both payment.* and subscription.* deliveries. Use
verifyWebhookSignatureDetailed to get { ok, reason } when you need to log why
a delivery failed.
Subscriptions
EIP-712 typed-data builders that byte-match the on-chain PeltierSubscriptions
singleton, plus the sk_ REST client:
import { subscriptionTypedData, subscriptionId, createSubscription } from '@peltier/node'
const typedData = subscriptionTypedData(8453, SUBSCRIPTIONS_ADDRESS, sub) // payer signs this
const subId = subscriptionId(8453, SUBSCRIPTIONS_ADDRESS, sub) // the on-chain id
await createSubscription(apiUrl, secretKey, { chain_id: 8453, subscription: sub, signature })cancelSubscriptionTypedData + relaySubscriptionCancel implement the payer's
gasless cancel. listSubscriptions / getSubscription / cancelSubscription /
triggerSubscriptionCharge / listSubscriptionCharges cover the rest of the
merchant surface.
Everything from core, one install
@peltier/node re-exports the entire @peltier/core surface: createPeltierClient,
payment sessions, intent signing, request creation, stealth withdrawal, quote and
balance queries, typed PeltierApiError, and the supported-chain constants. No
second install needed.
Related packages
| Package | For |
|---|---|
| @peltier/core | runtime-agnostic protocol core (already included here) |
| @peltier/react | React web widgets + hooks |
| @peltier/react-native | React Native widgets + hooks |
Docs
Full documentation lives at peltier.dev/docs.
License
MIT
