Skip to content

Instantly share code, notes, and snippets.

@alexsegura
Created March 31, 2015 14:19
Show Gist options
  • Save alexsegura/bf9143649445e96d2ccc to your computer and use it in GitHub Desktop.
Save alexsegura/bf9143649445e96d2ccc to your computer and use it in GitHub Desktop.
Paymill API pagination
<?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