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.

Add support for discount code restrictions (#3955)

Steven Teyf4b5a401f853
diff --git a/apps/web/lib/discounts/discount-provider-stripe.ts b/apps/web/lib/discounts/discount-provider-stripe.ts
index f96449dfc3..a4b721a5dd 100644
--- a/apps/web/lib/discounts/discount-provider-stripe.ts
+++ b/apps/web/lib/discounts/discount-provider-stripe.ts
@@ -161,7 +161,8 @@ function createStripeDiscountProvider() {
coupon: discount.couponId,
code: currentCode.toUpperCase(),
restrictions: {
- first_time_transaction: true,
+ first_time_transaction:
+ settings.discountCodeRestrictions.firstTimeTransaction,
},
},
{
diff --git a/apps/web/lib/integrations/stripe/schema.ts b/apps/web/lib/integrations/stripe/schema.ts
index 51c97ec785..ac9568c208 100644
--- a/apps/web/lib/integrations/stripe/schema.ts
+++ b/apps/web/lib/integrations/stripe/schema.ts
@@ -1,6 +1,7 @@
import * as z from "zod/v4";
export const stripeIntegrationSettingsSchema = z.object({
+ stripeMode: z.enum(["live", "test", "sandbox"]).optional().default("live"),
freeTrials: z
.object({
enabled: z
@@ -15,5 +16,11 @@ export const stripeIntegrationSettingsSchema = z.object({
),
})
.nullish(),
- stripeMode: z.enum(["live", "test", "sandbox"]).optional().default("live"),
+ discountCodeRestrictions: z
+ .object({
+ firstTimeTransaction: z.boolean().default(true),
+ })
+ .default({
+ firstTimeTransaction: true,
+ }),
});