Stripe.js 2: Pulling All Invoices For One Customer

Hi All,

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.

Would appreciate any guidance or hints.

Hey Bry,

Could you expand on your use-case a bit?

There should be a Stripe customer object for every customer you have (each with their own customer_id)

I always recommend storing that customer_id in the Bubble database upon creation of new subscriptions/customers

Hi Ben!

Been watching your videos! Thanks for helping me.

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?

Here’s what I have so far, which does return all customer names.

1) Repeating Group

2) Cells

Could you filter the data that is returned from the Stripe.js - List all Invoices’s data using the customer id?

If the customer data is available through that Stripe.js call you should be able to use the customers id stored in your DB as a filter.

That’s the problem. I am not able to filter the data using the CustomerID.

For now, I have created my own call accessing the Invoice object directly. This did the trick leaving the “Parameter” dynamic.

Will close for now :slight_smile:

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

Hi Ben,

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 :slight_smile: )

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

And the same result happen for any type of date that I try to pull from stripe. Do you have any idea why this is happening?

Have you tried adding the “…formatted” as option for dates?

image