Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active December 15, 2017 13:03
Show Gist options
  • Save adamjstevenson/a58c302d4c77dc688dbb2d826488e14e to your computer and use it in GitHub Desktop.
Save adamjstevenson/a58c302d4c77dc688dbb2d826488e14e to your computer and use it in GitHub Desktop.
List charges on a connected account
require 'stripe'
Stripe.api_key = "YOUR-API-KEY"
# Authenticate as the connected account and retrieve the first 100 charges
charges = Stripe::Charge.all({limit: 100},{stripe_account: "acct_YourConnectedAccountID"})
# Iterate through charges using auto-pagination
charges.auto_paging_each do |charge|
# Output the charge ID, amount, currency, refund, and dispute status
charge.dispute ? dispute = charge.dispute.id : dispute = "none"
puts "#{charge.id},#{charge.amount},#{charge.currency},#{charge.refunded},#{dispute}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment