Added support for promo codes in Stripe Checkout (#194)

no-issue

This commit adds support for Stripe's newly-added promotional code
parameter when creating a new Stripe Checkout session.

ref: https://stripe.com/docs/payments/checkout/set-up-a-subscription#coupons
This commit is contained in:
Kristian Freeman 2020-09-21 05:53:36 -05:00 committed by GitHub
parent 016e05b234
commit 6ec7eeae33

View File

@ -34,6 +34,7 @@ module.exports = class StripePaymentProcessor {
this._checkoutCancelUrl = config.checkoutCancelUrl;
this._billingSuccessUrl = config.billingSuccessUrl;
this._billingCancelUrl = config.billingCancelUrl;
this._enablePromoCodes = config.enablePromoCodes;
try {
this._product = await api.products.ensure(this._stripe, config.product);
@ -192,6 +193,7 @@ module.exports = class StripePaymentProcessor {
cancel_url: options.cancelUrl || this._checkoutCancelUrl,
customer: customer ? customer.id : undefined,
customer_email: customerEmail,
allow_promotion_codes: this._enablePromoCodes,
metadata,
subscription_data: {
trial_from_plan: true,