1 回答

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊
為學(xué)生想要訂閱的其他教師創(chuàng)建額外的 subscriptionItems 是正確的做法。但是,正如您注意到的那樣,當(dāng)您在訂閱上創(chuàng)建訂閱項(xiàng)目時(shí),不會(huì)立即向?qū)W生收費(fèi)。默認(rèn)情況下,Stripe 會(huì)為新添加的訂閱項(xiàng)目按比例分配的金額創(chuàng)建待處理發(fā)票項(xiàng)目(例如,在您的示例中為 2.5 美元)。如果您單獨(dú)留下按比例分配的發(fā)票項(xiàng)目,它們將被捆綁到學(xué)生的下一張發(fā)票中,總計(jì)為 12.5 美元:
- teacherB $2.5 (proration charges from last month)
- teacherA $5
- teacherB $5
- total next month: $12.5
如果您不想等到下個(gè)月才向?qū)W生收費(fèi),那么您可以在添加新訂閱項(xiàng)目后立即創(chuàng)建并支付發(fā)票,從而立即向?qū)W生收費(fèi)。
在節(jié)點(diǎn)中,這看起來(lái)像:
// 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);
添加回答
舉報(bào)