<?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 external key //$resp = $API->find('customer', array('external_key:EQUALS:XFTE-KEY')); //Get all customers from MN $resp = $API->find('customer', array('bill_state:EQUALS:MN')); /* 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 = '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); // Get records 10 at a time, starting with the first record $offset = 0; $limit = 10; $where = array(); $sort = array('customer_id:ASC'); // Order by customer_id // Get all customers, 10 at a time (10 per page) do { $resp = $API->find('customer', $where, $sort, $offset, $limit); $customers = $resp->response; print 'Showing customers ' . $offset . ' through ' . ($offset + $limit) . "\n"; foreach ($customers as $customer) { print ' Customer ID: ' . $customer->customer_id . ', Name: ' . $customer->company . "\n"; } print "\n\n\n"; $offset += $limit; // Increment so that we get the next set } while (count($customers) >= $limit); //print($API->lastRequest()); //print($API->lastResponse());
<?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); // Get a list of all countries $resp = $API->find('country'); /* 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)) { $countries = $resp->response; foreach ($countries as $country) { //print_r($customer); print 'Country: ' . $country->name . "\n"; print "\n"; } } else { print 'Error getting customer list' . "\n"; }
<?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); //Get all customers $resp = $API->find('note', array('obj_type:EQUALS:customer', 'obj_id:EQUALS:328')); /* 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)) { $notes = $resp->response; print_r($notes); } else { print 'Error getting notes' . "\n"; print_r($API->lastResponse()); }
<?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 payments for a specific invoice $resp = $API->find('transaction', array('transaction_type:EQUALS:pay', 'applied_to.invoice_id:EQUALS:10036')); if (!$API->isError($resp)) { $transactions = $resp->response; // Loop through the found invoices and print them out foreach ($transactions as $Payment) { print_r($Payment); } } /* print($API->lastRequest()); print($API->lastResponse()); */
// Here is your unique subscription ID # $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 } }
<?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); //Get all customers $resp = $API->find('customer'); /* 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)) { $customers = $resp->response; foreach ($customers as $customer) { //print_r($customer); print 'Customer ID: ' . $customer->customer_id . ', Name: ' . $customer->company . "\n"; print ' You can also use ->get*() methods: ' . $customer->getCustomerId() . ', Name: ' . $customer->getCompany() . "\n"; print "\n"; } } else { print 'Error getting customer list' . "\n"; }
<?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->find(ChargeOverAPI_Object::TYPE_INVOICE, array('customer_id:EQUALS:68'), array('invoice_id:DESC')); if (!$API->isError($resp)) { $invoices = $resp->response; // Loop through the found invoices and print them out foreach ($invoices as $Invoice) { print_r($Invoice); } } else { print 'There was an error looking up the invoice!' . "\n"; print 'Error: ' . $API->lastError(); print 'Request: ' . $API->lastRequest(); print 'Response: ' . $API->lastResponse(); print 'Info: ' . print_r($API->lastInfo(), true); }