-
Notifications
You must be signed in to change notification settings - Fork 857
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
If the invoice has more than 10 items, from item number 11 tax_amounts does not include expanded tax_rate. #1400
Comments
@padre Can you provide a lot more specific details to reproduce this exact issue? What code are you using? How are you expanding the extra lines? When you retrieve an Invoice you only get 10 lines at most in |
@remi-stripe I am using the package https://github.com/laravel/cashier-stripe When I get the invoice to generate the pdf document, $invoice->invoiceLineItems() should show expanded all lines of an invoice, including the tax rate for a tax amount (or at least we think so laravel/cashier-stripe#1475 (comment)) But I only get the first ten line items expanded. These are line items number 10 and 11 for an invoice:
The line item of invoice number 11 does not include expanded the tax rate for a tax amount: This is the code: https://github.com/laravel/cashier-stripe/blob/14.x/src/Invoice.php#L567 Is it a problem with stripe or laravel/cashier-stripe? Thanks! |
We need Stripe-specific exact end to end code to repro. Since you use Cashier and they wrap around our API it's hard to grasp which exact part is or isn't working exactly here unfortunately. Can you get the developer in that other issue to write a simple Stripe reproduction first? To me it doesn't look like they are passing the expansion parameters properly during pagination at least |
@padre it would help if you could lookup the Stripe request in your Stripe dashboard and post the entire request. That would help @remi-stripe in checking what's exactly going on here. |
Here's the code that calls performs the call btw: it's just an invoice retrieve request with the provided expanse data: https://github.com/laravel/cashier-stripe/blob/14.x/src/Invoice.php#L564-L575 |
GET /v1/invoices/in_1M4UugCelkdgTLAvIytlZbcj (req_BJ0AzGAXdgho8U) Params:
|
@driesvints but that code just retrieves the Invoice and gets the first 10 InvoiceLineItems back. Expansion should work totally fine in that one case. |
@remi-stripe That's the problem, the invoiceLineItems function only gets the first 10 expanded items. |
@padre if that's the case then how are you running into this issue? What are you doing that triggers the next set of items? |
@remi-stripe I think I found it. We seem to be using the https://github.com/laravel/cashier-stripe/blob/14.x/src/Invoice.php#L501 |
@driesvints All I do is try to download an invoice that has more than 10 items.
|
Hi @remi-stripe. You can use the following snippet to recreate the bug. As soon as you have an invoice with more than 10 line items that use tax rates it'll fail with the following error:
$stripe = new \Stripe\StripeClient('stripe-secret');
$invoice = $stripe->invoices->retrieve('in_xxx', [
'expand' => ['lines.data.tax_amounts.tax_rate'],
]);
foreach ($invoice->lines->autoPagingIterator() as $line) {
foreach ($line->tax_amounts as $tax_amount) {
$tax_rate = $tax_amount->tax_rate;
echo $tax_rate->display_name . ' ' . $tax_rate->percentage . '%' . PHP_EOL;
}
} After 10 line items, the next ones don't seem to include the expanded data and thus a string ID for |
Off the bat I think one quick solution could be to pass a $stripe = new \Stripe\StripeClient('stripe-secret');
$invoice = $stripe->invoices->retrieve('in_xxx', [
'expand' => ['lines.data.tax_amounts.tax_rate'],
]);
foreach ($invoice->lines->autoPagingIterator(['expand' => ['data.tax_amounts.tax_rate']) as $line) {
foreach ($line->tax_amounts as $tax_amount) {
$tax_rate = $tax_amount->tax_rate;
echo $tax_rate->display_name . ' ' . $tax_rate->percentage . '%' . PHP_EOL;
}
} I guess solving this automatically isn't possible. |
I sent in a PR for this: #1409 |
This should now be resolved by a server-side fix! Thank you all! Please feel free to re-open if you notice any problems. |
Cool, thanks! @padre can you try it out? |
@driesvints Nothing has changed :-(
|
@padre that's unfortunate. Can you re-open the issue like @richardm-stripe asked? |
@driesvints, done (thank you very much for your dedication) |
Describe the bug
Here is the PR laravel/cashier-stripe#1475
To Reproduce
Attempting to generate a pdf of an invoice with more than ten line items
Expected behavior
All lines on an invoice should be expanded, including the tax_rate for a tax_amount.
Code snippets
No response
OS
Ubuntu / Centos
PHP version
PHP 8.1
Library version
stripe/stripe-php v9.9.0
API version
2022-11-15
Additional context
No response
The text was updated successfully, but these errors were encountered: