-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
BackendBackend authenticationsBackend authenticationsP1-HighImportant for milestoneImportant for milestonePaymentPayment ProcessPayment ProcessenhancementNew feature or requestNew feature or requestsize:XL1+ month1+ month
Description
Description
Implement backend support for recurring subscriptions while keeping the existing
one-time donation flow fully intact. This includes new authenticated endpoints
for setup intents and subscription creation, per-campaign Stripe product and
price management, and webhook updates to persist subscription and invoice data
in Firestore.
Scope
Backend Endpoints
- Add
createSetupIntent.tsHTTPS function to:- Verify Firebase ID token
- Ensure or reuse a Stripe customer
- Return SetupIntent
clientSecretandcustomerIdfor saving payment methods
- Add
createSubscription.tsHTTPS function to:- Verify authentication
- Get or create a recurring Stripe price per campaign and interval
- Attach payment method to customer
- Create Stripe subscription
- Return subscription status or
paymentIntentClientSecretwhen 3DS is required
- Export new functions from
index.ts - Add shared request/response types in
subscription.ts(+ index export)
Subscription & Pricing Logic
Campaign Products
- Use a per-campaign Stripe product
- Store product ID on
{campaignId}.billingProductId - Create the product if missing, then reuse for all recurring prices
Pricing
- Support recurring intervals:
- Monthly (1 month)
- Quarterly (3 months)
- Yearly (1 year)
- Currency defaults to
EUR - Custom donation amounts supported:
- Server accepts amount in minor units
- Matching recurring price is created or reused on the campaign product
Webhook Integration
- Extend
handleStripeWebhook.tsto:- Upsert
subscriptions/{subscriptionId}documents - Upsert
donations/{invoiceId}documents for recurring invoices - Increment campaign totals once per successful invoice (idempotent)
- Upsert
- Preserve existing one-time donation handling for
payment_intent.succeededwithout changes
Acceptance Criteria
- SetupIntent endpoint implemented and authenticated
- Subscription creation endpoint implemented and authenticated
- Per-campaign Stripe product created and reused correctly
- Dynamic recurring prices supported per amount and interval
- Monthly, quarterly, and yearly subscriptions supported
- Webhook persists subscriptions and invoice-backed donations
- Campaign totals incremented idempotently
- One-time donation flow remains unchanged
- No regressions introduced
Notes
- Frontend wiring for recurring donations will be tracked separately
- Relies on existing Stripe webhook infrastructure and Firestore schema
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BackendBackend authenticationsBackend authenticationsP1-HighImportant for milestoneImportant for milestonePaymentPayment ProcessPayment ProcessenhancementNew feature or requestNew feature or requestsize:XL1+ month1+ month
Type
Projects
Status
Todo