#alexander-1966_api

1 messages ยท Page 1 of 1 (latest)

red folioBOT
#

๐Ÿ‘‹ 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.

misty flint
#

hi! I would list invoices filtered by subscription and look for the most recent one that's been paid, yes.

dry oar
#

ok, wanted to check if there's an easier way that I missed

misty flint
dry oar
#

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

ocean briar
#

You'll only get paid invoices for the sub_xxx and then you can derive the period from there

dry oar
#

yeah, true

ocean briar
#

So that one API call should work for you as the first item in the index will be the most recent paid invoice

dry oar
#

yeah ๐Ÿ‘ thanks for confirming

#

that's all, appreciate your support ๐Ÿ™‡โ€โ™‚๏ธ