diff --git a/apps/x/apps/renderer/src/hooks/useBilling.ts b/apps/x/apps/renderer/src/hooks/useBilling.ts index d17897ee..49459fdb 100644 --- a/apps/x/apps/renderer/src/hooks/useBilling.ts +++ b/apps/x/apps/renderer/src/hooks/useBilling.ts @@ -3,7 +3,6 @@ import { useState, useEffect, useCallback } from 'react' interface BillingInfo { subscriptionPlan: string subscriptionStatus: string - trialUsed: boolean sanctionedCredits: number availableCredits: number } diff --git a/apps/x/packages/core/src/billing/billing.ts b/apps/x/packages/core/src/billing/billing.ts index 2b93cbd2..9b408f1c 100644 --- a/apps/x/packages/core/src/billing/billing.ts +++ b/apps/x/packages/core/src/billing/billing.ts @@ -1,38 +1,39 @@ import { getAccessToken } from '../models/gateway.js'; -import { ROWBOAT_BILLING_BASE_URL } from '../config/env.js'; +import { API_URL } from '../config/env.js'; export interface BillingInfo { subscriptionPlan: string | null; subscriptionStatus: string | null; - trialUsed: boolean; sanctionedCredits: number; availableCredits: number; } export async function getBillingInfo(): Promise { const accessToken = await getAccessToken(); - const response = await fetch(`${ROWBOAT_BILLING_BASE_URL}/me`, { + const response = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${accessToken}` }, }); if (!response.ok) { throw new Error(`Billing API failed: ${response.status}`); } const body = await response.json() as { - customer: { - subscriptionPlan: string | null; - subscriptionStatus: string | null; - trialUsed: boolean; + user: { + id: string; + email: string; }; - usage: { - sanctionedCredits: number; - availableCredits: number; + billing: { + plan: string | null; + status: string | null; + usage: { + sanctionedCredits: number; + availableCredits: number; + }; }; }; return { - subscriptionPlan: body.customer.subscriptionPlan, - subscriptionStatus: body.customer.subscriptionStatus, - trialUsed: body.customer.trialUsed, - sanctionedCredits: body.usage.sanctionedCredits, - availableCredits: body.usage.availableCredits, + subscriptionPlan: body.billing.plan, + subscriptionStatus: body.billing.status, + sanctionedCredits: body.billing.usage.sanctionedCredits, + availableCredits: body.billing.usage.availableCredits, }; } diff --git a/apps/x/packages/core/src/config/env.ts b/apps/x/packages/core/src/config/env.ts index cadf23df..2ec62881 100644 --- a/apps/x/packages/core/src/config/env.ts +++ b/apps/x/packages/core/src/config/env.ts @@ -3,6 +3,3 @@ export const API_URL = export const SUPABASE_PROJECT_URL = process.env.SUPABASE_PROJECT_URL || 'http://127.0.0.1:54321'; - -export const ROWBOAT_BILLING_BASE_URL = - process.env.ROWBOAT_BILLING_BASE_URL || 'https://billing.staging.x.rowboatlabs.com'; diff --git a/apps/x/packages/shared/src/ipc.ts b/apps/x/packages/shared/src/ipc.ts index edf01117..51ee5ff7 100644 --- a/apps/x/packages/shared/src/ipc.ts +++ b/apps/x/packages/shared/src/ipc.ts @@ -522,7 +522,6 @@ const ipcSchemas = { res: z.object({ subscriptionPlan: z.string().nullable(), subscriptionStatus: z.string().nullable(), - trialUsed: z.boolean(), sanctionedCredits: z.number(), availableCredits: z.number(), }),