Skip to content

Instantly share code, notes, and snippets.

@shuklaneerajdev
Created July 16, 2018 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuklaneerajdev/c79ef2dc91c466a7bb48693c69ac2139 to your computer and use it in GitHub Desktop.
Save shuklaneerajdev/c79ef2dc91c466a7bb48693c69ac2139 to your computer and use it in GitHub Desktop.
require "stripe"
Stripe.api_key = "YOUR_API_KEY"
def grab_and_process_charges(list_of_charges)
# complete the task that you need to do with your list of charges
list_of_charges.each do |charge|
puts "charge id is #{charge['id']} and the amount is #{charge['amount']} in currency #{charge['currency']}"
end
end
list_of_charges = Stripe::Charge.list(limit: 10)
grab_and_process_charges(list_of_charges)
while list_of_charges['has_more']
puts "Iterating...."
next_list_of_charges = Stripe::Charge.list(limit: 10, starting_after: list_of_charges['data'][list_of_charges['data'].length-1]['id'])
list_of_charges = next_list_of_charges
grab_and_process_charges(list_of_charges)
end
puts "Done with processing all the charges."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment