Guest User

Untitled

a guest
Jul 15th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. require "stripe"
  2. Stripe.api_key = "YOUR_API_KEY"
  3. def grab_and_process_charges(list_of_charges)
  4. # complete the task that you need to do with your list of charges
  5. list_of_charges.each do |charge|
  6. puts "charge id is #{charge['id']} and the amount is #{charge['amount']} in currency #{charge['currency']}"
  7. end
  8. end
  9.  
  10. list_of_charges = Stripe::Charge.list(limit: 10)
  11. grab_and_process_charges(list_of_charges)
  12. while list_of_charges['has_more']
  13. puts "Iterating...."
  14. next_list_of_charges = Stripe::Charge.list(limit: 10, starting_after: list_of_charges['data'][list_of_charges['data'].length-1]['id'])
  15. list_of_charges = next_list_of_charges
  16. grab_and_process_charges(list_of_charges)
  17. end
  18. puts "Done with processing all the charges."
Add Comment
Please, Sign In to add comment