Delete usage
Use the deleteSubscriptionUsages method via JSON-RPC API 6.0 to delete usage entered for a specific subscription, price options group, and usage interval.
Request parameters
merchantCode
Required (string)
The system-generated merchant ID.
sessionID
Required (string) The system-generated code of the session.
hash
Required (string) The MD5 hmac key for the request.
SubscriptionReference
Required (string) Unique code that represents a subscription. Example: 83FE4FEF2.
UsageReference
Optional (number) The system-generated reference code for the usage of the subscription.
OptionCode
Optional (string)
Unique 2Checkout option code. The pay-per-usage price options group for which the usage is uploaded. Example: metered pricing.
IntervalStart
Optional (datetime)
(mandatory if IntervalEnd is provided)
Deletes all usages where UsageEnd >= IntervalStart. Format "YYYY-MM-DD". The timezone used is the one on the server.
IntervalEnd
Optional (datetime)
(mandatory if IntervalStart is provided)
Deletes all usages where UsageEnd <= IntervalEnd. Format "YYYY-MM-DD". The timezone used is the one on the server.
Request Sample
<?php
require ('PATH_TO_AUTH'); // authentication call
$SubscriptionReference = 'B7D8E72224';
$UsageReference = 120010776516;
$jsonRpcRequest = array('jsonrpc' => '2.0', 'method' => 'deleteSubscriptionUsages', 'params' => array($sessionID, 'SubscriptionReference' => $SubscriptionReference, array("UsageReference" => $UsageReference, "OptionCode" => 'USG_MN', "IntervalStart" => "2018-04-14 13:00:10", "IntervalEnd" => "2020-09-16 13:00:10")), 'id' => $i++);
var_dump ("deleteSubscriptionUsages", callRPC((Object)$jsonRpcRequest, $host));Response
The deleteSubscriptionUsages method via JSON-RPC APIv6 returns NULL when successful.
Error handling
The deleteSubscriptionUsages via JSON-RPC APIv6 returns FALSE if:
Provided parameters lack the required type or format.
MALFORMED_PARAMETER
One or more parameters lack the required format: SubscriptionReference must be a string.
MALFORMED_PARAMETER
One or more parameters lack the required format: UsageReference must be a positive integer higher than or equal to 1.
MALFORMED_PARAMETER
One or more parameters lack the required format: Units must be a positive integer higher than or equal to 1.
MALFORMED_PARAMETER
One or more parameters lack the required format: IntervalStart must be a string.
MALFORMED_PARAMETER
One or more parameters lack the required format: IntervalEnd must be a string.
The subscription or usage line are not found.
NOT_FOUND
Subscription not found.
NOT_FOUND
Usage line described does not exist.
The usage line is already billed.
ALREADY_BILLED
Usage was not deleted as this usage was already billed.
The renewal process is in progress for this subscription.
RENEWAL_IN_PROGRESS
There is a renewal in progress for the provided usage line.
An unexpected error happens.
GENERIC
There has been an error deleting the usage line. Please try again later.
Last updated
Was this helpful?