#nanzepanze - list balance transactions
1 messages ยท Page 1 of 1 (latest)
hey ther,e this is because the Go snippet makes use of the client's auto-pagination feature:
https://stripe.com/docs/api/pagination/auto?lang=go
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
which the basic curl request is not using
ok does that mean that setting the filter param "limit" to 3 has no affect unless I disable the client's auto-pagination or have I misunderstood how the filter works with the Go client?
the limit will apply "per request" but with auto pagination this is mostly invisible to you
What are you trying to do?
I want to get the list of transactions for a 24h period
if the transaction is of type: charge, adjustment or refund the transaction's description and amount will be sent to an accounting application
fairly straightforward I think in theory
@full hazel suggested earlier that I use the filter ending_before instead of the created gte and lte filters to look at what transactions were processed the day before #930500521939337226 message
sure, you can use ending_before if you have the ID of the last transaction you processed the day before, this would let you limit to just new ones you haven't seen yet
I'm still unclear on whether I should use the limit filter. When I turned off auto pagination I got back 3 transactions in the same way as I did with curl. What's stripe's best practice with regards to the limit with auto pagination?
The limit is not as relevant when using autopagination. What is your goal?
let's say my stripe account is fresh today and there are no transactions. from tomorrow everyday at midnight get the transactions that have occurred in the previous 24h period
so tomorrow we know the results would be zero. but let's say there are 10 transactions the next day my Go app will retrieve those 10 transactions and do whatever it needs. the next 24 hour period when the app runs it will retrieve any transactions that happens from those 10, e.g. starting at 11
does that make sense?
Sure, so if you keep track of the latest one you know about you can iterate until you hit that then abort. For the first day you would just exhaust the iterator.
I think I got the basics working ๐
Another silly question it may not be specific to the stripe go sdk but I'm not sure. If I want to output the response from the balance_transactions/list endpoint as JSON instead of the balanceTransaction.List go object does the sdk offer an easy way to do that?
SUre! You can access the LastResponse from any result and should be able to get at the RawJson there:
https://github.com/stripe/stripe-go#accessing-the-last-response
https://github.com/stripe/stripe-go/blob/master/stripe.go#L97
very cool! I thought I'd have to make my own struct etc but using LastResponse on the BalanceTransactionList().LastResponse was way easier ๐
thank you very much for your help!
Quite welcome!
anything else you need help with @spark hazel or all set?
NP! have a good one