Part of epic #100.
Function to ship
create-paypal-subscription
- Browser caller:
src/lib/payments/paypal.ts:145
- Request body:
{ plan_id: string, customer_email: string }
- Logic:
- CORS + auth
- Get PayPal access token
- POST
/v1/billing/subscriptions with the plan_id (created beforehand in PayPal dashboard) and approval URLs
- Write
subscriptions row with provider='paypal', status='pending', customer_email
- Return
{ subscription_id: response.id, approval_url: response.links.find(l => l.rel === 'approve').href }
- Browser redirects user to
approval_url. The existing paypal-webhook handles BILLING.SUBSCRIPTION.ACTIVATED to flip the DB row's status to active. No changes needed there.
Tests
- Deno unit tests mocking PayPal REST
- Un-skip
tests/e2e/payment/02-paypal-subscription.spec.ts:3 (subscription creation test)
Acceptance
🤖 Created from audit on 2026-05-20
Part of epic #100.
Function to ship
create-paypal-subscriptionsrc/lib/payments/paypal.ts:145{ plan_id: string, customer_email: string }/v1/billing/subscriptionswith theplan_id(created beforehand in PayPal dashboard) and approval URLssubscriptionsrow withprovider='paypal',status='pending',customer_email{ subscription_id: response.id, approval_url: response.links.find(l => l.rel === 'approve').href }approval_url. The existingpaypal-webhookhandlesBILLING.SUBSCRIPTION.ACTIVATEDto flip the DB row'sstatustoactive. No changes needed there.Tests
tests/e2e/payment/02-paypal-subscription.spec.ts:3(subscription creation test)Acceptance
supabase/functions/create-paypal-subscription/index.tsSubscriptionManager→ PayPal sandbox → returns to/payment-result→subscriptionsrow activated via webhook🤖 Created from audit on 2026-05-20