Skip to content

Commit e8c2023

Browse files
committed
zen: coupons
1 parent 1770162 commit e8c2023

13 files changed

Lines changed: 2741 additions & 10 deletions

File tree

infra/console.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,27 @@ const zenLiteCouponFirstMonth100 = new stripe.Coupon("ZenLiteCouponFirstMonth100
115115
appliesToProducts: [zenLiteProduct.id],
116116
duration: "once",
117117
})
118+
const zenLiteCouponThreeMonths100 = new stripe.Coupon("ZenLiteCoupon3Months100", {
119+
name: "3 months 100% off",
120+
percentOff: 100,
121+
appliesToProducts: [zenLiteProduct.id],
122+
duration: "repeating",
123+
durationInMonths: 3,
124+
})
125+
const zenLiteCouponSixMonths100 = new stripe.Coupon("ZenLiteCoupon6Months100", {
126+
name: "6 months 100% off",
127+
percentOff: 100,
128+
appliesToProducts: [zenLiteProduct.id],
129+
duration: "repeating",
130+
durationInMonths: 6,
131+
})
132+
const zenLiteCouponTwelveMonths100 = new stripe.Coupon("ZenLiteCoupon12Months100", {
133+
name: "12 months 100% off",
134+
percentOff: 100,
135+
appliesToProducts: [zenLiteProduct.id],
136+
duration: "repeating",
137+
durationInMonths: 12,
138+
})
118139
const zenLitePrice = new stripe.Price("ZenLitePrice", {
119140
product: zenLiteProduct.id,
120141
currency: "usd",
@@ -131,6 +152,9 @@ const ZEN_LITE_PRICE = new sst.Linkable("ZEN_LITE_PRICE", {
131152
priceInr: 92900,
132153
firstMonth50Coupon: zenLiteCouponFirstMonth50.id,
133154
firstMonth100Coupon: zenLiteCouponFirstMonth100.id,
155+
threeMonths100Coupon: zenLiteCouponThreeMonths100.id,
156+
sixMonths100Coupon: zenLiteCouponSixMonths100.id,
157+
twelveMonths100Coupon: zenLiteCouponTwelveMonths100.id,
134158
},
135159
})
136160

packages/console/app/src/routes/stripe/webhook.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,16 @@ export async function POST(input: APIEvent) {
160160
userID: userID,
161161
})
162162

163-
if (userEmail && coupon === LiteData.firstMonth100Coupon) {
164-
await Billing.redeemCoupon(userEmail, "GOFREEMONTH")
163+
if (userEmail) {
164+
if (coupon === LiteData.firstMonth100Coupon) {
165+
await Billing.redeemCoupon(userEmail, "GOFREEMONTH")
166+
} else if (coupon === LiteData.threeMonths100Coupon) {
167+
await Billing.redeemCoupon(userEmail, "GO3MONTHS100")
168+
} else if (coupon === LiteData.sixMonths100Coupon) {
169+
await Billing.redeemCoupon(userEmail, "GO6MONTHS100")
170+
} else if (coupon === LiteData.twelveMonths100Coupon) {
171+
await Billing.redeemCoupon(userEmail, "GO12MONTHS100")
172+
}
165173
}
166174
})
167175
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `coupon` MODIFY COLUMN `type` enum('BUILDATHON','GOFREEMONTH','GO3MONTHS100','GO6MONTHS100','GO12MONTHS100') NOT NULL;

0 commit comments

Comments
 (0)