Retrieve usage
Use the getSubscriptionUsages method SOAP API 6.0 to filter and retrieve usages for a subscription.
Request parameters
merchantCode
String
Required
String. The system-generated merchant ID.
hash
String
Required
String. The MD5 hmac key for the request.
sessionID
String
Required
String. The system-generated code of the session.
SubscriptionReference
String
Required
String. The system-generated reference code of the subscription.
Page
Number
Required
Number. Page to be retrieved.
Limit
Number
Required
Number. The number of results per page.
IntervalStart
Datetime
Required
Date. Filters all usages with UsageEnd >= IntervalStart. Format "YYYY-MM-DD". The timezone used is the one on the server.
IntervalEnd
Datetime
Required
Date. Filters all usages with UsageEnd <= IntervalEnd. Format "YYYY-MM-DD". The timezone used is the one on the server.
RenewalOrderReference
Number
Optional
Number. The reference code generated by the system when the subscription is renewed.
OptionCode
String
Optional
Unique 2Checkout option code. The pay-per-usage price options group for which the usage is uploaded. Example: metered pricing.
Request sample
<?php
require ('PATH_TO_AUTH'); // authentication call
$subscriptionReference = 'EF4B51535B';
$usageReference = 120010492176;
try {
$subscriptionUsageRequest = new stdClass();
$subscriptionUsageRequest->SubscriptionReference = $subscriptionReference;
$subscriptionUsageRequest->Page = 1;
$subscriptionUsageRequest->Limit = 10;
$subscriptionUsageRequest->IntervalStart = '2020-04-09 16:40:00';
$subscriptionUsageRequest->IntervalEnd = '2020-04-12 15:40:00';
$response = $client->getSubscriptionUsages($sessionID, $subscriptionUsageRequest);
var_dump($response);
} catch (SoapFault $ex) {
$faultname = (isset($ex->faultname)) ? " $faultname" : '';
echo "[$ex->faultcode]$faultname: $ex->faultstring" . PHP_EOL;
}
exit;Response
The getUsages method via SOAP APIv6 returns the Usage object when successful.
Error handling
The below errors are returned when the getUsages method via SOAP APIv6 is unsuccessful.
The provided parameters lack the required type or format.
SEARCH_PAGE_INVALID
The Page parameter must be a positive integer higher than or equal to 1.
SEARCH_LIMIT_INVALID
The Limit parameter must be a positive integer lower than 100.
MANDATORY_FIELDS_MISSING
Both 'IntervalStart' and 'IntervalEnd' parameters must be provided.
FILTER_INVALID
If provided, 'RenewalOrderReference' must be a positive integer.
FILTER_INVALID
'IntervalStart' must be provided in the following format: YYYY-MM-DD HH:MM:SS.
FILTER_INVALID
'IntervalStart' must be provided in the following format: YYYY-MM-DD HH:MM:SS.
FILTER_INVALID
'IntervalEnd' must be provided in the following format: YYYY-MM-DD HH:MM:SS.
FILTER_INVALID
'IntervalEnd' must be provided in the following format: YYYY-MM-DD HH:MM:SS.
SEARCH_PAGE_INVALID
The Page parameter must be a positive integer higher than or equal to 1.
SUBSCRIPTION_NOT_FOUND
Subscription not found.
Unexpected error happens
INTERNAL_ERROR
<unexpected_error>
Last updated
Was this helpful?