条带 api:多个计划/订阅,单一发票

stripe api: multiple plans / subscriptions, single invoice

我一整天都在阅读文档,很难理解这是否可行。

我想要的是为一个用户订阅多个计划并在一张发票上收费,从发票最初开具账单时每月定期付款。

在文档中说:

"Note that multiple subscriptions on a customer results in a separate billing cycle, invoice, and charge for each subscription, even if the plans have the same billing interval and the subscriptions are created at the same time."

哪个没希望

但是 api 明确允许通过 InvoiceItems api 创建包含多个项目的发票。这似乎主要是为了 custom/unique 对客户采取的行动,例如在常规订阅周期之外应用折扣或一次性收费。

我想我可以手动跟踪计费周期并手动创建多项目发票,但我更愿意通过 Stripe 将其自动化。

这可能吗?

对于每个新的计费周期,每个订阅都会在 Stripe 端有自己的发票和费用,如果没有一些定制开发,就无法将所有这些捆绑在一起。

如果您想将一个客户的所有订阅归为一次收费,最好的解决方案是对您要向客户收费的每个 "subscription" 使用 Invoice Items. You'd create a [=11=] monthly plan for all of your customers and then, each month, when you get the invoice.created event indicating that a new invoice has been created you'd create one invoice item。然后,Stripe 会自动为该发票一次性收取总金额。

根据文档,您可以向订阅添加数量,这将向您收取计划金额的倍数,但在同一张发票上:

Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

Stripe::Subscription.create(
  :customer => "cus_4fdAW5ftNQow1a",
  :plan => "pro-monthly",
  :quantity => 5,
)

有一整页关于它的文档here

Stripe API 现在支持您描述的内容:https://stripe.com/docs/subscriptions/multiplan。这个想法是向订阅添加多个计划,限制是所有计划必须共享相同的时间间隔。

// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("xxxxxxxxxxxxxxx");

stripe.subscriptions.create({
  customer: "cus_91elFtZU3tt11g",
  items: [
    {
      plan: "basic-monthly",
    },
    {
      plan: "additional-license",
      quantity: 2,
    },
  ]
}, function(err, subscription) {
  // asynchronously called
});

是的,您现在可以向现有订阅添加多个计划。以下是示例:

sub = Stripe::Subscription.retrieve('sub_Aj4Wy1gzA5xyz')
sub.items = [{plan: "UserTestPlan"}, {plan: "UserTestPlan2"}]
sub.save

2020最新推荐

现在,处理该场景的推荐工作流是:

  • 创建 productprices 而不是 plans
  • 创建 subscription(带有 price
  • 根据需要添加 subscriptionItem subscription

您的客户可以根据需要拥有很多 subscriptionItems。他将在 subscription 周期性基础上被计费一次,并且只有一张发票。如果您在月中添加 subscriptionItem,它也会处理。

stripe doc: Subscriptions with multiple products
Stripe API reference

// add item to existing subscription
await stripe.subscriptionItems.create({
    subscription: subscriptionId,
    price: priceId,
    quantity,
});