summaryrefslogtreecommitdiffhomepage
path: root/cloud/app/src/routes/stripe/webhook.ts
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-09-02 20:01:11 -0400
committerFrank <[email protected]>2025-09-02 20:01:13 -0400
commit4e629c5b64d52f6633e5e1a54d250b4b57c92604 (patch)
treea786a64484e161b4d2f0ac25a97bb3fa874cb861 /cloud/app/src/routes/stripe/webhook.ts
parent4624f0a260c36d55756b6f53641daacb878f9d92 (diff)
downloadopencode-4e629c5b64d52f6633e5e1a54d250b4b57c92604.tar.gz
opencode-4e629c5b64d52f6633e5e1a54d250b4b57c92604.zip
wip: cloud
Diffstat (limited to 'cloud/app/src/routes/stripe/webhook.ts')
-rw-r--r--cloud/app/src/routes/stripe/webhook.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/cloud/app/src/routes/stripe/webhook.ts b/cloud/app/src/routes/stripe/webhook.ts
index 61d14a645..592f4568d 100644
--- a/cloud/app/src/routes/stripe/webhook.ts
+++ b/cloud/app/src/routes/stripe/webhook.ts
@@ -24,8 +24,11 @@ export async function POST(input: APIEvent) {
if (!workspaceID) throw new Error("Workspace ID not found")
if (!customerID) throw new Error("Customer ID not found")
if (!amount) throw new Error("Amount not found")
+ if (amount !== 2118) throw new Error("Amount mismatch")
if (!paymentID) throw new Error("Payment ID not found")
+ const chargedAmount = 2000
+
await Actor.provide("system", { workspaceID }, async () => {
const customer = await Billing.get()
if (customer?.customerID && customer.customerID !== customerID) throw new Error("Customer ID mismatch")
@@ -50,7 +53,7 @@ export async function POST(input: APIEvent) {
await tx
.update(BillingTable)
.set({
- balance: sql`${BillingTable.balance} + ${centsToMicroCents(amount)}`,
+ balance: sql`${BillingTable.balance} + ${centsToMicroCents(chargedAmount)}`,
customerID,
paymentMethodID: paymentMethod.id,
paymentMethodLast4: paymentMethod.card!.last4,
@@ -59,7 +62,7 @@ export async function POST(input: APIEvent) {
await tx.insert(PaymentTable).values({
workspaceID,
id: Identifier.create("payment"),
- amount: centsToMicroCents(amount),
+ amount: centsToMicroCents(chargedAmount),
paymentID,
customerID,
})