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'; $url = 'http://haproxy-dev.chargeover.com/signup/api/v3'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // Invoice to pay $invoice_id = 10054; // Pay this invoice, BUT only use the customer's available account balance to pay it // (e.g. don't charge a credit card, just try to use their available open balance // from previous over-payments/credits) $resp = $API->action('invoice', $invoice_id, 'pay', array('use_customer_balance' => true)); if (!$API->isError($resp)) { // Did anything get applied to it? if ($resp->response) { print 'Customer balance was applied to this invoice.'; } else { print 'There was no customer balance to apply.'; } } 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(); print "\n\n\n\n"; print $API->lastResponse(); print "\n\n\n\n";
<?php /** * Example of approving an invoice * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // Invoice to attempt payment for $invoice_id = 10107; // Pay for it $resp = $API->action(ChargeOverAPI_Object::TYPE_INVOICE, $invoice_id, 'approve'); if (!$API->isError($resp)) { print_r($resp); } 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"; }
<?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); $data = array('line_items' => array(0 => array('line_item_id' => 611, '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"; }
<?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'; $url = 'http://macbookpro.chargeover.com:8888/chargeover/signup/api/v3.php'; $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); $package_id = 582; $resp = $API->action('package', $package_id, 'hold', array('holduntil_datetime' => date('Y-m-d H:i:s', strtotime('+30 days')))); /* 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";
<?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); $data = array('paycycle' => 'mon'); $resp = $API->action('package', 557, 'paycycle', $data); /* 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)) { 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"; }
* * */ 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); // This is the package we're suspending $package_id = 561; // Suspend it indefinitely $resp = $API->action('package', $package_id, 'suspend'); /* // Suspend it within a certain date range $resp = $API->action('package', $package_id, 'suspend', array( 'suspendfrom_datetime' => '2015-03-06 00:00:00', 'suspendto_datetime' => '2015-06-05 00:00:00', )); */ if (!$API->isError($resp)) { print 'Suspended package!'; /* print($API->lastRequest()); print("\n\n\n"); print($API->lastResponse()); */ } else {
<?php /** * Example of setting the payment method for a billing package * * */ 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); // This is the package we're sending out welcome e-mails to $package_id = 715; // Save credit card via API $resp = $API->action('package', $package_id, 'welcome'); // Response from the API print_r($resp); // Debugging print "\n\n"; print $API->lastRequest(); print "\n\n"; print $API->lastResponse();
/** * Example of creating an invoice, and then paying it using an ACH/eCheck payment * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // The invoice that we want to void $invoice_id = 13011; // Void an invoice $resp = $API->action('invoice', $invoice_id, 'void'); if (!$API->isError($resp)) { print 'Voided the invoice!' . "\n"; } else { print 'Error voiding invoice 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"; }
/** * Example of creating an invoice, and then paying it using a credit card * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // Invoice to attempt payment for $invoice_id = 13085; // Pay for it $resp = $API->action(ChargeOverAPI_Object::TYPE_INVOICE, $invoice_id, 'pay', $CreditCard); if (!$API->isError($resp)) { print_r($resp); } 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(); print "\n\n\n\n"; print $API->lastResponse(); print "\n\n\n\n"; }
$package_id = 1206; // Create a new credit card object $CreditCard = new ChargeOverAPI_Object_CreditCard(); $CreditCard->setNumber('4111 1111 1111 1111'); $CreditCard->setExpdateYear(date('Y') + 1); $CreditCard->setExpdateMonth(12); $CreditCard->setCustomerId($customer_id); // Save credit card via API $resp = $API->create($CreditCard); // Set the payment method if (!$API->isError($resp)) { $data = array('paymethod' => ChargeOverAPI_Object_Package::PAYMETHOD_CREDITCARD, 'creditcard_id' => $resp->response->id); /* $data = array( 'paymethod' => ChargeOverAPI_Object_Package::PAYMETHOD_INVOICE, ); */ $resp = $API->action('package', $package_id, 'paymethod', $data); if (!$API->isError($resp)) { print 'Updated payment method!'; /* print($API->lastRequest()); print("\n\n\n"); print($API->lastResponse()); */ } else { print 'ERROR: ' . $resp->message; } } else { print 'ERROR: ' . $resp->message; }
<?php /** * Example of sending a reset password link to a user * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // The user_id value $user_id = 375; // Sent this user a reset password link $resp = $API->action(ChargeOverAPI_Object::TYPE_USER, $user_id, 'reset_password'); // This is the type of action we want to perform if ($resp->response) { print 'OK, sent that user a reset password link!'; } else { print 'Could not send that user a reset password link!'; // Debug info print $API->lastRequest(); print "\n\n"; print $API->lastResponse(); }
* Example of refunding a previously made payment * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; // The payment transaction_id value $payment_transaction_id = 206; // By default, the full transaction amount will be refunde $data = null; //$data = array( 'amount' => 9.49 ); // Refund a custom amount $API = new ChargeOverAPI($url, $authmode, $username, $password); // Do the refund $resp = $API->action('transaction', $payment_transaction_id, 'refund', $data); if (!$API->isError($resp)) { print_r($resp); } 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"; }
/** * Example of explicitly setting a user's password to some string * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // The user_id value $user_id = 375; // The default behavior will send the user an email with their password // If you don't want to send the e-mail, you can suppress the email like this: $API->flag(ChargeOverAPI::FLAG_EMAILS, false); // Reset the password (and send the user the new password if not suppresssed) $resp = $API->action(ChargeOverAPI_Object::TYPE_USER, $user_id, 'reset_password', array('password' => 'here is the password')); if ($resp->response) { print 'OK, set that user\'s password!'; } else { print 'Could not set password.'; // Debug info print $API->lastRequest(); print "\n\n"; print $API->lastResponse(); }
<?php /** * Example of automatically logging a user into the customer portal * * */ 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); // This is the user/contact you want to log in $user_id = 389; $resp = $API->action('user', $user_id, 'login'); if (!$API->isError($resp)) { // Forward the user to the one-time login token header('Location: ' . $resp->response); exit; /* print($API->lastRequest()); print("\n\n\n"); print($API->lastResponse()); */ } else { print 'ERROR: ' . $resp->message; }
* Example of creating an invoice, and then paying it using an ACH/eCheck payment * * */ 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'; // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; $username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // The invoice that we want to void $invoice_id = 10564; // This $data is all optional, but can be used to override the defaults $data = array(); // Void an invoice $resp = $API->action('invoice', $invoice_id, 'email', $data); if (!$API->isError($resp)) { print 'Sent the invoice!' . "\n"; } else { print 'Error sending invoice 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 /** * Example of setting the payment method for a billing package * * */ 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); // This is the package we're cancelling $package_id = 600; $resp = $API->action('package', $package_id, 'cancel'); if (!$API->isError($resp)) { print 'Cancelled package!'; /* print($API->lastRequest()); print("\n\n\n"); print($API->lastResponse()); */ } else { print 'ERROR: ' . $resp->message; }