Skip to main content
knowledgecenter.2checkout.com

Delete usage

Overview

Use the deleteUsages method via SOAP API v6 to delete one or more usage entries based on the provided criteria.

Request Parameters

Parameters Type Required Description
merchantCode String Required The system-generated merchant ID.
sessionID String Required The system-generated code of the session.
hash String Required The MD5 hmac key for the request.
SubscriptionReference String Optional The system-generated reference code of the subscription.
UsageReference Number Optional The system-generated code for usage.
OptionCode String Optional Unique 2Checkout option code.
IntervalStart Number Optional Deletes all usages where UsageEnd >= IntervalStart. Format "YYYY-MM-DD". The timezone used is the one on the server.
IntervalEnd Number Optional Deletes all usages where UsageEnd <= IntervalEnd. Format "YYYY-MM-DD". The timezone used is the one on the server.

Request Sample

<?php
$sb = "58";
$vers = "6.0";
$client = new SoapClient("http://api.sandbox" . $sb . ".avangate.local/soap/$vers/?wsdl", array(
    'location' => "http://api.sandbox" . $sb . ".avangate.local/soap/$vers/",
    'cache_wsdl' => WSDL_CACHE_NONE,
    "trace" => 1));
$date = gmdate('Y-m-d H:i:s');
$merchantCode = "666999";
$key = "%y~8|m]T84p[W4+O1]_?";
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);
$sessionID = $client->login($merchantCode, $date, $hash);
var_dump("session: ", $sessionID);
//$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
$subscriptionReferencee = '4A1D733696';
$usageReference = 120010776516;

try {
    $subscriptionUsageRequest = new stdClass();
    $subscriptionUsageRequest->UsageReference = $usageReference;
    $subscriptionUsageRequest->OptionCode = 'Units 123';
    $subscriptionUsageRequest->IntervalStart = '2020-04-09 16:40:00';
    $subscriptionUsageRequest->IntervalEnd = '2020-04-12 15:40:00';
    $response = $client->deleteSubscriptionUsages($sessionID, $subscriptionReference, $subscriptionUsageRequest);
    var_dump($response);
} catch (SoapFault $ex) {
    $faultname = (isset($ex->faultname)) ? " $faultname" : '';
    echo "[$ex->faultcode]$faultname: $ex->faultstring" . PHP_EOL;
}

exit;

Response 

Success

NULL

Error

[NOT_FOUND]: Usage line described does not exist

 

  • Was this article helpful?