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.

fix stripe coupon creation currency

Steven Teye9e68941fc76
diff --git a/apps/web/lib/stripe/coupon-discount-converter.ts b/apps/web/lib/stripe/coupon-discount-converter.ts
index 5f03eb669d..94cd1da19e 100644
--- a/apps/web/lib/stripe/coupon-discount-converter.ts
+++ b/apps/web/lib/stripe/coupon-discount-converter.ts
@@ -31,7 +31,6 @@ export function dubDiscountToStripeCoupon(
}
const stripeCouponData: Stripe.CouponCreateParams = {
- currency: "usd",
duration,
...(duration === "repeating" &&
durationInMonths && {
@@ -39,7 +38,8 @@ export function dubDiscountToStripeCoupon(
}),
...(discount.type === "percentage"
? { percent_off: discount.amount }
- : { amount_off: discount.amount }),
+ : // `currency` is required if amount_off is passed: https://docs.stripe.com/api/coupons/create#create_coupon-currency
+ { amount_off: discount.amount, currency: "usd" }),
...(discount.name && { name: discount.name }),
};