Search methods pagination
Last updated: 17-Oct-2019
Rate this article:
Overview
Starting with 2Checkout API 5.0, search methods are including the option of pagination. Pagination has been developed for decreasing the request loading time while allowing you to better handle the returning responses.
How does it work?
Pagination works on all the search methods existing on 2Checkout API 5.0. The default pagination behavior is to display page 1 with 10 results. The maximum number of items displayed on a single page is 200.
Parameters
To use pagination, include the Pagination object inside the search method call, using the parameters below:
Parameters | Type/Description | |
---|---|---|
Pagination | Object | |
Details below. | ||
Page | Int | |
Set the number of pages that should be returned. | ||
Limit | Int | |
Set a limit for the number of results that should be returned. |
Response
The response of search methods that are including pagination will contain a new object, with the following parameters:
Parameters | Type/Description | |
---|---|---|
Pagination | Object | |
Details below | ||
Page | Int | |
Set the number of pages that should be returned. | ||
Limit | Int | |
Set a limit for the number of results that should be returned. | ||
Count | Int | |
Number of total results returned |
Sample request
The below PHP sample includes a search method for subscriptions.
<?php
require('PATH_TO_AUTH');
$SubscriptionSearch = new stdClass();
$SubscriptionSearch->CustomerEmail = 'email@avangate.com';
$SubscriptionSearch->DeliveredCode = null;
$SubscriptionSearch->AvangateCustomerReference = null;
$SubscriptionSearch->ExternalCustomerReference = null;
$SubscriptionSearch->Aggregate = false;
$SubscriptionSearch->SubscriptionEnabled = null; //true false null
$SubscriptionSearch->RecurringEnabled = null; // true - autorenewal, false - manual renewal, null = both(default)
$SubscriptionSearch->ProductCodes = null; //array('Product_Code1', 'Product_Code2');
$SubscriptionSearch->CountryCodes = null;//array ('au')
$SubscriptionSearch->PurchasedAfter = null;
$SubscriptionSearch->PurchasedBefore = null;
$SubscriptionSearch->ExpireAfter = null;
$SubscriptionSearch->ExpireBefore = null;
$SubscriptionSearch->LifetimeSubscription = null;
$SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial'
$SubscriptionSearch->TestSubscription = null; // true, false, null = both(default)
$SubscriptionSearch->Pagination = new stdClass();
$SubscriptionSearch->Pagination->Page = 1; // set the number of pages for the response
$SubscriptionSearch->Pagination->Limit = 200; // set the limit for the values from the response
try {
$accountSubscriptions = $client->searchSubscriptions($sessionID, $SubscriptionSearch);
}
catch (SoapFault $e) {
echo "accountSubscriptions: " . $e->getMessage();
exit;
}
var_dump("accountSubscriptions", $accountSubscriptions);
Rate this article: