【问题标题】:Stripe CLI: testing action when trial period endsStripe CLI:试用期结束时的测试操作
【发布时间】:2020-08-17 20:13:13
【问题描述】:

我希望能够在本地测试用户的试用期结束时是否采取了正确的操作。

我设置了 Stripe CLI,并开始收听:

stripe listen --forward-to http://localhost:8000/api/stripe-webhook

当试用结束时,customer.subscription.updated 事件将发生。

我使用 Stripe CLI 触发此事件:

stripe trigger customer.subscription.updated

在我的服务器端,我可以看到payload['data']['previous_attributes'] 包含一个带有foo = null 的元数据数组。当试用结束时,我们应该得到 previous_attributes 包含类似:{ "status": "trialing"...

我想知道是否可以使用模仿用户试用结束的 Stripe CLI 触发事件(或者甚至可能只是一种将 previous_attributes 设置为在实时环境中发生的类似值的方法试用结束)?如果可以做到这一点,那么在本地测试是否会在试验结束时发生适当的操作会更容易一些,而无需推送到类似 prod 的环境。

【问题讨论】:

    标签: stripe-payments


    【解决方案1】:

    最简单的方法可能是在创建订阅或现有订阅时使用trial_end 设置一个非常短的试用期,然后等待几分钟让它结束,此时它将生成适当的事件。

    stripe subscriptions update sub_HpOl9vDMzIEfGf --trial-end=`date -v +5M +%s`
    

    https://stripe.com/docs/billing/testing#trials

    https://stripe.com/docs/api/subscriptions/update#update_subscription-trial_end

    【讨论】:

      猜你喜欢
      • 2015-01-15
      • 2020-01-30
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 2021-07-03
      • 1970-01-01
      • 2021-01-26
      • 2021-03-24
      相关资源
      最近更新 更多