문제

I'm using the following code to get the invoices created by the specified customer:

customer.invoices.all

But it retrieves all the invoices regardless of which customer created them. I also tried the following:

Stripe::Invoice.all(customer: CUSTOMER_ID)

And it behaves the same way. Am I doing something wrong or is this a bug?

도움이 되었습니까?

해결책 2

Update 10/23/2020

The new Stripe API requires the following:

Stripe::Invoice.list(customer: CUSTOMER_ID)

Original Answer

It looks like like calling all on invoices overrides the previous query where it retrieves the invoices for the customer.

The following retrieves all invoices:

customer.invoices.all

The following retrieves all invoices for the customer only:

customer.invoices

다른 팁

Try this:

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

From the API: https://stripe.com/docs/api?lang=ruby#list_customer_invoices

You can try to do something like

  customer = Stripe::Customer.retrieve("cus_6C09m0rCIx3Ld8")
  invoices = Stripe::Invoice.all(:customer => customer.id)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top