Retrieve customer orders
Use the getCustomerOrders method to retrieve the orders belonging to a specific customer, across all of the customer’s subscriptions.
You can identify the customer either by the 2Checkout customer ID (CustomerReference) or by the external customer ID that you assigned (ExternalCustomerReference). The result is paginated, and the orders are sorted by order date, most recent first. An order that is referenced by more than one subscription of the customer is returned only once.
If the customer exists but has no subscriptions, the method returns an empty list of orders instead of an error.
Request parameters
sessionID
Required (string)
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes.
CustomerReference
Optional (int)
The internal 2Checkout customer ID. One of CustomerReference or ExternalCustomerReference is required.
ExternalCustomerReference
Optional (string)
The external customer ID that you control. One of CustomerReference or ExternalCustomerReference is required. If you include both, they must belong to the same customer.
Page
Optional (int)
Page number, starting from 1. Defaults to 1.
Limit
Optional (int)
Number of orders per page. Defaults to 10. Must be between 1 and 200.
Request sample
<?php
require ('PATH_TO_AUTH');
$options = new stdClass();
$options->ExternalCustomerReference = '666';
$options->Page = 1;
$options->Limit = 10;
$jsonRpcRequest = array (
'method' => 'getCustomerOrders',
'params' => array($sessionID, $options),
'id' => $i++,
'jsonrpc' => '2.0');
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));Response parameters
Items
Array of objects
Each item has the same structure as a single order returned by the getOrder method.
Pagination
Object
Pagination object with the following parameters:
Page — the requested page.
Limit — the requested page size.
Count — the total number of distinct orders of the customer, across all pages. The value is the same even if Page is past the last page of results.
Error codes
FORBIDDEN
The method is not enabled for your account.
INVALID_CUSTOMER
Neither CustomerReference nor ExternalCustomerReference was provided, the two references belong to different customers, or the customer does not exist.
PAGINATION_PAGE_PARAMETER_INVALID
Page is not a valid integer greater than or equal to 1.
PAGINATION_LIMIT_PARAMETER_INVALID
Limit is not between 1 and 200.
Last updated
Was this helpful?