从更新中的条纹订阅中删除优惠券 [英] Remove Coupon from Stripe Subscription in Update

查看:27
本文介绍了从更新中的条纹订阅中删除优惠券的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在更新期间删除订阅的优惠券,我认为将 nil 的优惠券传递给 api 应该将其删除,但它只是将其从帖子中删除.

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.

还有另一种方法可以这样做..https://stripe.com/docs/api/discounts/subscription_delete

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.

      Stripe::Subscription.update(
        subscription.stripe_id,
        {
          coupon: nil,
          items: [
            {
              id: subscription.item_stripe_id,
              quantity: 0,

            },
            { 
              plan: to_plan.stripe_id,
              quantity: 1
            }
          ],
        }
      ) 

像这样创建一个发布请求:

{
  "items": {
    "0": {
      "id": "si_G5sdf33t89",
      "quantity": "0"
    },
    "1": {
      "plan": "a_plan",
      "quantity": "1"
    }
  }
}

推荐答案

coupon: ''

优惠券设置为空字符串将其删除,而 nil/null 将被忽略

Coupon set to an empty string removes it, while nil/null is ignored

这篇关于从更新中的条纹订阅中删除优惠券的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆