From cf069dd046d0a91dde33e4e5c3e02771b8a19cf6 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 5 Jan 2026 18:09:37 -0500 Subject: wip: zen --- packages/console/core/src/billing.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'packages/console/core/src') diff --git a/packages/console/core/src/billing.ts b/packages/console/core/src/billing.ts index 049ee29bb..c14df11ae 100644 --- a/packages/console/core/src/billing.ts +++ b/packages/console/core/src/billing.ts @@ -157,6 +157,24 @@ export namespace Billing { }) } + export const grantCredit = async (workspaceID: string, dollarAmount: number) => { + const amountInMicroCents = centsToMicroCents(dollarAmount * 100) + await Database.transaction(async (tx) => { + await tx + .update(BillingTable) + .set({ + balance: sql`${BillingTable.balance} + ${amountInMicroCents}`, + }) + .where(eq(BillingTable.workspaceID, workspaceID)) + await tx.insert(PaymentTable).values({ + workspaceID, + id: Identifier.create("payment"), + amount: amountInMicroCents, + }) + }) + return amountInMicroCents + } + export const setMonthlyLimit = fn(z.number(), async (input) => { return await Database.use((tx) => tx -- cgit v1.2.3