Files
chat_web_app/llm-fe/MONETIZATION.md
westfarn ce86f56d37
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Failing after 2m20s
RevenueCat Capacitor IAP; keep Stripe on web (#100) (#102)
## 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
2026-08-04 03:43:10 -07:00

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.

  1. Prefer id from /user/get/ (serializer returns all model fields).
  2. Else JWT user_id claim (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_KEY
  • REACT_APP_REVENUECAT_GOOGLE_API_KEY
  • REACT_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.configure once on native (first purchase / logIn).
  • logIn(appUserID) after SignIn / SignUp / AuthCallback / AccountContext load.
  • logOut on Header2 sign-out and Delete account.
  • Issue #100 (FE) + companion backend RevenueCat webhook PR
  • ANDROID.md / IOS.md for store builds