Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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."
Add Comment
Please, Sign In to add comment