question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetching upcoming invoice's line items loses the request's original parameters

See original GitHub issue

When you retrieve an upcoming invoice in the API, your invoice might have more than 10 items. In that case you end up having to paginate the invoice. When doing so, you want to make sure that your parameters are passed automatically so that things like proration or plan changes are still taken into account on the next page(s).

Today, this is not working properly. This was originally reported in https://github.com/stripe/stripe-java/issues/264 and fixed in https://github.com/stripe/stripe-java/pull/275 so that you could explicitly pass the parameters to autoPagingIterable(). This was broken again in https://github.com/stripe/stripe-java/pull/294 when we removed StripeCollectionAPIResource though.

To reproduce the issue you need to do something like this:

  • Create a customer with a subscription on a $20 plan
  • Create 11 invoice items on that customer
  • Retrieve the upcoming invoice simulating a change to a plan for $50
  • Confirm that the last line item, for next month’s subscription, is for the $50 plan

Example code:

    String customerId = "cus_1234";
    String newPlan = "plan_1234";
    String subscriptionId = "sub_1234";

    Subscription sub = Subscription.retrieve(subscriptionId);
    Map<String, Object> itemNew = new HashMap<String, Object>();
    itemNew.put("id", sub.getSubscriptionItems().getData().get(0).getId());
    itemNew.put("plan", newPlan);

    List<Object> itemsChange = new ArrayList<>();
    itemsChange.add(itemNew);

    Map<String, Object> invoiceParams = new HashMap<String, Object>();
    invoiceParams.put("customer", customerId);
    invoiceParams.put("subscription", sub.getId());
    invoiceParams.put("subscription_items", itemsChange);
    Invoice upcoming = Invoice.upcoming(invoiceParams);

    Iterable<InvoiceLineItem> itItems = upcoming.getLines().autoPagingIterable();
    for (InvoiceLineItem item : itItems) {
        System.out.println(item);
    }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
remi-stripecommented, Jul 24, 2020

@itgeorge Thanks for the ping and sorry for the lack of update on that one. This is not an issue we have fixed yet because it’s unfortunately a tricky edge-case that we are trying to fix another way by adding a client/service infrastructure that would let you explicitly call the endpoint you expect instead.

We’ll investigate again though to see if there’s something we can temporarily introduce to fix this.

0reactions
pakrym-stripecommented, Nov 23, 2022

The original issue with the upcoming invoice line item iteration should be fixed on the service side now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stripe API reference – Retrieve an upcoming invoice's line items
When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those...
Read more >
Troubleshooting Common QuickBooks Errors - ServiceTrade
Occasionally, you may see some of your invoices not being processed by QuickBooks. This support article will detail the most common error...
Read more >
NetSuite Applications Suite - Items/Transactions Accounting ...
Referencing Old (Pre-edit) Values in a Workflow · Defining Conditions for Customer Credit Hold Field · Context Type Examples · Examples of Event...
Read more >
Frequently Asked Questions - Avalara Help Center
How do I resolve 'Tax Calculation is aborted because there are no line items for this transaction' in QuickBooks Desktop?
Read more >
IDEXX Cornerstone 8.3 Administrators Manual
Chapter 1: Getting Started with Cornerstone* Setup. 4. In the New ID column, type the new ID you want to use for this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found