Created
September 13, 2016 21:30
-
-
Save adamjstevenson/cee5d69a3939dee18ed84aba8cf078db to your computer and use it in GitHub Desktop.
List Connected Account Transfers and Balance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'stripe' | |
Stripe.api_key = "YOUR-API-KEY" | |
account = "acct_YourConnectedAccountID" | |
# Retrieve available balance for the connected account | |
balance = Stripe::Balance.retrieve(stripe_account: account) | |
puts "Available balance: #{balance.available[0].amount}" | |
puts "Pending balance: #{balance.pending[0].amount}" | |
# Authenticate as the connected account and retrieve the first 100 transfers | |
transfers = Stripe::Transfer.all({limit: 100}, {stripe_account: account}) | |
# Iterate through created transfers using auto-pagination | |
puts "Past Transfers" | |
transfers.auto_paging_each do |tr| | |
# Format the date nicely | |
formatted_date = Time.at(tr.date).strftime("%m/%d/%Y") | |
# Output the transfer id, amount, and date | |
puts "#{tr.id}, #{tr.amount}, #{formatted_date}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment