如何使用Stripe API创建billing_reason为subscription_threshold的发票?
Stripe Billing Threshold 相关问题解答
能否通过API直接创建billing_reason为subscription_threshold的发票?
不行。subscription_threshold这个billing_reason值是Stripe系统内部专属的,只有当订阅触发计费阈值规则时,Stripe自动生成的发票才会带有该值,无法通过API手动指定这个值来创建发票。
测试时能否自定义billing_reason生成发票以避免等待?
无法通过Invoice API直接将billing_reason设为subscription_threshold来模拟阈值触发场景,但有两种快速测试的方法:
- 手动触发发票生成:调用
POST /v1/invoices接口,指定目标subscription参数并设置auto_advance=true,可以立即生成发票,不用等Stripe自动流程的10分钟延迟。不过此时发票的billing_reason会是subscription_cycle或manual,而非subscription_threshold。 - 模拟事件测试后端逻辑:用Stripe CLI模拟
invoice.created事件,在事件的payload里手动设置billing_reason为subscription_threshold,直接验证你的后端响应逻辑,不需要生成真实的阈值触发发票。
内容的提问来源于stack exchange,提问作者Paymahn Moghadasian
相关产品推荐
相关产品推荐

