Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Created September 13, 2016 21:30
Show Gist options
  • Save adamjstevenson/cee5d69a3939dee18ed84aba8cf078db to your computer and use it in GitHub Desktop.
Save adamjstevenson/cee5d69a3939dee18ed84aba8cf078db to your computer and use it in GitHub Desktop.
List Connected Account Transfers and Balance
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