Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get total amount after applying coupon in Stripe payment gateway

I'm using stripe to process payments in my app.

I have created a plan and I have some coupons.

I am creating a subscription using following code.

customer.subscriptions.create(plan=PLAN_type,coupon=PROMO_CODE)

but I want to know the amount the customer going to charged if he appy coupon, so that I can display it to him on a webpage.

I am able get the amount of a plan and discount offered by a coupon. But now I want the total amount after applying the coupon.

I can do this by manually applying discount to the amount , but I want to know is there a way from API to do this

like image 861
RMK Avatar asked Mar 14 '15 07:03

RMK


People also ask

Can I use a 100% off coupon in checkout Stripe?

From Stripe Support: "I'd say that you cannot add a 100% off discount in Stripe Checkout. It doesn't allow purchase below the minimum charge amount for one-time payments.

How do you use coupons on Stripe?

In the Dashboard on the Create a coupon page, click the Use customer-facing coupon codes button. Enter a code. This is the code that a customer enters at checkout to redeem the discount. If you don't set a code, Stripe generates one for you.

Can you use promo codes with Stripe app?

Accessing Promotion Codes Some new features, such as Promotion Codes on Stripe Billing or Checkout, is only available to paid Billing users.

How do you make a coupon Stripe?

Click the Products Tab from the Stripe dashboard. Then, select Coupons. Click + New in the top right corner of the Coupons page. On this page, give your new coupon a Title, select the coupon type between a Percentage discount or a Fixed Amount discount, choose the amount of the discount, and the time Duration.


1 Answers

I don't think there would be a way to know the amount your customer is going to be charged upfront. If you want to display this to your customer before creating the subscription you have to calculate this on your end.

If you just want to confirm the total charged after the subscription has been created, you would retrieve the invoices for that customer with the List Customer Invoices API.

The invoice you're looking for should be the first one since it was the latest created, but to be safe you should check the corresponding subscription to make sure it corresponds to the subscription you just created. You would then be able to retrieve the total from that invoice to know how much you charged your customer.

like image 144
koopajah Avatar answered Nov 09 '22 06:11

koopajah