DocDoeAI / src /lib /api /billing.ts
asnannp's picture
deploy: sync backend to Space root (learn-lesson HF cache fix)
65d68f5
Raw History Blame Contribute Delete
788 Bytes
import { apiPost } from "@/lib/api/client";
import type { BillingMe } from "@/lib/api/types";
import type { ActivePaidBillingPlanKey } from "@/lib/billing/activePlans";
export type CheckoutSession = {
url: string;
session_id: string;
};
export type BillingPortalSession = {
url: string;
};
export function createCheckoutSession(plan: ActivePaidBillingPlanKey) {
return apiPost<CheckoutSession, { plan: ActivePaidBillingPlanKey }>(
"/billing/create-checkout-session",
{ plan },
);
}
export function startBillingTrial() {
return apiPost<BillingMe, Record<string, never>>("/billing/start-trial", {});
}
export function createBillingPortalSession() {
return apiPost<BillingPortalSession, Record<string, never>>(
"/billing/create-portal-session",
{},
);
}