Blocks/Billing & Subscriptions
AdvancedMonetization

Billing & Subscriptions

One-time + recurring billing + invoices

PayPal REST API billing: one-time orders, monthly/yearly subscription plans, usage-based limits, refunds, HTML invoice generation, and webhook handler. Note: PayPal-only — adapt the patterns for your payment provider of choice.

18h
Time saved
405
Lines of code
100%
TypeScript
#subscriptions#billing#payments

Dependencies

resend

Code preview

blocks/billing/index.ts
1const sub = await createSubscription('pro_monthly', user.email)
2window.location.href = sub.links.find(l => l.rel === 'approve').href
3
4var(--text-3);font-style:italic">// Check plan limits:
5const limit = await getPlanLimit(userId, 'ai_calls')
6if (limit.used >= limit.max) throw new Error('Upgrade required')

Short excerpt. Full block includes SQL migrations, error handling, RLS policies, and complete file structure.

$39

One-time · Instant GitHub access

Instant GitHub repo access

Own the code forever

Free updates

30-day refund if it breaks

You might also like