#alexander-1966_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1284104007341838369
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! I would list invoices filtered by subscription and look for the most recent one that's been paid, yes.
ok, wanted to check if there's an easier way that I missed
your retrieve call doesn't make sense to me. It would be more like invoices = Stripe::Invoice.list({subscription:"sub_xxx", status:"paid"}) and look at the first one, which is most recent.
the retrieve code is for finding the corresponding line item for that subscription (to fetch its period)
the part ...[:lines][:data].find {|x| x[:id] == 'sub_...'} is for finding the correct line in case the invoice has multiple items
Hmm, but that part seems redundant if you just use the list endpoint and pass the subscription and status params: https://docs.stripe.com/api/invoices/list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You'll only get paid invoices for the sub_xxx and then you can derive the period from there
yeah, true
So that one API call should work for you as the first item in the index will be the most recent paid invoice