Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add coupons to stripe's checkout

To enable SCA changes, I am now integrating https://stripe.com/docs/payments/checkout/client stripe's (stripe v3 js file) checkout feature to my app, which makes it easy for integration of my subscription system.

Question

how to pass coupons to stripe.redirectToCheckout() method, don't see anything related to this in documentation.

code sample

    stripe.redirectToCheckout({
      items: plans_and_addons,
      successUrl: successUrl,
      cancelUrl: cancelUrl,
      clientReferenceId: customer_id, // helpful in webhook response
    })
like image 483
przbadu Avatar asked Aug 09 '19 06:08

przbadu


2 Answers

I am also facing the same issue so I contacted stripe support.

Please check the support team's reply.

I did a thorough research on your query and I'm afraid, Checkout supports only a limited set of customizations (e.g. name, description, logo) and fields. Focusing the UI allows us to iterate on it more effectively to improve conversions and maintain support across a wide range of platforms.

They provided me one document link you can also check it. https://stripe.com/docs/payments/checkout/customization

I think you can solve your problem by creating custom checkout with helping stipe API. --not tried.

like image 90
maulik bafalipara Avatar answered Oct 03 '22 08:10

maulik bafalipara


I also ran into this, and what I've deduced from the Stripe docs is that you can't apply a coupon directly to the redirectToCheckout method, you have to create a Checkout session first and then use that.

  • Add a discount to Checkout the sample code is calling Checkout.session.create, not Checkout directly
  • redirectToCheckout Reference Docs doesn't mention a discount or coupon parameter at all, and the sample code again is creating a Checkout session using fetch (to one's own server backend, which is where my expertise ceases and where I'm stifled), to generate a session ID and then passing that into the result where redirectToCheckout is called.
like image 30
Daniel Fowler Avatar answered Oct 03 '22 08:10

Daniel Fowler