deboorn/ccb-api

Church Community Builder Api Helper

v1.0.2 2015-11-20 19:03 UTC

This package is not auto-updated.

Last update: 2024-04-27 16:14:32 UTC


README

CCB-Api

  • PHP 5 Church Community Builder Helper
  • License: Creative Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)
  • Please respect the license above (CC BY-NC 3.0), it's strictly non commercial.
  • Commercial license available for a very small one-time fee of $15.
  • If you are a paid freelancer developing for a church you need a commercial license.
  • These files are Not officially supported by Church Community Builder.
  • Questions regarding this software should be directed to daniel.boorn@gmail.com.

How to Install

Install the deboorn/ccb-api package

$ composer require deboorn/ccb-api

Example of Usage

$ccb = new \CCB\Api('username', 'password', 'https://yourdomain.ccbchurch.com/api.php');


# Example 1 -- How to fetch and loop over api data


// fetch transaction detail type list
$response = $ccb->fetch('transaction_detail_type_list');

// loop over results (if any)
if ($response['transaction_detail_types']->attr('count') > 0) {
    foreach ($response['transaction_detail_type'] as $element) {
        $item = pq($element);
        var_dump($item['name']->text());
    }
}


# Example 2 -- How to build and post xml body data to api

// get model from local file /ccb/templates/import_online_gifts.xml
// you could also skip this and build your xml string directly
// add your own templates by saving them from the api docs to the template directory
$model = $ccb->fromTemplate('srv_endpoint_string');
$model['element_name']->text('value');
// ...
$response = $ccb->fetch('srv_endpoint_string', $model, 'POST');
var_dump($response);

# Example 3 -- How to build and send GET data to api

$params = array(
    // required
    'coa_category_id' => 50,
    'individual_id'   => 0,
    'amount'          => number_format(rand(100, 300), 2),
    // optional
    'merchant_transaction_id'     => uniqid('OG'), // max 50
    'merchant_authorization_code' => 'AP', // max 10
    'merchant_notes'              => 'Test Donation Api', // max 100
    'merchant_process_date'       => date('Y-m-d'),
    'first_name'                  => 'John',
    'last_name'                   => 'Doe',
    'street_address'              => '12th Ave North', // max 150
    'city'                        => 'Myrtle Beach', // max 30
    'state'                       => 'SC', // max 3
    'zip'                         => '29579', // max 10
    'email'                       => 'john.doe@example.com',
    'campus_id'                   => 1,
    'payment_method'              => 'API - CCard',
    'payment_method_type'         => 'VISA', // enum (Other, MC, VISA, AMEX, DISC
    'transaction_date'            => date('Y-m-d'),
);

try {
    $response = $ccb->fetch('online_giving_insert_gift', $params);
    var_dump($response['gift_id']->text());
} catch (\CCB\Exception $e) {
    var_dump($e->getMessage(), $e->getCode(), $e->getXml());
}