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

I use stripe to process payments in my application.

I created a plan and I have some coupons.

I am creating a subscription using the following code.

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

but I want to know the amount that the customer will charge him if he turns out to be a decent coupon so that I can display it on a web page.

I can get the plan amount and the discount offered by the coupon. But now I want to receive the total amount after applying the coupon.

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

+6
source share
1 answer

I do not think that there would be a way to find out the amount that your client will charge in advance. If you want to display this for your customer before creating a subscription, you must calculate this at the end.

If you just want to confirm the total amount accrued after creating the subscription, you will receive invoices for this customer with a list of API invoices.

The account you are looking for should be the first because it was created last, but to be safe, you need to check the appropriate subscription to make sure that it matches the just created subscription. Then you can get total from this account to find out how much you paid for the client.

+3
source

Source: https://habr.com/ru/post/983782/


All Articles