How to Apply a Coupon to a Stripe Customer

2019-08-10 03:30发布

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条回答
Viruses.
2楼-- · 2019-08-10 04:17

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
查看更多
登录 后发表回答