feat: integrate Stripe for embedded checkout; update billing API to return client_secret and adjust checkout flow in components

This commit is contained in:
Usman Baig
2026-02-20 03:41:35 +01:00
parent 6d277b126e
commit 0bbbb8a1af
9 changed files with 291 additions and 29 deletions

View File

@@ -85,13 +85,24 @@ export interface CreateCheckoutParams {
limit: number
}
export async function createCheckoutSession(params: CreateCheckoutParams): Promise<{ url: string }> {
return await billingFetch<{ url: string }>('/api/billing/checkout', {
export async function createCheckoutSession(params: CreateCheckoutParams): Promise<{ client_secret: string }> {
return await billingFetch<{ client_secret: string }>('/api/billing/checkout', {
method: 'POST',
body: JSON.stringify(params),
})
}
export interface CheckoutSessionStatus {
status: string
customer_email: string
}
export async function getCheckoutSessionStatus(sessionId: string): Promise<CheckoutSessionStatus> {
return await billingFetch<CheckoutSessionStatus>(`/api/billing/checkout/session-status?session_id=${encodeURIComponent(sessionId)}`, {
method: 'GET',
})
}
export interface Invoice {
id: string
amount_paid: number