summaryrefslogtreecommitdiffhomepage
path: root/packages/console/app
diff options
context:
space:
mode:
Diffstat (limited to 'packages/console/app')
-rw-r--r--packages/console/app/src/routes/stripe/webhook.ts7
-rw-r--r--packages/console/app/src/routes/workspace/[id]/billing/index.tsx2
2 files changed, 8 insertions, 1 deletions
diff --git a/packages/console/app/src/routes/stripe/webhook.ts b/packages/console/app/src/routes/stripe/webhook.ts
index 0d8cf61cf..c28d9ebbb 100644
--- a/packages/console/app/src/routes/stripe/webhook.ts
+++ b/packages/console/app/src/routes/stripe/webhook.ts
@@ -9,6 +9,7 @@ import { Actor } from "@opencode-ai/console-core/actor.js"
import { Resource } from "@opencode-ai/console-resource"
import { LiteData } from "@opencode-ai/console-core/lite.js"
import { BlackData } from "@opencode-ai/console-core/black.js"
+import { User } from "@opencode-ai/console-core/user.js"
export async function POST(input: APIEvent) {
const body = await Billing.stripe().webhooks.constructEventAsync(
@@ -109,6 +110,8 @@ export async function POST(input: APIEvent) {
if (type === "lite") {
const workspaceID = body.data.object.metadata?.workspaceID
const userID = body.data.object.metadata?.userID
+ const userEmail = body.data.object.metadata?.userEmail
+ const coupon = body.data.object.metadata?.coupon
const customerID = body.data.object.customer as string
const invoiceID = body.data.object.latest_invoice as string
const subscriptionID = body.data.object.id as string
@@ -156,6 +159,10 @@ export async function POST(input: APIEvent) {
id: Identifier.create("lite"),
userID: userID,
})
+
+ if (userEmail && coupon === LiteData.firstMonth100Coupon) {
+ await Billing.redeemCoupon(userEmail, "GOFREEMONTH")
+ }
})
})
}
diff --git a/packages/console/app/src/routes/workspace/[id]/billing/index.tsx b/packages/console/app/src/routes/workspace/[id]/billing/index.tsx
index fb4848535..11185436b 100644
--- a/packages/console/app/src/routes/workspace/[id]/billing/index.tsx
+++ b/packages/console/app/src/routes/workspace/[id]/billing/index.tsx
@@ -25,9 +25,9 @@ export default function () {
<Show when={billingInfo()?.customerID}>
<ReloadSection />
<MonthlyLimitSection />
+ <RedeemSection />
<PaymentSection />
</Show>
- <RedeemSection />
</Show>
</div>
</div>