billSDK
Adapters

Stripe

Payment processing with Stripe

Setup

import { stripePayment } from "@billsdk/stripe";

payment: stripePayment({
  secretKey: process.env.STRIPE_SECRET_KEY!,
  webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
})

Webhooks

Endpoint: /api/billing/webhook

Events to enable:

  • checkout.session.completed — activates subscription
  • payment_intent.payment_failed — marks as failed

Stripe Dashboard

  1. Developers → Webhooks → Add endpoint
  2. URL: https://your-domain.com/api/billing/webhook
  3. Copy signing secret to STRIPE_WEBHOOK_SECRET

Local Development

stripe listen --forward-to localhost:3000/api/billing/webhook

Payment Modes

PriceModeBehavior
0SetupCollects payment method, no charge
>0PaymentCharges immediately, saves method

Renewals

await billing.api.processRenewals();
await billing.api.processRenewals({ dryRun: true });
await billing.api.processRenewals({ customerId: user.id });

Refunds

await billing.api.createRefund({
  paymentId: "...",
  amount: 1000, // partial, in cents
});

On this page