1 回答
TA贡献1864条经验 获得超2个赞
为学生想要订阅的其他教师创建额外的 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);
添加回答
举报