diff options
| author | Frank <[email protected]> | 2026-01-05 18:09:37 -0500 |
|---|---|---|
| committer | Frank <[email protected]> | 2026-01-05 18:09:39 -0500 |
| commit | cf069dd046d0a91dde33e4e5c3e02771b8a19cf6 (patch) | |
| tree | 65890f391880ff26d9ed2f8ee0dbe0b8ab4291f7 /packages/console/core/src | |
| parent | 4dc3cb911551563a5e648e4baa58bac3e8a994df (diff) | |
| download | opencode-cf069dd046d0a91dde33e4e5c3e02771b8a19cf6.tar.gz opencode-cf069dd046d0a91dde33e4e5c3e02771b8a19cf6.zip | |
wip: zen
Diffstat (limited to 'packages/console/core/src')
| -rw-r--r-- | packages/console/core/src/billing.ts | 18 |
1 files changed, 18 insertions, 0 deletions
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 |
