OpenSourceFellows / amplify

Open Source Fellow Sandbox
https://amplify-app-production.herokuapp.com/
MIT License
88 stars 63 forks source link

Coupon Code: Stripe #82

Closed manishapriya94 closed 2 years ago

manishapriya94 commented 2 years ago

User Story:

Coupon codes make it more accessible for people of all backgrounds to be able to participate in civic engagement. In our use case, an advocacy organization can give codes at their discretion via email, social media, or through in person.

Screen Shot 2022-02-22 at 4 45 18 PM

Within checkout.vue we have a space for a promo code. The use case here if that if a person enters a code in the input text box below and if its under the threshold of times discounted:

  1. If you didn't select a donation amount, your total will come out to zero
  2. If you plan on sending donation, your total will not include post cost of 1.00 ('donate and send' button appears)

We might want to also consider adding messaging if a limit has been reached or if the coupon code doesn't work

Implementation:

Stripe currently lays out the following for integrating coupons into checkout:

  1. Outreach teams adds coupons into dashboard

    Screen Shot 2022-02-22 at 4 06 36 PM

    We'll use 'amount off' which takes a dollar off

  2. It seems you can't apply a coupon directly to the redirectToCheckout method, you have to create a Checkout session first and then use that.

  3. Add a discount to Checkout the sample code is calling Checkout.session.create, not Checkout directly

Quick note 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.

Questions: Can coupons be done on just client side? Does coupon exhaust the customizations we have access to?

ewchong commented 2 years ago

Currently looks like the backend is setup to use Stripe's custom payment flow. To use Stripe Checkout, will have to switch to calling session.create in the backend. This repo gives a good overview of the differences between the options: stripe-samples/accept-a-payment