Communicating with Stripe w/ list of ids

Howdy, just trying out retool for the first time. I'm trying to paginate over stripe orders. The method I'm using is to grab all of the relevant ids from the current page and query for them in Stripe.
Regardless of how I pass ids to Stripe, the Stripe integration being provided as a comma-separated list, but they need to be query params (eg ids[]=&ids[]=2). Is there a workaround for this?
FWIW here is how I'm grabbing the ids: {{_.compact(_.slice(sorted_orders.data, Orders.paginationOffset, Orders.paginationOffset + Orders.pageSize).map(i => i.stripeOrderId))}}. (I don't have much of a JS background, so that may be less efficient than it could be.
p.s. is there a better way to fetch an entire paginated set of results from Stripe via the integration?

Hi Dave! I think I know what you mean – when we pass objects / arrays to Stripe through our existing integration we’re not properly URL encoding the parameters – is that right?

Yep, exactly!

hey @dave, really sorry about that!

we’ll fix this asap (in the next day or two hopefully). meanwhile, perhaps you can instead use a REST query to unblock yourself:


(i was using products but you can switch this to orders and it should work)

Thanks Abdul! That looks reasonable. If you don’t mind another question, in the larger scope of this post, I’m trying to fill in Stripe data to inform a table - it looks like Retool is invoking that resource each time I page through the table (which is probably fine). Are there any good strategies if I wanted to, say, prefetch all of the data and join it against something else before including it in a table?

I saw another post where Retool folks tried to implement a boundary-limit pager like Stripe uses, and found that it’s a pain in the butt (which is true - it’s not the same as a limit-offset pager). Prefetching everything would help mitigate some of those concerns.

ah, so you just wanna fetch all stripe resources in one go? for example, all stripe orders or something like that

you can have a JS query that fetches each page, and appends to a state variable. here’s an example, where the stripe query is called fetchCustomersPage and the state variable is called allStripeCustomers
`async function fetchAll() {
let res = []

let data = await fetchCustomersPage.trigger()
res = res.concat(data.response.body.data)
allStripeCustomers.setValue(res)

while (data.response.body.has_more) {
const lastId = res[res.length - 1].id
data = await fetchCustomersPage.trigger({ additionalScope: { lastId } })
res = res.concat(data.response.body.data)
allStripeCustomers.setValue(res)
}
}

fetchAll()`

and these are the relevant pieces from fetchCustomersPage:


(note that limit is by default something low, like 10. so you’ll want to explicitly up it to 100, which is the highest that stripe supports)

Hi Dave! I think I know what you mean – when we pass objects / arrays to Stripe through our existing integration we’re not properly URL encoding the parameters – is that right?

Yep, exactly!

hey @dave, really sorry about that!

we’ll fix this asap (in the next day or two hopefully). meanwhile, perhaps you can instead use a REST query to unblock yourself:


(i was using products but you can switch this to orders and it should work)

Thanks Abdul! That looks reasonable. If you don’t mind another question, in the larger scope of this post, I’m trying to fill in Stripe data to inform a table - it looks like Retool is invoking that resource each time I page through the table (which is probably fine). Are there any good strategies if I wanted to, say, prefetch all of the data and join it against something else before including it in a table?

I saw another post where Retool folks tried to implement a boundary-limit pager like Stripe uses, and found that it’s a pain in the butt (which is true - it’s not the same as a limit-offset pager). Prefetching everything would help mitigate some of those concerns.

ah, so you just wanna fetch all stripe resources in one go? for example, all stripe orders or something like that