diff --git a/llm-fe/MONETIZATION.md b/llm-fe/MONETIZATION.md index 13d6ca6..3ab2589 100644 --- a/llm-fe/MONETIZATION.md +++ b/llm-fe/MONETIZATION.md @@ -4,10 +4,10 @@ | Runtime | Checkout / manage | Ledger | |---------|-------------------|--------| -| Web (`!isNativePlatform`) | Stripe Checkout + Customer Portal via `/finance/...` | Stripe webhooks | +| 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 `/finance/invoices/` (and subscription) returns after refresh. Provider badge uses `provider` + `revenuecat_store`. +FE displays whatever `/monetization/invoices/` (and subscription) returns after refresh. Provider badge uses `provider` + `revenuecat_store`. ## App user id diff --git a/llm-fe/src/llm-fe/components/BillingSection/BillingSection.test.tsx b/llm-fe/src/llm-fe/components/BillingSection/BillingSection.test.tsx index 5f92429..df1f3c1 100644 --- a/llm-fe/src/llm-fe/components/BillingSection/BillingSection.test.tsx +++ b/llm-fe/src/llm-fe/components/BillingSection/BillingSection.test.tsx @@ -157,16 +157,16 @@ const mockFinanceGets = ({ plans?: unknown[]; } = {}) => { mockGet.mockImplementation((url: string) => { - if (url === '/finance/invoices/') { + if (url === '/monetization/invoices/') { return Promise.resolve({ data: invoices }); } - if (url === '/finance/payments/') { + if (url === '/monetization/payments/') { return Promise.resolve({ data: payments }); } - if (url === '/finance/subscription/') { + if (url === '/monetization/subscription/') { return Promise.resolve({ data: subscription }); } - if (url === '/finance/plans/') { + if (url === '/monetization/plans/') { return Promise.resolve({ data: plans }); } return Promise.reject(new Error(`unexpected GET ${url}`)); @@ -246,7 +246,7 @@ describe('BillingSection', () => { await user.click(screen.getByRole('button', { name: /Change plan/i })); await waitFor(() => { - expect(mockPost).toHaveBeenCalledWith('/finance/portal/', { + expect(mockPost).toHaveBeenCalledWith('/monetization/portal/', { return_url: 'http://localhost/account/', }); }); @@ -321,7 +321,7 @@ describe('BillingSection', () => { await waitFor(() => { expect(mockPost).toHaveBeenCalledWith( - '/finance/checkout/', + '/monetization/checkout/', expect.objectContaining({ success_url: expect.stringContaining('/billing/success'), cancel_url: expect.stringContaining('/billing/cancel'), @@ -378,7 +378,7 @@ describe('BillingSection', () => { expect(mockPurchasePlan).toHaveBeenCalled(); }); expect(mockPost).not.toHaveBeenCalledWith( - '/finance/checkout/', + '/monetization/checkout/', expect.anything() ); }); diff --git a/llm-fe/src/llm-fe/components/BillingSection/BillingSection.tsx b/llm-fe/src/llm-fe/components/BillingSection/BillingSection.tsx index 92dbd78..04eff29 100644 --- a/llm-fe/src/llm-fe/components/BillingSection/BillingSection.tsx +++ b/llm-fe/src/llm-fe/components/BillingSection/BillingSection.tsx @@ -292,10 +292,10 @@ const BillingSection = (): JSX.Element => { try { const [invoiceResponse, paymentResponse, subscriptionResponse, plansResponse] = await Promise.all([ - axiosInstance.get('/finance/invoices/'), - axiosInstance.get('/finance/payments/'), - axiosInstance.get('/finance/subscription/'), - axiosInstance.get('/finance/plans/'), + axiosInstance.get('/monetization/invoices/'), + axiosInstance.get('/monetization/payments/'), + axiosInstance.get('/monetization/subscription/'), + axiosInstance.get('/monetization/plans/'), ]); setInvoices(Array.isArray(invoiceResponse.data) ? invoiceResponse.data : []); setPayments(Array.isArray(paymentResponse.data) ? paymentResponse.data : []); @@ -385,7 +385,7 @@ const BillingSection = (): JSX.Element => { try { const returnUrl = `${window.location.origin}/account/`; const response = await axiosInstance.post<{ portal_url: string }>( - '/finance/portal/', + '/monetization/portal/', { return_url: returnUrl } ); const portalUrl = response.data?.portal_url; @@ -461,7 +461,7 @@ const BillingSection = (): JSX.Element => { ...(planSlug ? { plan_slug: planSlug } : {}), }); const response = await axiosInstance.post<{ checkout_url: string }>( - '/finance/checkout/', + '/monetization/checkout/', { success_url, cancel_url, diff --git a/llm-fe/src/llm-fe/components/Header2/Header2.test.tsx b/llm-fe/src/llm-fe/components/Header2/Header2.test.tsx index 0eb01dd..d23b052 100644 --- a/llm-fe/src/llm-fe/components/Header2/Header2.test.tsx +++ b/llm-fe/src/llm-fe/components/Header2/Header2.test.tsx @@ -86,7 +86,7 @@ describe('Header2 (#81 subscription-aware Documents nav link)', () => { renderHeader(); - await waitFor(() => expect(mockGet).toHaveBeenCalledWith('/finance/subscription/')); + await waitFor(() => expect(mockGet).toHaveBeenCalledWith('/monetization/subscription/')); expect(screen.queryByText('Documents')).not.toBeInTheDocument(); }); diff --git a/llm-fe/src/llm-fe/components/UsageSummaryCard/UsageSummaryCard.tsx b/llm-fe/src/llm-fe/components/UsageSummaryCard/UsageSummaryCard.tsx index b0274dc..b1ae56c 100644 --- a/llm-fe/src/llm-fe/components/UsageSummaryCard/UsageSummaryCard.tsx +++ b/llm-fe/src/llm-fe/components/UsageSummaryCard/UsageSummaryCard.tsx @@ -174,8 +174,8 @@ const UsageSummaryCard = (): JSX.Element => { setLoading(true); try { const [subscriptionResponse, invoiceResponse] = await Promise.all([ - axiosInstance.get('/finance/subscription/'), - axiosInstance.get('/finance/invoices/'), + axiosInstance.get('/monetization/subscription/'), + axiosInstance.get('/monetization/invoices/'), ]); setSubscription(subscriptionResponse.data || null); setHasPortalAccess( @@ -231,7 +231,7 @@ const UsageSummaryCard = (): JSX.Element => { try { const returnUrl = `${window.location.origin}/account/`; const response = await axiosInstance.post<{ portal_url: string }>( - '/finance/portal/', + '/monetization/portal/', { return_url: returnUrl } ); if (response.data?.portal_url) { diff --git a/llm-fe/src/llm-fe/hooks/useSubscription.ts b/llm-fe/src/llm-fe/hooks/useSubscription.ts index 2a45284..adc3aba 100644 --- a/llm-fe/src/llm-fe/hooks/useSubscription.ts +++ b/llm-fe/src/llm-fe/hooks/useSubscription.ts @@ -6,7 +6,7 @@ import { planAllowsRag, SubscriptionMe } from '../utils/finance'; /** * Module-level cache so every component that calls useSubscription() during the - * same session shares one /finance/subscription/ request instead of each + * same session shares one /monetization/subscription/ request instead of each * mounting its own (e.g. Header2 + DocumentStoragePage on the same page). */ let cachedSubscription: SubscriptionMe | null = null; @@ -18,7 +18,7 @@ async function loadSubscription(): Promise { } if (!inFlightRequest) { inFlightRequest = axiosInstance - .get('/finance/subscription/') + .get('/monetization/subscription/') .then((response: AxiosResponse) => { cachedSubscription = response.data || null; return cachedSubscription; @@ -44,7 +44,7 @@ export type UseSubscriptionResult = { refresh: () => Promise; }; -/** Fetches /finance/subscription/ once per session (shared across callers) and exposes plan-derived flags. */ +/** Fetches /monetization/subscription/ once per session (shared across callers) and exposes plan-derived flags. */ export function useSubscription(): UseSubscriptionResult { const { authenticated } = useContext(AuthContext); const [subscription, setSubscription] = useState(cachedSubscription); diff --git a/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.test.tsx b/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.test.tsx index cd3f52c..9f195c0 100644 --- a/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.test.tsx +++ b/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.test.tsx @@ -133,7 +133,7 @@ describe('AuthCallback', () => { await waitFor(() => { expect(mockPost).toHaveBeenCalledWith( - '/finance/checkout/', + '/monetization/checkout/', expect.objectContaining({ success_url: expect.stringContaining('/billing/success'), cancel_url: expect.stringContaining('/billing/cancel'), diff --git a/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.tsx b/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.tsx index a6ea380..8cb1cd4 100644 --- a/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.tsx +++ b/llm-fe/src/llm-fe/pages/AuthCallback/AuthCallback.tsx @@ -181,7 +181,7 @@ const AuthCallback = (): JSX.Element => { setStatusText('Starting checkout…'); const { success_url, cancel_url } = checkoutReturnUrls(); trackEvent(AnalyticsEvents.CHECKOUT_STARTED, { source: 'sso_signup' }); - const checkoutResponse = await axiosInstance.post('/finance/checkout/', { + const checkoutResponse = await axiosInstance.post('/monetization/checkout/', { success_url, cancel_url, }); diff --git a/llm-fe/src/llm-fe/pages/DocumentStoragePage/DocumentStoragePage.test.tsx b/llm-fe/src/llm-fe/pages/DocumentStoragePage/DocumentStoragePage.test.tsx index 13609f4..d818db1 100644 --- a/llm-fe/src/llm-fe/pages/DocumentStoragePage/DocumentStoragePage.test.tsx +++ b/llm-fe/src/llm-fe/pages/DocumentStoragePage/DocumentStoragePage.test.tsx @@ -60,7 +60,7 @@ const subscriptionResponse = (rag: boolean) => ({ const mockGetByUrl = (overrides: { rag: boolean }) => { mockGet.mockImplementation((url: string) => { - if (url === '/finance/subscription/') { + if (url === '/monetization/subscription/') { return Promise.resolve(subscriptionResponse(overrides.rag)); } if (typeof url === 'string' && url.startsWith('/documents/')) { diff --git a/llm-fe/src/llm-fe/pages/SignUp/SignUp.test.tsx b/llm-fe/src/llm-fe/pages/SignUp/SignUp.test.tsx index b0a3986..c480d32 100644 --- a/llm-fe/src/llm-fe/pages/SignUp/SignUp.test.tsx +++ b/llm-fe/src/llm-fe/pages/SignUp/SignUp.test.tsx @@ -139,7 +139,7 @@ describe('SignUp', () => { }); await waitFor(() => { - expect(mockPost).toHaveBeenCalledWith('/finance/checkout/', { + expect(mockPost).toHaveBeenCalledWith('/monetization/checkout/', { success_url: 'http://localhost/billing/success?session_id={CHECKOUT_SESSION_ID}', cancel_url: 'http://localhost/billing/cancel', }); diff --git a/llm-fe/src/llm-fe/pages/SignUp/SignUp.tsx b/llm-fe/src/llm-fe/pages/SignUp/SignUp.tsx index b32df98..7fa5d02 100644 --- a/llm-fe/src/llm-fe/pages/SignUp/SignUp.tsx +++ b/llm-fe/src/llm-fe/pages/SignUp/SignUp.tsx @@ -271,7 +271,7 @@ const SignUp = (): JSX.Element => { const { success_url, cancel_url } = checkoutReturnUrls(); trackEvent(AnalyticsEvents.CHECKOUT_STARTED, { source: 'signup' }); - const checkoutResponse = await axiosInstance.post('/finance/checkout/', { + const checkoutResponse = await axiosInstance.post('/monetization/checkout/', { success_url, cancel_url, });