Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Created November 22, 2015 20:10
Show Gist options
  • Save adamjstevenson/2fcfb7f9344f5c121f85 to your computer and use it in GitHub Desktop.
Save adamjstevenson/2fcfb7f9344f5c121f85 to your computer and use it in GitHub Desktop.
Paginate failed Stripe charges (Python)
import stripe
stripe.api_key = "sk_your_api_key"
charges = stripe.Charge.all(limit=100, paid='false', include=['total_count'])
print (str(charges.total_count) + ' charges failed.')
for charge in charges.data:
print(charge.id + ' failed. Failure code: '+charge.failure_code)
while charges.has_more:
charges = stripe.Charge.all(limit=100, starting_after=charges.data[-1], paid='false')
for charge in charges.data:
print(charge.id + ' failed. Failure code: '+charge.failure_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment