This commit is contained in:
Frank
2025-10-31 14:42:18 -04:00
parent 4bde3f7b15
commit 021334509e
10 changed files with 1047 additions and 25 deletions

View File

@@ -13,7 +13,9 @@ export namespace Billing {
export const CHARGE_NAME = "opencode credits"
export const CHARGE_FEE_NAME = "processing fee"
export const CHARGE_AMOUNT = 2000 // $20
export const CHARGE_AMOUNT_DOLLAR = 20
export const CHARGE_FEE = 123 // Stripe fee 4.4% + $0.30
export const CHARGE_THRESHOLD_DOLLAR = 5
export const CHARGE_THRESHOLD = 500 // $5
export const stripe = () =>
new Stripe(Resource.STRIPE_SECRET_KEY.value, {
@@ -142,17 +144,6 @@ export namespace Billing {
})
}
export const disableReload = async () => {
return await Database.use((tx) =>
tx
.update(BillingTable)
.set({
reload: false,
})
.where(eq(BillingTable.workspaceID, Actor.workspace())),
)
}
export const setMonthlyLimit = fn(z.number(), async (input) => {
return await Database.use((tx) =>
tx

View File

@@ -16,6 +16,8 @@ export const BillingTable = mysqlTable(
monthlyUsage: bigint("monthly_usage", { mode: "number" }),
timeMonthlyUsageUpdated: utc("time_monthly_usage_updated"),
reload: boolean("reload"),
reloadTrigger: int("reload_trigger"),
reloadAmount: int("reload_amount"),
reloadError: varchar("reload_error", { length: 255 }),
timeReloadError: utc("time_reload_error"),
timeReloadLockedTill: utc("time_reload_locked_till"),