invertase/stripe-firebase-extensions

Add discount parameter for create checkout session

Open

#322 opened on Nov 30, 2021

View on GitHub
 (5 comments) (10 reactions) (0 assignees)TypeScript (211 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (480 stars)
PR merge metrics
 (PR metrics pending)

Description

Feature request

  • Extension name: firestore-stripe-payments

Is your feature request related to a problem? Please describe.

I would like to create a way for my customers to automatically redeem a coupon intended only for a specific customer group. Currently you can only specify a promotion_code when creating a checkout session.

Describe the solution you'd like

It would be nice if in the future you could also pass a coupon parameter.

Stripe Api allows this via

discounts.coupon
optional
The ID of the coupon to apply to this Session.

Additional context

We could simply add coupon as a parameter and edit

if (promotion_code) {
      sessionCreateParams.discounts = [{ promotion_code }];
}

to

if (promotion_code || coupon) {
      sessionCreateParams.discounts = [{ promotion_code, coupon }];
}

to the createCheckoutSession function.

Contributor guide