How to Apply a Coupon to a Stripe Customer

冷暖自知 提交于 2019-12-13 02:31:50

问题


I can't find any way to apply the coupon/discount to an existing customer who has a reoccurring payment. I'm using the stripe gem. I went ahead and created the coupon on the Stripe dashboard. I see no mention on how to add a coupon on their API page. I've tried this solution below but to no avail.

cu = Stripe::Customer.retrieve("cus_XXX")

cu.discount = "my_coupon_id"

cu.save

# returns Stripe::InvalidRequestError: (Status 400) Received unknown parameter: discount

There must be some sort of method I'm missing. What am I missing to fix this.


回答1:


You need to use the coupon parameter along with the Update Customer API so in Ruby that would be something like this:

cu = Stripe::Customer.retrieve("cus_XXX")
cu.coupon = "my_coupon_id"
cu.save


来源:https://stackoverflow.com/questions/27662394/how-to-apply-a-coupon-to-a-stripe-customer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!