diff options
| author | Frank <[email protected]> | 2025-09-02 20:01:11 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-09-02 20:01:13 -0400 |
| commit | 4e629c5b64d52f6633e5e1a54d250b4b57c92604 (patch) | |
| tree | a786a64484e161b4d2f0ac25a97bb3fa874cb861 /cloud/core/src | |
| parent | 4624f0a260c36d55756b6f53641daacb878f9d92 (diff) | |
| download | opencode-4e629c5b64d52f6633e5e1a54d250b4b57c92604.tar.gz opencode-4e629c5b64d52f6633e5e1a54d250b4b57c92604.zip | |
wip: cloud
Diffstat (limited to 'cloud/core/src')
| -rw-r--r-- | cloud/core/src/billing.ts | 39 | ||||
| -rw-r--r-- | cloud/core/src/workspace.ts | 2 |
2 files changed, 2 insertions, 39 deletions
diff --git a/cloud/core/src/billing.ts b/cloud/core/src/billing.ts index 298d151f9..6f241ba06 100644 --- a/cloud/core/src/billing.ts +++ b/cloud/core/src/billing.ts @@ -52,43 +52,6 @@ export namespace Billing { ) } - export const consume = fn( - z.object({ - requestID: z.string().optional(), - model: z.string(), - inputTokens: z.number(), - outputTokens: z.number(), - reasoningTokens: z.number().optional(), - cacheReadTokens: z.number().optional(), - cacheWriteTokens: z.number().optional(), - costInCents: z.number(), - }), - async (input) => { - const workspaceID = Actor.workspace() - const cost = centsToMicroCents(input.costInCents) - - return await Database.transaction(async (tx) => { - await tx.insert(UsageTable).values({ - workspaceID, - id: Identifier.create("usage"), - model: input.model, - inputTokens: input.inputTokens, - outputTokens: input.outputTokens, - reasoningTokens: input.reasoningTokens, - cacheReadTokens: input.cacheReadTokens, - cacheWriteTokens: input.cacheWriteTokens, - cost, - }) - await tx - .update(BillingTable) - .set({ - balance: sql`${BillingTable.balance} - ${cost}`, - }) - .where(eq(BillingTable.workspaceID, workspaceID)) - }) - }, - ) - export const generateCheckoutUrl = fn( z.object({ successUrl: z.string(), @@ -109,7 +72,7 @@ export namespace Billing { product_data: { name: "opencode credits", }, - unit_amount: 2000, // $20 minimum + unit_amount: 2118, // $20 minimum + Stripe fee 4.4% + $0.30 }, quantity: 1, }, diff --git a/cloud/core/src/workspace.ts b/cloud/core/src/workspace.ts index 8646362a2..a9fb923d6 100644 --- a/cloud/core/src/workspace.ts +++ b/cloud/core/src/workspace.ts @@ -26,7 +26,7 @@ export namespace Workspace { await tx.insert(BillingTable).values({ workspaceID, id: Identifier.create("billing"), - balance: centsToMicroCents(100), + balance: 0, }) }) await Actor.provide( |
