Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.