Created
March 31, 2015 14:19
-
-
Save alexsegura/bf9143649445e96d2ccc to your computer and use it in GitHub Desktop.
Paymill API pagination
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
<?php | |
$api = new Paymill\Request('private_key'); | |
function get_transactions($api, $count, $offset) { | |
$request = new Paymill\Models\Request\Transaction(); | |
// Other options here | |
$request->setFilter([ | |
'offset' => $offset, | |
'count' => $count | |
]); | |
return $api->getAll($request); | |
} | |
$count = 10; | |
$offset = 0; | |
while ($transactions = get_transactions($api, $count, $offset)) { | |
foreach ($transactions as $transaction) { | |
// Do something | |
} | |
$offset += $count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment