Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.0] Bug solution for Issue #476 #562

Merged
merged 1 commit into from
Oct 8, 2018
Merged

[7.0] Bug solution for Issue #476 #562

merged 1 commit into from
Oct 8, 2018

Conversation

rental-ninja
Copy link

Now retrieve an invoice with ALL line items:
As per Stripe API documentation, when retrieving an invoice, you only retrieve "the first handful of those items", referring to the line items. Currently, the "findInvoice" method of the Billable only retrieves the invoice without retrieving all the lines. Therefore, when bills are generated, we get lots of missing lines and therefore it's impossible to check by our customers if their bill is OK.

This pull request solves this problem by simply retrieving up to 1000 lines of the invoice and replacing the lines object of the original invoice.

Now retrieve an invoice with ALL line items.
@taylorotwell
Copy link
Member

Do we really need 1000? Is 100 good enough?

@rental-ninja
Copy link
Author

Hi!
Thanks for your answer. No, definitely it's not needed 1000, it was only to make sure that we get all of them.
Our case is that we run with "seats". So, in Stripe we just have 2 plans and we multiply the amount of the plan per the number of "seats". So every change in this number creates two lines.
For the moment the maximum number of lines we had in an invoice was about 50. So I think that 100 would be OK but if this could be something we can adjust, for instance with a parameter, it would be nice.
Thanks for your time!

@driesvints driesvints changed the title Bug solution for Issue #476 [7.0] Bug solution for Issue #476 Oct 8, 2018
Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please fix the StyleCI warnings?

@taylorotwell taylorotwell merged commit e5dda63 into laravel:7.0 Oct 8, 2018
@rental-ninja
Copy link
Author

Great!
Thank you all for your help!

taylorotwell added a commit that referenced this pull request Oct 9, 2018
[7.0] Bug solved: accessing the Stripe invoice lines with the Stripe Key. Issue #476 (#562)
sebdesign added a commit to sebdesign/cashier that referenced this pull request Sep 15, 2019
According to laravel#562, the invoice response contains only 10 line items, so we were manually fetching 1000 items.

But Stripe's pagination limit is 100 items, so that doesn't ensure that all the line items will be fetched.

Instead, we can use the `Stripe\Collection::autoPagingIterator()` which automatically fetches all the paginated results with a generator.

I was tempted to use a lazy collection here, but since this method will be called by the `Invoice::invoiceItems()` and `Invoice::subscriptions()` methods, we don't want to hit the API twice just to filter the results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants