Skip to content

Commit 4bd2ebb

Browse files
committed
Merge branch 'add-bulk-listing-and-pagination'
2 parents ed45079 + c990247 commit 4bd2ebb

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ $merchants = $paylike->merchants();
6363
$merchants->create($args);
6464
$merchants->fetch($merchant_id);
6565
$merchants->update($merchant_id, $args);
66+
$all_merchants = $merchants->get($app_id,$limit,$before);
6667

6768
$cards = $paylike->cards();
6869
$cards->create($merchant_id, $args);
@@ -74,8 +75,29 @@ $transactions->fetch($transaction_id);
7475
$transactions->capture($transaction_id, $args);
7576
$transactions->void($transaction_id, $args);
7677
$transactions->refund($transaction_id, $args);
78+
$all_transactions = $transactions->get($merchant_id,$limit,$before);
7779
```
7880

81+
## Pagination
82+
The methods that allow fetching all transactions/merchants support pagination. By default they are limited to the last 10 items.
83+
An example of handling pagination to fetch all available transactions:
84+
85+
```php
86+
$transactions = array();
87+
$limit = 10;
88+
$before = null;
89+
90+
do {
91+
$api_transactions = $this->transactions->get($merchant_id, $limit, $before);
92+
if (count($api_transactions) < $limit) {
93+
$before = null;
94+
} else {
95+
$before = $api_transactions[$limit - 1]['id'];
96+
}
97+
$transactions = array_merge($transactions, $api_transactions);
98+
} while ($before);
99+
```
100+
79101
## Error handling
80102

81103
The api wrapper will throw errors when things do not fly. All errors inherit from

0 commit comments

Comments
 (0)