简体   繁体   English

在Stripe付款网关中应用优惠券后如何获得总金额

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

I'm using stripe to process payments in my app. 我正在使用Stripe在我的应用程序中处理付款。

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) 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 我可以通过手动对金额进行折扣来做到这一点,但是我想知道API是否有办法做到这一点

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 . 如果您只想在创建订阅后确认总费用,则可以使用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. 您要查找的发票应该是自上次创建以来的第一张发票,但是为了安全起见,应检查相应的subscription以确保它与您刚创建的订阅相对应。 You would then be able to retrieve the total from that invoice to know how much you charged your customer. 这样,您便可以从该发票中检索total ,以了解向客户收取了多少费用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM