Last active
December 15, 2017 13:06
-
-
Save adamjstevenson/e7ebf64a44cc88e8c0ec to your computer and use it in GitHub Desktop.
Paginate Stripe `invoice.payment_succeeded` events (Node)
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
var stripe = require('stripe')('sk_your_api_key'); | |
stripe.events.list( | |
{ limit: 100, type: 'invoice.payment_succeeded' }, | |
function(err, events) { | |
for (i = 0; i < events.data.length; i++){ | |
console.log(events.data[i].id); | |
} | |
if (events.has_more) { | |
paginateEvents(events["data"][events["data"].length - 1].id); | |
} | |
} | |
) | |
function paginateEvents(starting_after) { | |
stripe.events.list( | |
{ limit: 100, type: 'invoice.payment_succeeded', starting_after: starting_after }, | |
function(err, events) { | |
for (i = 0; i < events.data.length; i++){ | |
console.log(events.data[i].id); | |
} | |
if (events.has_more) { | |
paginateEvents(events["data"][events["data"].length - 1].id); | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment