Stripe
Version 0.0.1 · Owners: @benallfree
Stripe is a payment processor for Billing. Buyers pay on Stripe's hosted Checkout page, Stripe's webhooks keep Billing's items current, and owners manage cards and invoices in Stripe's Customer Portal.
With Managed Payments on (the default), Stripe sells as merchant of record: it collects and files sales tax and VAT, handles disputes, and buyers see "Sold through Link" on their receipts. Turn it off to sell as yourself.
Install · Configure · Use · Integrations · Example
Install
extkit.Setup(app, []extkit.Extension{settings.New(), billing.New(billing.Config{}), stripe.New(stripe.Config{})}, nil, nil)
The module is pocketone.dev/ext/stripe. It talks to Stripe's API over plain HTTP, with no Stripe SDK, and pins
API version 2026-04-22.dahlia.
Configure
Open Billing → Settings in the dashboard. Stripe's section is below Billing's own.
| Setting | What it does |
|---|---|
| Secret key | Your Stripe secret key. A test key (sk_test_) uses Stripe's sandbox. A restricted key (rk_) works when it can write Checkout Sessions, subscriptions and refunds and read prices, customers, invoices and payments. |
| Webhook signing secret | The whsec_ secret of the webhook endpoint below. |
| Managed Payments | Stripe sells as merchant of record for new checkouts. Subscriptions that started without it renew as they are. |
Test checks the key with one read call.
In Stripe, add a webhook endpoint (Developers → Webhooks) at the webhook URL shown on the settings page
(<your app>/api/_c/billing/v1/webhook?provider=stripe), with these events:
checkout.session.completed,checkout.session.async_payment_succeededcustomer.subscription.created,customer.subscription.updated,customer.subscription.deleted,customer.subscription.paused,customer.subscription.resumedinvoice.paid,invoice.payment_failedcharge.refunded,charge.dispute.created,charge.dispute.closed
On your own machine, the Stripe CLI forwards them instead:
stripe listen --forward-to 'localhost:8090/api/_c/billing/v1/webhook?provider=stripe' \
--events checkout.session.completed,checkout.session.async_payment_succeeded,customer.subscription.created,customer.subscription.updated,customer.subscription.deleted,customer.subscription.paused,customer.subscription.resumed,invoice.paid,invoice.payment_failed,charge.refunded,charge.dispute.created,charge.dispute.closed
and prints the signing secret to paste.
Each product on Billing → Products names its Stripe price: prices: {"stripe": "price_..."}. A subscription
product needs a recurring price, a one-time product a one-time price; Check prices tells you if one doesn't match.
Use
Billing is the API; this extension only answers it. What Billing's calls do at Stripe:
| Billing | Stripe |
|---|---|
checkout |
A Checkout Session for the product's price and quantity, client_reference_id set to Billing's checkout. The buyer's email is filled in, or their Stripe customer when they bought before. |
portal |
A Customer Portal session for the owner's Stripe customer. |
cancel |
cancel_at_period_end, or cancels now. |
resume |
Clears a scheduled cancel. |
quantity, plan |
Updates the subscription's item; proration now invoices the difference at once, next_period adds it to the next invoice, none doesn't prorate. |
refund |
A refund of a one-time purchase, or of a subscription's latest paid invoice. |
A one-time purchase is identified by its PaymentIntent (pi_...), which refunds and disputes name. A subscription
in Stripe's incomplete or unpaid state grants nothing until it's paid.
Integrations
| Extension | How they fit |
|---|---|
| Billing | Stripe provides payments/v1, the processor contract Billing uses. Several processors can be installed; Billing's settings pick the one that takes new checkouts. |
| Settings | Stripe's settings are a section on Billing → Settings. |
| KV | The keys are stored privately in the key-value store, never readable over its API. |
Example
// Command example runs one PocketOne app that sells through Stripe: billing (ext/billing) with Stripe as its only
// processor.
//
// go run ./example serve
//
// Then, in the dashboard ([email protected] / password): Billing → Settings, paste a test secret key (sk_test_...),
// and add a product on Billing → Products with prices {"stripe": "price_..."}. For webhooks on your machine, run
// `stripe listen --forward-to 'localhost:8090/api/_c/billing/v1/webhook?provider=stripe' --events <the README's list>`
// and paste the signing secret it prints. As [email protected], POST /api/_c/billing/v1/checkout {"product": "<key>"},
// open the URL it returns and pay with card 4242 4242 4242 4242.
//
// Logins (ext/devusers, local testing only): dashboard [email protected] / password, app user [email protected] / password.
package main
import (
"log"
"ganigeorgiev.com/pocketbase/pocketbase"
"pocketone.dev/ext/billing"
"pocketone.dev/ext/devusers"
"pocketone.dev/ext/extkit"
"pocketone.dev/ext/settings"
"pocketone.dev/ext/stripe"
)
func main() {
app := pocketbase.New()
devusers.Register(app) // local testing: superuser [email protected] and user [email protected], password "password"
exts := []extkit.Extension{settings.New(), billing.New(billing.Config{}), stripe.New(stripe.Config{})}
if _, err := extkit.Setup(app, exts, nil, nil); err != nil {
log.Fatal(err)
}
if err := app.Start(); err != nil {
log.Fatal(err)
}
}
License
MIT
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.