Created
July 16, 2018 04:35
-
-
Save shuklaneerajdev/c79ef2dc91c466a7bb48693c69ac2139 to your computer and use it in GitHub Desktop.
This file contains 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" | |
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