【问题标题】:Python/Stripe invoice creation no line_item addedPython/Stripe 发票创建未添加 line_item
【发布时间】:2018-11-27 22:53:59
【问题描述】:

在我的 python 项目中,我必须与 Stripe API 集成以自动化我的付款和发票管理。 我尝试创建这样的发票:

        stripe.Invoice.create(
            customer=c_stripe.id,
            billing='charge_automatically',
            tax_percent=22,
            charge=sc.id,
            description='Test ondemand invoice',
            lines=[s_li,]
        )

其中 c_stripe.id 是条带中客户的 id,sc.id 是之前创建的费用的 id。 现在我必须将行项目添加到我的发票中,我这样做了:

        s_li = stripe.line_item.create(
            amount=int(glob_amount*100),
            currency='eur',
            description='test monthly usage',
            type='invoiceitem'
        )

但系统对我说“条纹中没有 line_item 方法”。 如何在 Stripe API 中创建包含不同项目行的发票?

提前致谢

【问题讨论】:

    标签: python python-3.x stripe-payments


    【解决方案1】:

    您可能正在寻找stripe.InvoiceItem。特别是stripe.InvoiceItem.create()

    这是一个例子:

    invoice_item = stripe.InvoiceItem.create(
        customer=c_stripe.id,
        amount=int(glob_amount*100),
        currency='eur',
        description='test monthly usage',
        invoice=invoice.id
    )
    

    如果您想将此项目附加到特定的现有Invoice,您可以提供invoice.id。如果未提供,Stripe 会将其附加到下一个预定的Invoice

    发票可选

    要将此发票项目添加到的现有发票的 ID。离开时 空白,发票项目将被添加到下一个即将安排的 发票。这在添加发票项目以响应 invoice.created webhook。您只能将发票项目添加到草稿 发票。

    您可能还想检查:

    【讨论】:

      猜你喜欢
      • 2018-11-05
      • 2018-07-26
      • 1970-01-01
      • 2021-04-19
      • 2021-09-13
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多