Javascript 条带:将subscriptionItem添加到现有订阅时是否立即向客户收费?

Javascript 条带:将subscriptionItem添加到现有订阅时是否立即向客户收费?,javascript,node.js,stripe-payments,Javascript,Node.js,Stripe Payments,我在一家在线课程提供商工作。这是客户流: 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 学生订阅teacherA |这会创建一个每月的

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

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 学生订阅teacherA |这会创建一个每月的条带订阅|学生付费 学生订阅教师b |这会在订阅中添加订阅项|学生不计费 问题是,当我创建subscriptionItem时,客户不会立即付费,并开始免费访问高级内容

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

然后我认为创建有很多订阅的项目是个好主意,如果我错了,请纠正我


我正在寻找一种实现如下流程的方法:

每位教师的订阅费为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 01/01 |学生A以| 5美元订阅teacherA 2015年1月|学生A以|账单2.5美元|剩余半个月的价格订阅teacherB 02/01 |订阅自动发票|账单10美元
你知道如何做到这一点吗?

为学生想要订阅的额外教师创建额外订阅是正确的做法。但是,正如您注意到的,当您在订阅上创建订阅项目时,学生不会立即计费。默认情况下,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);