英文:
Stripe: Creating invoice Item without invoice, adding invoice item into new invoice
问题
我使用以下代码创建了多个没有发票ID的发票项目。
const invoiceItem = await stripe.invoiceItems.create({
customer: customerId,
price,
});
现在我想发送一个包含所有已创建的发票项目的发票。
然而,我不能简单地创建一个发票,并使用发票ID更新我的发票项目,因为Stripe不允许这样做。
我真正想要实现的是在Stripe账户中的以下内容(红色圆圈中的按钮):
如何编写“立即发票”按钮的代码?我需要重新创建所有的发票项目吗?
英文:
I created multiple invoice item without an invoice id with the following code.
const invoiceItem = await stripe.invoiceItems.create({
customer: customerId,
price,
});
Now I want to send an invoice that includes all the invoice item that was created.
however I can't simply create an invoice and update my invoice item with the invoice id as stripe does not allow that.
// ===== DOES NOT WORK =====
const invoice = await stripe.invoices.create({
customer: customerId,
collection_method: 'send_invoice',
days_until_due: 30,
});
await stripe.invoiceItems.update({
customer: customerId,
price,
invoice: invoice.id,
})
what I really want to achieve is actually the following in stripe account (button circle in red)
How do I code the "Invoice now" button? Do I need to re-create all the invoice item??
答案1
得分: 1
> 当省略参数时,pending_invoice_items_behavior的默认值现在是exclude(排除)。
所以你想要将pending_invoice_items_behavior指定为include
(包括)以将所有待处理的发票项目包含在内。
英文:
From API version 2022-08-01:
> When the parameter is omitted the default value of pending_invoice_items_behavior is now exclude.
So you want to specify pending_invoice_items_behavior to include
to include all the pending Invoice Items into it.
答案2
得分: 0
只需添加发票项目。这些项目将显示在客户端上。然后,发票现在会获取所有未结发票项目,并生成一张发票。
英文:
just add invoiceitems. those will appear on the client. Invoice now then takes all open invoiceitems and creates an invoice out of it
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论