Skip to content

Commit

Permalink
feat(billing): enable promo codes on checkout via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Nov 19, 2024
1 parent af1237a commit 18f24f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/api/src/billing/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const envSchema = z.object({
STRIPE_SECRET_KEY: z.string(),
STRIPE_PRICE_ID: z.string(),
STRIPE_WEBHOOK_SECRET: z.string(),
STRIPE_CHECKOUT_REDIRECT_URL: z.string()
STRIPE_CHECKOUT_REDIRECT_URL: z.string(),
STRIPE_ENABLE_COUPONS: z.enum(["true", "false"]).default("false")
});

export const envConfig = envSchema.parse(process.env);
2 changes: 1 addition & 1 deletion apps/api/src/billing/services/stripe/stripe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class StripeService extends Stripe {
}
],
mode: "payment",
allow_promotion_codes: true,
allow_promotion_codes: this.billingConfig.STRIPE_ENABLE_COUPONS === "true",
customer: options.customerId,
success_url: `${options.redirectUrl}?session_id={CHECKOUT_SESSION_ID}&payment-success=true`,
cancel_url: `${options.redirectUrl}?session_id={CHECKOUT_SESSION_ID}&payment-canceled=true`
Expand Down

0 comments on commit 18f24f6

Please sign in to comment.