使用条带将运费添加到第一个订阅发票 [英] Adding shipping to first subscription invoice using stripe

查看:31
本文介绍了使用条带将运费添加到第一个订阅发票的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在集成 Stripe,以使用户能够订阅发往美国和加拿大的实体产品.

I am integrating stripe to enable the user to subscribe to a physical product shipping to the US and Canada.

我想使用 invoice.created 网络钩子来修改发票并根据送货地址添加运费.

I want to use the invoice.created webhook to modify the invoice and add a shipping charge depending on the delivery address.

根据stripe docs 的问题是第一张发票是立即收费的,这意味着我不能在第一次收费之前修改它,因为我可以修改它.

The problem according to stripe docs is that the first invoice is charged immediately, implying that I cannot modify it prior to the first charge as I could with the subsequent.

如果是这样,那么我认为解决此问题的唯一方法是为我们和加拿大的每个订阅间隔添加计划,例如 product-weekly-usproduct-monthly-usproduct-weekly-caproduct-monthly-ca 而不是 product-monthlyproduct-每周

If this is so, then the only way around this I believe is to add plans for us and canada for each of the subscription intervals e.g product-weekly-us, product-monthly-us, product-weekly-ca, product-monthly-ca instead of just product-monthly, product-weekly

然后运费将是静态的(没有订单项)并且是总额的一部分.

The shipping would then be static (no line item) and part of the total.

编辑

所以从 koopajah 的答案中查看发票,这是我可以解决的问题(请确认):

So looking into invoices from koopajah's answer, here is what I can work out (please confirm):

  1. 为您的客户创建发票项目(待处理发票项目) - 这是否不包括订阅的行项目?
  2. 为客户创建订阅(将那些待处理的发票项目添加到订阅的新发票中) - 这将触发 invoice.created webhook,您必须检查并忽略它 - 会您必须跟踪发票编号吗?**哦等等!它会被关闭,所以你可以检查一下 :D **
  3. 所有后续发票均使用 invoice.created 网络钩子修改,用于打开发票
  1. Create the invoice items for your customer (pending invoice items) - does this exclude the line item for the subscription?
  2. Create the subscription for the customer (which adds those pending invoice items to the new invoice for the subscription) - this will fire invoice.created webhook, which you would have to inspect and ignore - would you have to track the invoice numbers? **edit: oh wait! It would be closed, so you can just check that :D **
  3. All subsequent invoices are modified with the invoice.created webhook for open invoices

推荐答案

如果您想继续使用 Invoice Items,您只需在创建用户订阅之前为第一个周期创建一个.订阅创建后,将创建第一张发票并自动为您当前的客户提取发票项目.

If you want to keep using Invoice Items you just have to create one for the first cycle before creating your user subscription. Then once the subscription is created the first invoice will be created and automatically pick up the Invoice Item for your current customer.

然后,您可以按照计划在 webhook 中创建下一个发票项目.

You can then create the next Invoice Items in the webhook as you planned to do.

编辑:步骤如下:

  1. 使用 Stripe 令牌创建客户
  2. 为该客户创建一个发票项目,用于运费金额(不是订阅金额)
  3. 为此客户创建订阅,这将自动将在步骤 2 中创建的发票项目添加到总费用
  1. Create a Customer with the Stripe token
  2. Create an Invoice Item for this customer for the shipping amount (not the subscription one)
  3. Create the subscription for this customer which will automatically add the Invoice Item created at step 2 to the total charge
  1. 6.... 在 webhook "invoice.created" 中检查发票是否已关闭,如果没有,请重复步骤 2 并将当前发票标识符添加到 invoice 参数

这篇关于使用条带将运费添加到第一个订阅发票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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