* in an error message. * * See the docs for more details: * http://chargeover.com/docs/rest-api.html#external-keys * * @author Keith Palmer <*****@*****.**> */ 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_SIGNATURE_V1; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // Here's the external key we're going to try to use more than once $external_key = 'duplicate key ' . mt_rand(0, 100); $Customer = new ChargeOverAPI_Object_Customer(array('company' => 'Test API Company, LLC', 'bill_addr1' => '123 ChargeOver Street', 'bill_addr2' => 'Suite 10', 'bill_city' => 'Minneapolis', 'bill_state' => 'MN', 'bill_postcode' => '55416', 'bill_country' => 'USA', 'external_key' => $external_key)); // This ***should*** generate an error after the first request (each subsequent request should be a duplicate key) for ($i = 0; $i < 5; $i++) { $resp = $API->create($Customer); //print($API->lastResponse()); //exit; if (!$API->isError($resp)) { $customer_id = $resp->response->id; print 'SUCCESS! Customer # is: ' . $customer_id . "\n"; } else { print 'ERROR! The error message was: ' . $resp->message . "\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); $Item = new ChargeOverAPI_Object_Item(array('name' => 'My Test Item ' . mt_rand(0, 1000), 'type' => ChargeOverAPI_Object_Item::TYPE_SERVICE, 'pricemodel' => array('base' => 295.95, 'pricemodel' => ChargeOverAPI_Object_Item::PRICEMODEL_FLAT))); // Create the user $resp = $API->create($Item); // Check for errors if (!$API->isError($resp)) { $item_id = $resp->response->id; print 'SUCCESS! Item # is: ' . $item_id; } else { print 'Error saving item via API'; print "\n\n"; print $API->lastRequest() . "\n\n"; print $API->lastResponse() . "\n\n"; } print $API->lastRequest() . "\n\n"; print $API->lastResponse() . "\n\n";
<?php header('Content-Type: text/plain'); require '../ChargeOverAPI.php'; //This url should be specific to your ChargeOver instance $url = 'http://dev.chargeover.com/signup/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 = new ChargeOverAPI_Object_User(array('customer_id' => 1, 'password' => 'some test password', 'name' => 'Ryan Bantz', 'email' => '*****@*****.**', 'phone' => '888-555-1212')); // Create the user $resp = $API->create($User); // Check for errors if (!$API->isError($resp)) { $user_id = $resp->response->id; print 'SUCCESS! User/contact # is: ' . $user_id; } else { print 'Error saving user/contact via API'; 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); $Note = new ChargeOverAPI_Object_Note(array('note' => 'Here is my test note', 'obj_type' => 'customer', 'obj_id' => 328)); // Create the user $resp = $API->create($Note); // Check for errors if (!$API->isError($resp)) { $note_id = $resp->response->id; print 'SUCCESS! Note # is: ' . $note_id; } else { print 'Error saving note via API'; print $API->lastResponse(); } /* print($API->lastRequest()); print("\n\n\n"); print($API->lastResponse()); */
$username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); $Package = new ChargeOverAPI_Object_Package(); $Package->setCustomerId(18); // Tell it to use whatever ACH account is on file for this customer //$Package->setPaymethod('ach'); //$Package->setPaymethod('crd'); // ... or whichever credit card // By default, ChargeOver will create MONTHLY recurring packages - but you can change this: //$Package->setPaycycle('yrl'); // yearly //$Package->setPaycycle('qtr'); // quarterly // @todo more cycles docs $LineItem = new ChargeOverAPI_Object_LineItem(); $LineItem->setItemId(1); //$LineItem->setDescrip('Test of a description goes here.'); $LineItem->setTrialDays(20); $LineItem->setLineQuantity(15); $Package->addLineItems($LineItem); $resp = $API->create($Package); if (!$API->isError($resp)) { $package_id = $resp->response->id; print 'SUCCESS! Package # is: ' . $package_id; } else { print 'Error saving package via API' . "\n"; 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"; }
<?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 = 1; $CreditCard = new ChargeOverAPI_Object_CreditCard(array('customer_id' => $customer_id, 'number' => '4111 1111 1111 1111', 'expdate_year' => '2016', 'expdate_month' => '11', 'name' => 'John Doe')); $resp = $API->create($CreditCard); if (!$API->isError($resp)) { $creditcard_id = $resp->response->id; print 'SUCCESS! Stored credit card as creditcard_id #: ' . $creditcard_id; } else { print 'Error saving credit card via API!'; 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); $customer_id = 1560; $ACH = new ChargeOverAPI_Object_Ach(array('customer_id' => $customer_id, 'type' => ChargeOverAPI_Object_Ach::TYPE_CHECKING, 'number' => '1234 1234 1234', 'routing' => '072403004', 'name' => 'John Doe')); $resp = $API->create($ACH); if (!$API->isError($resp)) { $ach_id = $resp->response->id; print 'SUCCESS! Stored ACH/eCheck account as ach_id #: ' . $ach_id; } else { print 'Error saving ACH/eCheck account via API!'; print $API->lastResponse(); }
$password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); $Invoice = new ChargeOverAPI_Object_Invoice(); $Invoice->setCustomerId(1); $Invoice->setDate('2014-01-02'); $LineItem = new ChargeOverAPI_Object_LineItem(); $LineItem->setItemId(4); $LineItem->setLineRate(29.95); $LineItem->setLineQuantity(3); $LineItem->setDescrip('Test of a description goes here.'); $Invoice->addLineItems($LineItem); $LineItem = clone $LineItem; $LineItem->setLineQuantity(2); $Invoice->addLineItems($LineItem); //print_r($Invoice->__toString()); $resp = $API->create($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); $Resthook = new ChargeOverAPI_Object_Resthook(array('target_url' => 'http://playscape2.uglyslug.com/resthooks/user_update.php', 'event' => 'user.update')); // Create the user $resp = $API->create($Resthook); // Check for errors if (!$API->isError($resp)) { print 'SUCCESS!'; print_r($resp); } else { print 'Error saving resthook via API'; print "\n\n"; print $API->lastRequest() . "\n\n"; print $API->lastResponse() . "\n\n"; }
$Transaction->setCustomerId(1); //$Transaction->setGatewayId(1); $Transaction->setGatewayStatus(1); $Transaction->setGatewayTransid('abcd1234'); $Transaction->setGatewayMsg('My test message'); $Transaction->setGatewayMethod('visa'); $Transaction->setAmount(1500.95); $Transaction->setTransactionType('pay'); $Transaction->setTransactionMethod('Visa'); $Transaction->setTransactionDetail(''); $Transaction->setTransactionDate('2014-12-02'); /* // If you also want to specify what invoices you apply this to $AppliedTo = new ChargeOverAPI_Object_Transaction(); $AppliedTo->setInvoiceId(1234); $Transaction->addAppliedTo($AppliedTo); */ $resp = $API->create($Transaction); if (!$API->isError($resp)) { $transaction_id = $resp->response->id; print 'SUCCESS! Transaction # is: ' . $transaction_id; } else { print 'Error saving transaction via API' . "\n"; 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"; }
<?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 = 1; $Tokenized = new ChargeOverAPI_Object_Tokenized(array('customer_id' => $customer_id, 'token' => 'abcd1234', 'type' => 'customer')); $resp = $API->create($Tokenized); if (!$API->isError($resp)) { $tokenized_id = $resp->response->id; print 'SUCCESS! Stored tokenized payment method as tokenized_id #: ' . $tokenized_id; } else { print 'Error saving tokenized info via API!'; print $API->lastResponse(); }