Stripe:在向现有订阅添加 subscriptionItem 时立即向客户收费/开具账单?

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


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

问题是,当我创建 subscriptionItem 时,不会立即向客户收费,而是开始免费访问高级内容。


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


然后我认为创建有很多 subscriptionItems 是个好主意,如果我错了请纠正我。


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


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


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

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


慕森王
浏览 115回答 1
1回答

慕斯王

为学生想要订阅的其他教师创建额外的 subscriptionItems 是正确的做法。但是,正如您注意到的那样,当您在订阅上创建订阅项目时,不会立即向学生收费。默认情况下,Stripe 会为新添加的订阅项目按比例分配的金额创建待处理发票项目(例如,在您的示例中为 2.5 美元)。如果您单独留下按比例分配的发票项目,它们将被捆绑到学生的下一张发票中,总计为 12.5 美元: - teacherB $2.5 (proration charges from last month) - teacherA $5 - teacherB $5 - total next month: $12.5如果您不想等到下个月才向学生收费,那么您可以在添加新订阅项目后立即创建并支付发票,从而立即向学生收费。在节点中,这看起来像:  // 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);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript