亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Stripe:在向現有訂閱添加 subscriptionItem 時立即向客戶收費/開具賬單?

Stripe:在向現有訂閱添加 subscriptionItem 時立即向客戶收費/開具賬單?

慕森王 2023-02-17 10:21:31
我在一家在線課程提供商工作。這是客戶流程:student subscribe to teacherA | this creates a monthly Stripe subscription       | student is billedstudent 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 $501/15 | studentA subscribe to teacherB at | billed $2.5 # half of remaining month02/01 | subscription auto invoice         | billed $10您知道如何實現這一目標嗎?
查看完整描述

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);


查看完整回答
反對 回復 2023-02-17
  • 1 回答
  • 0 關注
  • 218 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號