Created
August 31, 2015 00:20
-
-
Save agentcoops/5969eaaa0f628f9e7eaf to your computer and use it in GitHub Desktop.
Sum your charges
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
Stripe.api_key = # your API key | |
nextCharges = Stripe::Charge.all(:limit => 100) | |
data = nextCharges.data | |
while nextCharges.has_more do | |
nextCharges = Stripe::Charge.all(:limit => 100, :starting_after => data[data.length - 1].id) | |
data = data + nextCharges.data | |
end | |
data.inject(0) {| sum, nextCharge | sum + nextCharge.amount } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment