Created
November 22, 2015 20:10
-
-
Save adamjstevenson/2fcfb7f9344f5c121f85 to your computer and use it in GitHub Desktop.
Paginate failed Stripe charges (Python)
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
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