Subscriptions and credit top-ups that charge once, verify server-side, and never double-credit.
We take your existing Next.js + Supabase site and wire in Pocketsflow end to end: checkout for plans and USD top-ups, HMAC-verified webhooks, idempotent ledger writes, an admin billing dashboard, and a customer billing portal. Built on Voxly, a credits-based AI voice & podcast SaaS, to show exactly what ships.
Checkout
Creator — $29/mo
Live webhook timeline
How a payment becomes credits
Five server-side steps stand between a Pocketsflow checkout and a credit balance that can be trusted.
1. Checkout
Customer pays by card or Google Pay on the Pocketsflow checkout.
2. Webhook fires
Pocketsflow POSTs the event to our billing webhook endpoint.
3. Signature verified
HMAC-SHA256 signature checked server-side before anything else.
4. Stored once
Event upserted in Supabase with a unique event_id — no duplicates.
5. Credits added
Ledger entry inserted, balance updated, confirmation email sent.
Idempotency, live
Same webhook, sent twice. Only the first one counts.
Balance
1,340 cr
What's in scope
Every card below is a real, working interface in this prototype.
2 interfaces, one application
Choose your role to explore the prototype.
The handler, in short
Verify the signature, upsert the event with a unique constraint, then credit the ledger. That order never changes.
// app/api/webhooks/pocketsflow/route.ts
const signature = req.headers.get("pf-signature");
const ok = verifyHmacSha256(rawBody, signature, env.PF_WEBHOOK_SECRET);
if (!ok) return new Response("invalid signature", { status: 400 });
// idempotent write — event_id is a unique column
const { data: row } = await supabase
.from("billing_events")
.upsert({ event_id: event.id, type: event.type, payload: event }, {
onConflict: "event_id", ignoreDuplicates: true,
})\n .select()\n .maybeSingle();
if (!row) return Response.json({ outcome: "duplicate_skipped" });
// first time we see this event — credit the ledger
await supabase.from("credit_ledger").insert({
customer_id: event.customer_id, amount: event.credits, source: "topup",
});
return Response.json({ outcome: "processed" });Frequently asked
Cards and Google Pay, both confirmed as available on the Pocketsflow account used for this integration. Apple Pay can be added later if Pocketsflow enables it on your account.
See the whole billing flow, live.
Click through checkout, the webhook log, and the admin dashboard exactly as your customers and your team would.