Been exploring how to get all invoices for one customer using Stripe.js 2. For starters, I am able to pull all without a problem, but when I try to pull invoices for just one customer, I have no idea how to get the Stripe “CustomerID” added in the expression.
I have the CustomerID saved in my DB. I know that the API call “List All Invoices” can use the “CustomerID”. However, the plugin seems not to allow for this? Am I correct? Hence, why am struggling?
Gotcha - yeah Bubble doesn’t handle “loops + API calls” very well (so each item would make a separate call to get data)
I think there are a couple options you have:
you can do what @boston85719 said and try and filter the list of all invoices by customer_id (but that would run into an issue with pagination as the response would only be able to have 100 records I believe)
Alternatively you can “cache” the invoice data for each customer, meaning make those API calls for each user and store their invoice data somewhere in the Bubble database. Unfortunately this means you will need to add a non-trivial amount of complexity to your application architecture since this means to do it right you either need a scheduled workflow that syncs data or you will need to pay attention to Stripe webhook for invoice creation
If I understand your use-case you are trying to list all your customers and get some invoice related information? It might help if you explained exactly what you are trying to render on this page as there might be a different way to do what you are trying to do
I have followed your instructions to pull the customer information related from my stripe account and it seem to work fine except the dates. (thank you so much for that )
This first screenshot show the way it looks on my app. I can see the number, the amount and the status but the other number you see (163339418) supposed to be the “period start date” (You can see on the secon screen shot