Search methods pagination
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.
Request parameters
To use pagination, include the Pagination object inside the search method call, using the parameters below:
Pagination
Object Details below.
Pagination.Page
Int Set the number of pages that should be returned.
Pagination.Limit
Int Set a limit for the number of results that should be returned.
Request sample
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);Response parameters
The response of search methods that are including pagination will contain a new object, with the following parameters:
Pagination
Object Details below
Pagination.Page
Int Set the number of pages that should be returned.
Pagination.Limit
Int Set a limit for the number of results that should be returned.
Pagination.Count
Int Number of total results returned
Last updated
Was this helpful?