Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Fix wrong promo code applied at checkout

Luke Vellad25c8ddaf338
diff --git a/apps/web/src/app/api/stripe/buy-license/route.ts b/apps/web/src/app/api/stripe/buy-license/route.ts
index dd4a6ffeb..e910bde92 100644
--- a/apps/web/src/app/api/stripe/buy-license/route.ts
+++ b/apps/web/src/app/api/stripe/buy-license/route.ts
@@ -51,12 +51,16 @@ export async function GET(request: NextRequest) {
const { type, seats, promoCode } = mapProductToLicenseType[product];
- const promotionCodes = await stripe.promotionCodes.list({
- code: promoCode,
- active: true,
- });
+ let promoCodeId: string | undefined;
+
+ if (promoCode) {
+ const promotionCodes = await stripe.promotionCodes.list({
+ code: promoCode,
+ active: true,
+ });
- const promoCodeId = promotionCodes.data[0]?.id;
+ promoCodeId = promotionCodes.data[0]?.id;
+ }
try {
const session = await stripe.checkout.sessions.create({