Welcome to Nebutra Sailor Docs 🎉
ChangelogIntroductionLicensing
Help Center (External) ↗

Stripe

Configure Stripe for billing, subscriptions, and the customer billing portal.

This page covers the legacy Stripe integration. Per ADR 2026-09-26, card payments worldwide moved to Creem — a merchant of record that collects and remits sales tax/VAT itself. Stripe is retired from new work; its code stays only for subscriptions, the billing portal, the licence webhook, and checkouts opened before the switch. Nothing new should be built on it. For the current card rail, see Creem.

Prerequisites

  • A Stripe account
  • Stripe CLI installed: npm install -g stripe

Step 1: Set environment variables

STRIPE_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxx
STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxx

Use sk_test_ keys during development.

Step 2: Create products in Stripe

Nebutra's billing model maps to three Stripe products:

# Create products
stripe products create --name="Nebutra FREE" --description="Free tier"
stripe products create --name="Nebutra PRO" --description="$29/month"
stripe products create --name="Nebutra ENTERPRISE" --description="Custom pricing"

# Create prices
stripe prices create \
  --product=prod_xxx \
  --unit-amount=2900 \
  --currency=usd \
  --recurring[interval]=month

Step 3: Configure webhook endpoint

In your Stripe Dashboard: Developers → Webhooks → Add endpoint

  • URL: https://api.nebutra.com/api/webhooks/stripe
  • Events to listen for:
    • checkout.session.completed
    • customer.subscription.created
    • customer.subscription.updated
    • customer.subscription.deleted
    • invoice.paid
    • invoice.payment_failed

Test webhooks locally

stripe listen --forward-to localhost:3000/api/webhooks/stripe

Step 4: Webhook handler

The Stripe webhook handler is pre-built in the monorepo — as a Hono route on the API gateway, not a Next.js route handler:

const stripeWebhookRoute = createRoute({ method: "post", path: "/stripe" /* … */ });

stripeWebhookRoutes.openapi(stripeWebhookRoute, async (c) => {
  const body = await c.req.text();
  const sig = c.req.header("stripe-signature");
  const event = stripe.webhooks.constructEvent(body, sig!, process.env.STRIPE_WEBHOOK_SECRET!);

  await handleStripeEvent(event, stripe, prisma);

  return c.json({ received: true });
});

Mounted at app.route("/api/webhooks", stripeWebhookRoutes) in backends/gateway/src/app.ts, so the public path is POST /api/webhooks/stripe. There is no @nebutra/billing/stripe webhook-handling export — application code does not call into this route; it only reads what it wrote (subscription status, payment orders).

Step 5: Billing portal

Customers can manage their subscription via the Stripe customer portal, using createBillingPortalSession from @nebutra/billing:

import { createBillingPortalSession } from "@nebutra/billing";

const session = await createBillingPortalSession(
  org.stripeCustomerId,
  `${process.env.WEB_URL}/settings/billing`,
);

redirect(session.url);

Stripe test cards

Card numberScenario
4242 4242 4242 4242Successful payment
4000 0000 0000 9995Insufficient funds
4000 0025 0000 31553D Secure authentication

Use any future expiry date and any 3-digit CVC.

Related

Creem

The current card rail — worldwide, merchant of record.

Billing Model

Plans, quotas, and metering.

Webhooks Guide

Full webhook setup and signature verification.

How is this guide?

Edit on GitHub

Last updated on

On this page

Prerequisites
Step 1: Set environment variables
Step 2: Create products in Stripe
Step 3: Configure webhook endpoint
Test webhooks locally
Step 4: Webhook handler
Step 5: Billing portal
Stripe test cards
Related