#Jasuno
1 messages · Page 1 of 1 (latest)
Hello
Yep you can list balance transactions for a Connected Account using https://stripe.com/docs/api/balance_transactions/list and passing the Stripe Account Header (see: https://stripe.com/docs/connect/authentication)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
const balanceTransactions = await stripe.balanceTransactions.list({ limit: 3, }, { stripeAccount: {{CONNECT_ACCOUNT}} });
so that should work?
Yep that looks good
These headers work with all the API functions?
One more thing, i'm using typescript in the client side application and i will be sending those transactions to the front end, is there a library of these types? so my front end knows what type it will be receiving?
Yes
The type declarations in StripeJS package will always track to the latest version of the Stripe API.
So https://www.npmjs.com/package/@stripe/stripe-js this package?
Yep
I tried this before and i notice that the types there do not match for example if i call
const balance = await stripe.balance.retrieve({ stripeAccount: user?.stripeId, });
There API returns a type of Balance, which does not match the Balance type in that library
Hmm not super familiar with typescript overall, one moment, let me confer with a colleague
Can you show me exactly what you are seeing?
They should match as far as I know
Hello
Hey! Okay got more context
sorry got pulled in to a meeting
Basically, Stripe.JS doesn't have types for everything in our API. You can see the types it does support here: https://github.com/stripe/stripe-js/tree/master/types. Instead, for something like the Balance object you would create your own frontend types for this, but you are really better off just parsing the relevant pieces you want when retrieving on the backend and then passing those pieces to the frontend and building types for those specific pieces.
Ok so as I understand it, there is no shared library between API types and one that you have access in the front-end, instead we need to create all of our own types, preferably only including what ever we are sending back.
Yes overall that is correct. There are some shared types (like with an object like PaymentIntent -- see: https://github.com/stripe/stripe-js/blob/master/types/api/payment-intents.d.ts) but for most there won't be.
Thanks that helps a lot, i think thats it, thanks for all the help, it would be cool if more for those types were accessible from the front end.
I'll pass along that feedback