Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update create-stripe-promotion-code.ts

Kiran K257e0a110336
diff --git a/apps/web/lib/stripe/create-stripe-promotion-code.ts b/apps/web/lib/stripe/create-stripe-promotion-code.ts
index 711e2a4171..0964688218 100644
--- a/apps/web/lib/stripe/create-stripe-promotion-code.ts
+++ b/apps/web/lib/stripe/create-stripe-promotion-code.ts
@@ -14,9 +14,19 @@ export async function createStripePromotionCode({
link,
}: {
workspace: Pick<WorkspaceProps, "id" | "stripeConnectId">;
- discount: Pick<DiscountProps, "id" | "couponId" | "amount" | "type">;
+ discount: Pick<
+ DiscountProps,
+ "id" | "couponId" | "amount" | "type" | "couponCodeTrackingEnabledAt"
+ >;
link: Pick<LinkProps, "id" | "key" | "couponCode">;
}) {
+ if (!discount.couponCodeTrackingEnabledAt) {
+ console.log(
+ `Coupon code tracking is not enabled for discount ${discount.id}. Stripe promotion code creation skipped.`,
+ );
+ return;
+ }
+
if (link.couponCode) {
console.log(
`Promotion code ${link.couponCode} already exists for link ${link.id}. Stripe promotion code creation skipped.`,