Skip to main content

Cancel Subscription Line

Cancel a subscription line.

Example

Use the $API->action('package', 595, 'upgrade', $data); method to cancel line 611 in subscription #592.

<?php

header('Content-Type: text/plain');

require '../ChargeOverAPI.php';
require 'config.php';

$API = new ChargeOverAPI($url, $authmode, $username, $password);

$data = array(
'line_items' => array(
0 => array(

// The line_item_id to cancel
'line_item_id' => 611,

// Tell it to cancel this line
'cancel' => true
),
),
);

$resp = $API->action('package', 595, 'upgrade', $data);

/*
print("\n\n\n\n");
print($API->lastRequest());
print("\n\n\n\n");
print($API->lastResponse());
print("\n\n\n\n");
exit;
*/

if (!$API->isError($resp))
{
print('SUCCESS!');
}
else
{
print('Error message was: ' . $resp->code . ': ' . $resp->message . "\n");

print("\n\n\n\n");
print($API->lastRequest());
print("\n\n\n\n");
print($API->lastResponse());
print("\n\n\n\n");
}