From 4c282ea9caf11224238f071de57bd6a70671b989 Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Fri, 19 Dec 2025 12:57:13 +0100 Subject: [PATCH] feat: add promotion codes support to SMS credit purchases (#23774) Co-authored-by: peer@cal.com Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: CarinaWolli Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> --- .../billing/service/billingProvider/StripeBillingService.ts | 4 +++- .../trpc/server/routers/viewer/credits/buyCredits.handler.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/features/ee/billing/service/billingProvider/StripeBillingService.ts b/packages/features/ee/billing/service/billingProvider/StripeBillingService.ts index 5c1d2e44e1..c1bbda7262 100644 --- a/packages/features/ee/billing/service/billingProvider/StripeBillingService.ts +++ b/packages/features/ee/billing/service/billingProvider/StripeBillingService.ts @@ -44,8 +44,9 @@ export class StripeBillingService implements IBillingProviderService { successUrl: string; cancelUrl: string; metadata?: Record; + allowPromotionCodes?: boolean; }) { - const { priceId, quantity, successUrl, cancelUrl, metadata } = args; + const { priceId, quantity, successUrl, cancelUrl, metadata, allowPromotionCodes = true } = args; const session = await this.stripe.checkout.sessions.create({ line_items: [{ price: priceId, quantity }], @@ -53,6 +54,7 @@ export class StripeBillingService implements IBillingProviderService { success_url: successUrl, cancel_url: cancelUrl, metadata: metadata, + allow_promotion_codes: allowPromotionCodes, invoice_creation: { enabled: true, }, diff --git a/packages/trpc/server/routers/viewer/credits/buyCredits.handler.ts b/packages/trpc/server/routers/viewer/credits/buyCredits.handler.ts index f8dbab855f..f10e3a3d35 100644 --- a/packages/trpc/server/routers/viewer/credits/buyCredits.handler.ts +++ b/packages/trpc/server/routers/viewer/credits/buyCredits.handler.ts @@ -77,6 +77,7 @@ export const buyCreditsHandler = async ({ ctx, input }: BuyCreditsOptions) => { quantity, successUrl: redirectUrl, cancelUrl: redirectUrl, + allowPromotionCodes: true, metadata: { ...(teamId && { teamId: teamId.toString() }), userId: ctx.user.id.toString(),