问题
I need to remove a coupon on a subscription during update, I thought passing coupon of nil to the api should remove it, but it just removes it from the post.
There is another way of doing it like this.. https://stripe.com/docs/api/discounts/subscription_delete
but it requires another call I don't want to do.
Ruby Stripe Gem API:
Stripe::Subscription.update(
subscription.stripe_id,
{
coupon: nil,
items: [
{
id: subscription.item_stripe_id,
quantity: 0,
},
{
plan: to_plan.stripe_id,
quantity: 1
}
],
}
)
creates a post request like this:
{
"items": {
"0": {
"id": "si_G5sdf33t89",
"quantity": "0"
},
"1": {
"plan": "a_plan",
"quantity": "1"
}
}
}
回答1:
coupon: ''
Coupon set to an empty string removes it, while nil/null is ignored
来源:https://stackoverflow.com/questions/58634940/remove-coupon-from-stripe-subscription-in-update