mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-09 15:22:39 +02:00
feat(billing): add direct Stripe billing portal access
Replace dashboard redirect with Stripe Customer Portal session for the "Manage in Stripe" button, so users go directly to Stripe to manage invoices, payment methods, and billing details. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9c010dabd8
commit
309c05782e
4 changed files with 34 additions and 4 deletions
|
|
@ -11,6 +11,19 @@ export interface BillingInfo {
|
|||
availableCredits: number;
|
||||
}
|
||||
|
||||
export async function getBillingPortalUrl(): Promise<string> {
|
||||
const accessToken = await getAccessToken();
|
||||
const response = await fetch(`${API_URL}/v1/billing/portal-session`, {
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Portal session failed: ${response.status}`);
|
||||
}
|
||||
const body = await response.json() as { url: string };
|
||||
return body.url;
|
||||
}
|
||||
|
||||
export async function getBillingInfo(): Promise<BillingInfo> {
|
||||
const accessToken = await getAccessToken();
|
||||
const response = await fetch(`${API_URL}/v1/me`, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue