【问题标题】:Stripe retrieves invoices for all customers - not the one specifiedStripe 检索所有客户的发票 - 而不是指定的那一位
【发布时间】:2020-10-24 07:48:35
【问题描述】:

我正在使用以下代码来获取指定客户创建的发票:

customer.invoices.all

但无论是哪个客户创建的,它都会检索所有发票。我还尝试了以下方法:

Stripe::Invoice.all(customer: CUSTOMER_ID)

它的行为方式相同。我做错了什么还是这是一个错误?

【问题讨论】:

    标签: ruby stripe-payments


    【解决方案1】:

    试试这个:

    Stripe::Invoice.all(:customer => "CUSTOMER_ID")
    

    来自 API:https://stripe.com/docs/api?lang=ruby#list_customer_invoices

    【讨论】:

    • 按照原来的问题,我已经试过了。
    【解决方案2】:

    2020 年 10 月 23 日更新

    新的 Stripe API 需要以下内容:

    Stripe::Invoice.list(customer: CUSTOMER_ID)
    

    原答案

    看起来像在发票上调用 all 会覆盖之前检索客户发票的查询。

    以下检索所有发票:

    customer.invoices.all
    

    以下内容仅检索客户的所有发票:

    customer.invoices
    

    【讨论】:

      【解决方案3】:

      你可以尝试做类似的事情

        customer = Stripe::Customer.retrieve("cus_6C09m0rCIx3Ld8")
        invoices = Stripe::Invoice.all(:customer => customer.id)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-12-11
        • 1970-01-01
        • 2022-07-30
        • 2015-02-14
        • 2014-06-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多