## Summary - Native Capacitor: RevenueCat purchase/restore (`@revenuecat/purchases-capacitor`) - Web: Stripe checkout/portal unchanged - Billing history shows store rows (`provider` / `revenuecat_store`) - RC `logIn`/`logOut` on auth lifecycle; appUserID = user pk Closes #100. Depends on backend [chat_backend#68](ai_ml_operations/chat_backend#68) / monetization PR. ## Test plan - [x] Unit tests: BillingSection, revenueCat, finance helpers, SignIn/Up, AuthCallback, Header2, DeleteAccount (38 OK) - [ ] Fill `REACT_APP_REVENUECAT_*` keys in `.env.mobile` - [ ] Align RC offerings/products with plan slugs - [ ] `npm run build:mobile` + `cap sync`; sandbox purchase on Android/iOS - [ ] Confirm web Stripe checkout/portal still work - [ ] After RC webhook, Account → Billing history shows store invoiceReviewed-on: #102
1.5 KiB
1.5 KiB
Monetization (web Stripe + native RevenueCat)
Channels
| Runtime | Checkout / manage | Ledger |
|---|---|---|
Web (!isNativePlatform) |
Stripe Checkout + Customer Portal via /monetization/... |
Stripe webhooks |
| Native Capacitor | RevenueCat IAP (@revenuecat/purchases-capacitor) |
RevenueCat webhooks → same invoice/payment tables |
FE displays whatever /monetization/invoices/ (and subscription) returns after refresh. Provider badge uses provider + revenuecat_store.
App user id
RevenueCat appUserID = Django user pk as string.
- Prefer
idfrom/user/get/(serializer returns all model fields). - Else JWT
user_idclaim (SIMPLE_JWT.USER_ID_CLAIM).
Backend webhook resolver accepts numeric pk (or email fallback).
Mobile env keys
In .env.mobile:
REACT_APP_REVENUECAT_APPLE_API_KEYREACT_APP_REVENUECAT_GOOGLE_API_KEYREACT_APP_REVENUECAT_OFFERING_ID(optional)
Package identifiers in the RC dashboard should include plan slugs (e.g. founders) so purchasePlan(planSlug) can match packages/products. Optional backend REVENUECAT_PRODUCT_PLAN_MAP maps product id → plan slug.
Auth hooks
Purchases.configureonce on native (first purchase / logIn).logIn(appUserID)after SignIn / SignUp / AuthCallback / AccountContext load.logOuton Header2 sign-out and Delete account.
Related
- Issue #100 (FE) + companion backend RevenueCat webhook PR
ANDROID.md/IOS.mdfor store builds