This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/mobile/services/subscriptionService.ts
caelum0x 54ca6de161 feat: round-4 product build-out (50 more gaps closed, all 7 green ~94-100%)
Second deep audit→build→verify pass; all products typecheck clean.

- gitgram-web (100): fix feed pagination, reel drafts, 6 gaps
- gitgram-backend (99): add admin/moderator role checks to moderation routes;
  wire backend-e2e CI (Postgres+Redis services); 5 gaps
- gitgram-mobile (97): fix broken create-reel flow; 11 gaps
- aitm-core (98): dedupe vendored CLI command registrations; real vector search
  with local fallback; 7 gaps
- aitm-api (99): replace hash-based embeddings with real OpenAI/Voyage embeddings
  (+ checkpoints test_status migration 0008); 8 gaps
- aitm-mcp (99): add X-API-Key to workspace tool proxy calls; 8 gaps
- aitm-website (94): fix annual billing checkout; 5 gaps

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 14:44:42 +03:00

87 lines
2.0 KiB
TypeScript

import api from './api';
export interface SubscriptionPlan {
id: string;
name: string;
price: string;
interval: string;
available: boolean;
features: string[];
}
export interface PlansResponse {
plans: SubscriptionPlan[];
currentPlan: string;
}
export const subscriptionService = {
getPlans: async (): Promise<PlansResponse> => {
const { data } = await api.get<PlansResponse>('/subscriptions/plans');
return data;
},
getSubscription: async (_subscriptionId?: string) => {
const { data } = await api.get('/subscriptions');
return data;
},
getMySubscriptions: async () => {
const { data } = await api.get('/subscriptions');
return { subscriptions: Array.isArray(data) ? data : [data].filter(Boolean) };
},
createCheckout: async (plan: string) => {
const { data } = await api.post('/subscriptions/checkout', { plan });
return data;
},
getCheckoutURL: async ({
productId,
quantity,
trialPeriodDays,
returnUrl,
}: {
productId: string;
quantity?: number;
trialPeriodDays?: number;
returnUrl?: string;
}) => {
const { data } = await api.post('/subscriptions/checkout', {
plan: productId,
productId,
quantity,
trialPeriodDays,
returnUrl,
});
return data.url || data.checkoutUrl || data.paymentLink;
},
cancelSubscription: async (_subscriptionId?: string) => {
const { data } = await api.delete('/subscriptions');
return data;
},
changePlan: async (
subscriptionId: string,
payload: { productId: string; prorationBillingMode?: string }
) => {
const { data } = await api.post('/subscriptions/checkout', {
plan: payload.productId,
subscriptionId,
...payload,
});
return data;
},
updatePaymentMethod: async (
subscriptionId: string,
payload: { type: 'new' | 'existing'; returnUrl?: string }
) => {
const { data } = await api.post('/subscriptions/checkout', {
subscriptionId,
...payload,
});
return data;
},
};