diff --git a/ChargeOverAPI.php b/ChargeOverAPI.php index e696827..9d35837 100755 --- a/ChargeOverAPI.php +++ b/ChargeOverAPI.php @@ -222,7 +222,7 @@ protected function _request($http_method, $uri, $data = null) // We at least got back a valid JSON object if ($data->status != ChargeOverAPI::STATUS_OK) { - return $this->_error($data->message, $data->code); + return $this->_error($data->message, $data->code, $data->details); } return $data; @@ -232,7 +232,7 @@ protected function _request($http_method, $uri, $data = null) return $this->_error($err, ChargeOverAPI::ERROR_RESPONSE); } - protected function _error($err, $code = 400) + protected function _error($err, $code = 400, $details = null) { $this->_last_error = $err; @@ -241,6 +241,7 @@ protected function _error($err, $code = 400) 'code' => $code, // let's force this to a 400 error instead, it's non-recoverable $info['http_code'], 'status' => ChargeOverAPI::STATUS_ERROR, 'message' => $err, + 'details' => $details, 'response' => null, ))); } diff --git a/docs/example_attempt_payment.php b/docs/example_attempt_payment.php index 6c16437..3329675 100755 --- a/docs/example_attempt_payment.php +++ b/docs/example_attempt_payment.php @@ -11,13 +11,13 @@ require '../ChargeOverAPI.php'; //This url should be specific to your ChargeOver instance -$url = 'http://dev.chargeover.com/signup/api/v3'; +$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 = 'fnELaQ2yXJeINDZ6HjVtAwF0mSqdxCzo'; -$password = 'ePTGCYz104wILNdcWZMQsV3JEjapqBlm'; +$username = '1YExkQoscPr0eHzVbKvMASyLpmC427BW'; +$password = 'fhKyga18s3D42lIbB6vRc0TdFOzrYUkL'; $API = new ChargeOverAPI($url, $authmode, $username, $password); @@ -26,10 +26,10 @@ null, 'pay', // This is the type of action we want to perform array( - 'customer_id' => 2, - 'amount' => 50, + 'customer_id' => 23, + 'amount' => 2.95, 'applied_to' => array( - 'invoice_id' => 10002 + 'invoice_id' => 46 ), )); @@ -39,7 +39,7 @@ } else { - print('Error saving invoice via API' . "\n"); + print('Error while attempting payment via API' . "\n"); print('Error message was: ' . $resp->code . ': ' . $resp->message . "\n"); diff --git a/docs/example_create_creditcard.php b/docs/example_create_creditcard.php index 0443fed..3caa7f0 100755 --- a/docs/example_create_creditcard.php +++ b/docs/example_create_creditcard.php @@ -9,8 +9,8 @@ //$url = 'https://YOUR-INSTANCE-NAME.chargeover.com/api/v3'; $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; -$username = 'V1tufg9vklUywH0DqrFs26bjCTm7A8KE'; -$password = 'PBRIh8mqzErT2ikpud3VtLwX6W1Ko7JN'; +$username = '1YExkQoscPr0eHzVbKvMASyLpmC427BW'; +$password = 'fhKyga18s3D42lIbB6vRc0TdFOzrYUkL'; $API = new ChargeOverAPI($url, $authmode, $username, $password); @@ -22,7 +22,7 @@ 'number' => '4111 1111 1111 1111', 'expdate_year' => '2016', - 'expdate_month' => '11', + 'expdate_month' => '8', 'name' => 'John Doe', )); diff --git a/docs/example_create_package.php b/docs/example_create_package.php index 87d281c..54a25f9 100755 --- a/docs/example_create_package.php +++ b/docs/example_create_package.php @@ -4,13 +4,13 @@ require '../ChargeOverAPI.php'; -//This url should be specific to your ChargeOver instance +// 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 = 'rjaLs9MYQdieAF5h1BqPkcxIRuNOlGJE'; -$password = '0zYL9hwBpQVfrZXNET5JMjdIqg8HscFn'; +$username = '1YExkQoscPr0eHzVbKvMASyLpmC427BW'; +$password = 'fhKyga18s3D42lIbB6vRc0TdFOzrYUkL'; $API = new ChargeOverAPI($url, $authmode, $username, $password); diff --git a/docs/example_get_package_by_id.php b/docs/example_get_package_by_id.php new file mode 100755 index 0000000..f867d42 --- /dev/null +++ b/docs/example_get_package_by_id.php @@ -0,0 +1,30 @@ +findById('package', 1234); + +if (!$API->isError($resp)) +{ + $Package = $resp->response; + print_r($Package); + +} +else +{ + print('There was an error looking up the subscription!' . "\n"); +} + diff --git a/docs/example_pay_invoice_w_creditcard.php b/docs/example_pay_invoice_w_creditcard.php index 798aaf5..95fe2f0 100755 --- a/docs/example_pay_invoice_w_creditcard.php +++ b/docs/example_pay_invoice_w_creditcard.php @@ -16,16 +16,16 @@ // Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; -$username = '7sutWFEO2zKVYIGmZMJ3Nij5hfLxDRb8'; -$password = '9vCJbmdZKSieVchyrRItFQw8MBN4lOH3'; +$username = '1YExkQoscPr0eHzVbKvMASyLpmC427BW'; +$password = 'fhKyga18s3D42lIbB6vRc0TdFOzrYUkL'; $API = new ChargeOverAPI($url, $authmode, $username, $password); $Invoice = new ChargeOverAPI_Object_Invoice(); -$Invoice->setCustomerId(1562); +$Invoice->setCustomerId(23); $LineItem = new ChargeOverAPI_Object_LineItem(); -$LineItem->setItemId(303); +$LineItem->setItemId(1); $LineItem->setLineRate(29.95); $LineItem->setLineQuantity(3); $LineItem->setDescrip('Test of a description goes here.'); @@ -45,7 +45,10 @@ // Create the credit card object $CreditCard = new ChargeOverAPI_Object_CreditCard(array( - 'number' => '4111 1111 1111 1111', + + //'number' => '4111 1111 1111 1111', + 'number' => '4116196783374209', // This one causes decline messages + 'expdate_year' => '2015', 'expdate_month' => '12', 'name' => 'Keith Palmer', diff --git a/docs/example_send_transaction.php b/docs/example_send_transaction.php index 9bc98c6..8c02ca6 100755 --- a/docs/example_send_transaction.php +++ b/docs/example_send_transaction.php @@ -10,26 +10,31 @@ require '../ChargeOverAPI.php'; -//This url should be specific to your ChargeOver instance -$url = 'http://dev.chargeover.com/api/v3'; +// This url should be specific to your ChargeOver instance +$url = 'http://dev.chargeover.com/api/v3.php'; //$url = 'https://YOUR-INSTANCE-NAME.chargeover.com/api/v3'; -// Your ChargeOver API credentials $authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC; -$username = 'fnELaQ2yXJeINDZ6HjVtAwF0mSqdxCzo'; -$password = 'ePTGCYz104wILNdcWZMQsV3JEjapqBlm'; +$username = '1YExkQoscPr0eHzVbKvMASyLpmC427BW'; +$password = 'fhKyga18s3D42lIbB6vRc0TdFOzrYUkL'; $API = new ChargeOverAPI($url, $authmode, $username, $password); // The invoice that we want to void -$transaction_id = 129; +$transaction_id = 23; // This $data is all optional, but can be used to override the defaults $data = array( + + // This let's you override the actual message template itself + //'message_id' => 3, + + // These let you override individual parts of the message //'email' => 'johndoe@send-invoice-to.com', - //'message_subject' => 'Test subject', - //'message_body' => 'Override the default message body here', - //'message_from' => 'you@your-company.com', + //'subject' => 'Test subject', + //'html' => 'Override the default HTML body here', + //'body' => 'Override the default message body here', + //'from' => 'you@your-company.com', ); // Void an invoice