mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-19 18:35:18 +02:00
Resolve stash merge conflicts: keep both inline-task and billing features
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e27a93d051
commit
27e8fe0f22
6 changed files with 117 additions and 0 deletions
38
apps/x/packages/core/src/billing/billing.ts
Normal file
38
apps/x/packages/core/src/billing/billing.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { getAccessToken } from '../models/gateway.js';
|
||||
import { ROWBOAT_BILLING_BASE_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<BillingInfo> {
|
||||
const accessToken = await getAccessToken();
|
||||
const response = await fetch(`${ROWBOAT_BILLING_BASE_URL}/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;
|
||||
};
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
|
@ -3,3 +3,6 @@ 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';
|
||||
|
|
|
|||
|
|
@ -516,6 +516,17 @@ const ipcSchemas = {
|
|||
]).nullable(),
|
||||
}),
|
||||
},
|
||||
// Billing channels
|
||||
'billing:getInfo': {
|
||||
req: z.null(),
|
||||
res: z.object({
|
||||
subscriptionPlan: z.string().nullable(),
|
||||
subscriptionStatus: z.string().nullable(),
|
||||
trialUsed: z.boolean(),
|
||||
sanctionedCredits: z.number(),
|
||||
availableCredits: z.number(),
|
||||
}),
|
||||
},
|
||||
} as const;
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue