Stripe:将订阅项添加到现有订阅时立即向客户收费/计费? [英] Stripe: charge/bill customer immediately when adding a subscriptionItem to an already existing subscription?

查看:58
本文介绍了Stripe:将订阅项添加到现有订阅时立即向客户收费/计费?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一家在线课程提供商工作.这是客户流程:

<前>学生订阅教师A |这将创建每月的 Stripe 订阅 |学生被计费学生订阅教师B |这会向订阅添加一个订阅项 |学生不收费

问题在于,当我创建订阅项时,客户不会立即付费,而是开始免费访问优质内容.

从我在文档中提到的内容来看,创建有很多订阅让学生订阅教师是一个糟糕的设计(无论如何,他们将单个客户的订阅限制为 25 个).

然后我觉得创建有很多subscriptionItems是个好主意,如果我错了,请纠正我.


我正在寻找一种方法来实现这样的流程:

订阅价格为每位教师 5 美元

<前>01/01 |学生A 订阅教师A |收费 5 美元01/15 |学生A 订阅教师B |收费 $2.5 # 剩余月份的一半02/01 |订阅自动发票|收费 10 美元

您知道如何实现这一目标吗?

解决方案

为学生想要订阅的额外教师创建额外的订阅项是正确的做法.但是,正如您注意到的,当您在订阅上创建订阅项目时,不会立即向学生收费.默认情况下,Stripe 为新添加的订阅项目的按比例分配的金额创建待处理的发票项目(例如,在您的示例中为 2.5 美元).如果您不理会按比例分配的发票项目,它们将被捆绑到学生的下一张发票中,总计 12.5 美元:

 - TeacherB $2.5(上个月按比例收费)- 老师A $5- 老师B $5- 下个月总计:12.5 美元

如果您不想等到下个月才向学生收费,那么您可以通过在添加新订阅项目后立即创建和支付发票来立即向学生收费.

在节点中,这看起来像:

//为老师 B 添加新的订阅项等待 stripe.subscriptionItems.create({subscription: 'sub_xyz',//订阅 IDprice: 'price_teacher_b_price',//老师 B 的价格});//此时,Stripe 将创建待处理的发票项目.//未决发票项目将默认包含在下个月的//发票,但您可以立即将它们拉入新发票:const invoice = await stripe.invoices.create({customer: 'cus_xyz',//客户/学生});//此时,发票项已经被拉入新发票中.//要向学生收费,您需要完成并支付发票.你//可以一步完成:等待 stripe.invoices.pay(invoice.id);

I'm working for an online courses provider. This is the customer flow:

student subscribe to teacherA | this creates a monthly Stripe subscription       | student is billed
student subscribe to teacherB | this adds a subscriptionItem to the subscription | student is not billed

The problem is that, when I create the subscriptionItem, the customer is not immediately billed, and begin access to premium content for free.

From what I red in the doc, creating has much subscription has students subscribes to teachers is a bad design (anyway, they have limited subscription for a single customer to 25).

Then I thought that creating has much subscriptionItems was a good idea, correct me if I'm wrong.


I'm looking for a way to achieve a flow like this:

Subscription price is $5 for every teachers

01/01 | studentA subscribe to teacherA at | billed $5
01/15 | studentA subscribe to teacherB at | billed $2.5 # half of remaining month
02/01 | subscription auto invoice         | billed $10

Have you got a clue on how to achieve that ?

解决方案

Creating the extra subscriptionItems for the additional teachers that the student wants to subscribe to is the correct move. But, as you noticed when you create a subscription item on the subscription the student isn't billed immediately. By default, Stripe creates pending invoice items for the prorated amount of the newly added subscription item (e.g., $2.5 in your example). If you left the proration invoice items alone, they would get bundled into the student's next invoice which would total to $12.5:

 - teacherB $2.5 (proration charges from last month)
 - teacherA $5
 - teacherB $5
 - total next month: $12.5

If you don't want to wait for the next month for the student to get billed, then you can bill the student immediately by creating and paying an invoice right after adding the new subscription item.

In node this would look something like:

  // Add the new subscription item for Teacher B

  await stripe.subscriptionItems.create({
    subscription: 'sub_xyz', // The subscription ID
    price: 'price_teacher_b_price', // The price for teacher B
  });

  // At this point, Stripe would have created pending invoice items.
  // Pending invoice items would by default be included in the next month's
  // invoice, but you can pull them into a new invoice immediately:

  const invoice = await stripe.invoices.create({ 
    customer: 'cus_xyz', // The customer/student
  });

  // At this point, the invoice items have been pulled into a new invoice.
  // To charge the student you need to finalize and pay the invoice. You
  // can do this in one step:

  await stripe.invoices.pay(invoice.id);

这篇关于Stripe:将订阅项添加到现有订阅时立即向客户收费/计费?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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