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);
添加回答
舉報