Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Creating Checkout session with Coupon (#1163) #1164

Closed
wants to merge 1 commit into from
Closed

Bugfix: Creating Checkout session with Coupon (#1163) #1164

wants to merge 1 commit into from

Conversation

io238
Copy link

@io238 io238 commented May 21, 2021

This PR fixes issue #1163.

Description:

It's not possible to generate a Stripe Checkout session through Cashier when using Coupons via the ->withCoupon() method.

There are two issues:

(1) The Stripe API does not accept both allow_promotion_codes and discounts parameters. Stripe throws an exception even when the allow_promotion_codes parameter is set to false.

(2) The discount parameter in the session creation payload needs to be an indexed array.

Both issues seem to be in inconsistent implementation of the Checkout API. It's not very well documented and this different from the way how regular subscriptions are created (without Checkout). See https://stripe.com/docs/billing/subscriptions/discounts for more details.

Changes:

  • Empty values such as 'allow_promotion_codes' = false are filtered from the payload before sending it to Stripe
  • coupon nested one level deeper in the discounts parameter

@driesvints
Copy link
Member

Thanks @io238. I've took an alternative approach for this here: #1165

@driesvints driesvints closed this May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants