Skip to content

Commit

Permalink
Example of getting a subscription by ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Palmer Jr authored and Keith Palmer Jr committed Dec 21, 2016
1 parent e3313aa commit dff7dac
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 29 deletions.
5 changes: 3 additions & 2 deletions ChargeOverAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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,
)));
}
Expand Down
14 changes: 7 additions & 7 deletions docs/example_attempt_payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
),
));

Expand All @@ -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");

Expand Down
6 changes: 3 additions & 3 deletions docs/example_create_creditcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -22,7 +22,7 @@

'number' => '4111 1111 1111 1111',
'expdate_year' => '2016',
'expdate_month' => '11',
'expdate_month' => '8',
'name' => 'John Doe',
));

Expand Down
6 changes: 3 additions & 3 deletions docs/example_create_package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
30 changes: 30 additions & 0 deletions docs/example_get_package_by_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

header('Content-Type: text/plain');

require '../ChargeOverAPI.php';

//This url should be specific to your ChargeOver instance
$url = 'https://dev.chargeover.com/api/v3';
//$url = 'https://YOUR-INSTANCE-NAME.chargeover.com/api/v3';

$authmode = ChargeOverAPI::AUTHMODE_HTTP_BASIC;
$username = '7sutWFEO2zKVYIGmZMJ3Nij5hfLxDRb8';
$password = '9vCJbmdZKSieVchyrRItFQw8MBN4lOH3';

$API = new ChargeOverAPI($url, $authmode, $username, $password);

// Find a subscription by subscription ID #
$resp = $API->findById('package', 1234);

if (!$API->isError($resp))
{
$Package = $resp->response;
print_r($Package);

}
else
{
print('There was an error looking up the subscription!' . "\n");
}

13 changes: 8 additions & 5 deletions docs/example_pay_invoice_w_creditcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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',
Expand Down
23 changes: 14 additions & 9 deletions docs/example_send_transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dff7dac

Please sign in to comment.