Multi-tenant recurring membership billing with live ToyyibPay payments, Postgres RLS isolation, and cron-based subscription lifecycle management.
POST /api/webhooks/toyyibpay 200 OK · payment.success · RM 0.10
Each layer of the stack runs in production mode — no mock APIs, no faked data, no skipped parts.
Every org is scoped by Postgres Row Level Security. No cross-tenant data leakage — enforced at the database layer, not application logic.
Real RM 0.10 ToyyibPay transactions in production mode. Not sandbox — real charges that verify the end-to-end payment flow.
Every ToyyibPay callback is stored raw in webhook_logs before processing. Full audit trail, idempotent status updates.
Active → Overdue → Churned state machine. next_due_date advances on payment. Auto-churn triggers after N days overdue.
Supabase Edge Functions run daily, scanning for overdue members and triggering Resend email reminders without manual intervention.
Revenue calculated live from active plan subscriptions. Overdue and churn breakdowns surface the billing health of the org.
Exactly what runs when a member pays — no hand-waving.
POST createBill
ToyyibPay API · live mode
ToyyibPay payment page
Member enters card details
POST /api/webhooks/…
form-encoded callback · status=1
members.status = paid
Postgres update · RLS enforced
Webhook parsed as form-encoded
ToyyibPay sends application/x-www-form-urlencoded, not JSON. Most demos get this wrong.
Raw payload stored first
webhook_logs receives the raw callback before any processing. Idempotency key prevents double-processing.
Status chain is atomic
payments.status → paid and members.status → active happen in the same Postgres transaction.
Every tool chosen for real-world applicability.
No account needed. Create a workspace and explore the full lifecycle.