Stripe:创建不带发票的发票项目,将发票项目添加到新发票中

huangapple go评论96阅读模式
英文:

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)
Stripe:创建不带发票的发票项目,将发票项目添加到新发票中

How do I code the "Invoice now" button? Do I need to re-create all the invoice item??

答案1

得分: 1

API版本2022-08-01

> 当参数被省略时,默认值为pending_invoice_items_behavior现在是排除。

因此,您想要指定pending_invoice_items_behaviorinclude,以包括所有未处理的发票项目。

英文:

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

huangapple
  • 本文由 发表于 2023年8月9日 12:49:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76864659-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定