$Package->setExternalKey($your_subscription_id); // This is for our data usage $LineItem = new ChargeOverAPI_Object_LineItem(); $LineItem->setItemId(13); $Package->addLineItems($LineItem); // This is for our extra # of devices $LineItem = new ChargeOverAPI_Object_LineItem(); $LineItem->setItemId(14); $Package->addLineItems($LineItem); $resp = $API->create($Package); if ($resp->response->id) { // Created the package! // Now, every day you want to push new usage to it // Get the package $resp = $API->find('package', array('external_key:EQUALS:' . $your_subscription_id)); $resp = $API->findById('package', $resp->response[0]->getPackageId()); $Package = $resp->response; $Lines = $Package->getLineItems(); foreach ($Lines as $Line) { if ($Line->getItemExternalKey() == 'data') { // @todo Go fetch the usage from your database for the # of gigabytes $usage_data = 5; // 5 gigabytes } else { if ($Line->getItemExternalKey() == 'devices') { // @todo Go fetch the usage from your database for the # of devices $usage_data = 9; // 9 devices } } // Push the usage
<?php header('Content-Type: text/plain'); require '../ChargeOverAPI.php'; //This url should be specific to your ChargeOver instance $url = 'http://dev.chargeover.com/api/v3'; //$url = 'https://YOUR-INSTANCE-NAME.chargeover.com/api/v3'; $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); //Find a customer by the ChargeOver customer ID $resp = $API->findById('customer', '8'); /* print("\n\n\n\n"); print($API->lastRequest()); print("\n\n\n\n"); print($API->lastResponse()); print("\n\n\n\n"); */ if (!$API->isError($resp)) { $customer = $resp->response; print 'SUCCESS! got back customer: ' . $customer->company; } else { print 'There was an error looking up the customer!' . "\n"; }
<?php header('Content-Type: text/plain'); require '../ChargeOverAPI.php'; //This url should be specific to your ChargeOver instance $url = 'https://dev.chargeover.com/api/v3'; //$url = 'https://YOUR-INSTANCE-NAME.chargeover.com/api/v3'; $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); //Find a customer by the ChargeOver customer ID $resp = $API->findById(ChargeOverAPI_Object::TYPE_INVOICE, 2720); if (!$API->isError($resp)) { $Invoice = $resp->response; print_r($Invoice); //print_r($Invoice->getLineItems()); //print_r($Invoice->getLineItems(1)); //print($Invoice->getCustomerId()); } else { print 'There was an error looking up the invoice!' . "\n"; }