<?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); $user_id = 350; $User = new ChargeOverAPI_Object_User(array('name' => 'Ryan Bantz', 'email' => '*****@*****.**')); $resp = $API->modify($user_id, $User); if (!$API->isError($resp)) { print 'Updated the user!'; print "\n\n\n\n"; print $API->lastRequest(); print "\n\n\n\n"; print $API->lastResponse(); print "\n\n\n\n"; } else { print 'Error updating user via API: ' . $resp->message; print "\n\n\n\n"; print $API->lastRequest(); print "\n\n\n\n"; print $API->lastResponse(); print "\n\n\n\n"; }
// The invoice we want to update $invoice_id = 10009; // Build up the object $Invoice = new ChargeOverAPI_Object_Invoice(); $Invoice->setDate('2015-06-08'); $LineItem = new ChargeOverAPI_Object_LineItem(); $LineItem->setItemId(3); $LineItem->setLineRate(29.95); $LineItem->setLineQuantity(3); $LineItem->setDescrip('Add this new line item to the invoice.'); $Invoice->addLineItems($LineItem); // To keep the existing line item, you have to pass the line_item_id $LineItem = new ChargeOverAPI_Object_LineItem(); $LineItem->setLineItemId(2575); $Invoice->addLineItems($LineItem); $resp = $API->modify($invoice_id, $Invoice); /* 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)) { $invoice_id = $resp->response->id; print 'SUCCESS! Invoice # is: ' . $invoice_id; } else { print 'Error saving invoice via API' . "\n"; print 'Error message was: ' . $resp->code . ': ' . $resp->message . "\n"; print "\n\n\n\n"; print $API->lastRequest();
<?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); $customer_id = 3; $Customer = new ChargeOverAPI_Object_Customer(array('company' => 'Test API Company, LLC', 'bill_addr1' => mt_rand(0, 1000) . ' ChargeOver Street', 'bill_addr2' => 'Suite 10', 'bill_city' => 'Minneapolis', 'bill_state' => 'MN', 'bill_postcode' => '55416', 'bill_country' => 'USA', 'external_key' => 'abcd' . mt_rand(1, 10000), 'superuser_name' => 'David Palmer', 'superuser_email' => '*****@*****.**', 'superuser_phone' => '860-634-1111')); $resp = $API->modify($customer_id, $Customer); if (!$API->isError($resp)) { print 'SUCCESS! Customer # ' . $customer_id . ' was updated!'; } else { print 'Error saving customer via API'; print "\n\n\n\n"; print $API->lastRequest(); print "\n\n\n\n"; print $API->lastResponse(); print "\n\n\n\n"; }