Skip to content

Instantly share code, notes, and snippets.

@agentcoops
Created August 31, 2015 00:20
Show Gist options
  • Save agentcoops/5969eaaa0f628f9e7eaf to your computer and use it in GitHub Desktop.
Save agentcoops/5969eaaa0f628f9e7eaf to your computer and use it in GitHub Desktop.
Sum your charges
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