Created
October 13, 2016 04:06
-
-
Save adamjstevenson/4de54bd08fe5f97eade10c1300c0ebd1 to your computer and use it in GitHub Desktop.
List balance transactions for a specific transfer
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' | |
# Your API key | |
Stripe.api_key = 'YOUR-API-KEY' | |
# Retrieve the balance transactions associated with a specific transfer | |
txns = Stripe::BalanceTransaction.list({ transfer: 'tr_18V4GALrKpFcM2405wrIONb9', limit: 100 }) | |
# Iterate through and list each balance transaction | |
txns.auto_paging_each do | txn | | |
# Don't include the transfer balance transaction | |
unless txn.type.eql?("transfer") | |
# Format the date nicely | |
formatted_date = Time.at(txn.created).getutc.strftime("%m/%d/%Y") | |
# Output the type (charge, refund, adjustment, etc.), ID, amount, and created date | |
puts "#{txn.type},#{txn.source},#{txn.amount},#{formatted_date}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment