Stripe:创建没有发票的发票项目,将发票项目添加到新发票中。

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

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账户中的以下内容(红色圆圈中的按钮):
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的默认值现在是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

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

发表评论

匿名网友

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

确定