1. Go to this page and download the library: Download nexusvc/ccg-sales-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nexusvc / ccg-sales-api example snippets
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$username = 'FIRSTNAME.LASTNAME'; // Sales Agent Username from CCG
$password = 'XXXXXXXXXXXXXXXXXX'; // Sales Agent Password from CCG
$npn = 'XXXXXXXX'; // Sales Agent NPN
// Authenticating and getting a token
$ccg = new CCG;
$ccg->auth()->login(
$username,
$password,
$npn
);
return $ccg->auth();
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
return $ccg->quote()->categories();
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Set Product Params
$params = [
'type' => $CategoryType, // Set the Type returned from categories
];
return $ccg->quote($params)->products();
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
return $ccg->quote()->verifications();
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Credit or Debit
$payable = $ccg->payable([
'account' => 'XXXXXXXXXXXXXXXX',
'cvc' => 'XXX',
'expiration' => [
'month' => 'XX',
'year' => 'XXXX'
],
]);
// BankAccount
$payable = $ccg->payable([
'account' => 'XXXXXXXXXXXX',
'routing' => 'XXXXXXXXXXXX'
]);
// Attach Payable to Order
$payable->addToOrder();
// Alternative: Attach Payable to Order
$ccg->order->addPayable($payable);
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
$params = [
'state' => 'FL',
'type' => 'LimitedMedical',
'coverageType' => 1
];
// Example filter by groupId
$product = $ccg->quote($params)->products()->filter(function($item) {
return $item->groupId === 12362;
})->first();
// Attach Product to Order
$product->addToOrder();
// Alternative: Attach Product to Order
$ccg->order->addProduct($product);
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Create applicant
// This method always returns a new Applicant()
$applicant = $ccg->applicant([
'firstName' => 'John',
'lastName' => 'Doe',
'dob' => 'YYYY-MM-DD',
'gender' => 'Male',
'relation' => 'primary'
]);
// Phone
$phone = $ccg->phone('XXXXXXXXXX');
// Email
$email = $ccg->email('XXXXXXXXXX');
// Address
$addressParams = [
'street1' => '1 GENERAL WAY',
'street2' => 'APT 100',
'city' => 'Popular City',
'state' => 'FL',
'zip' => 'XXXXX'
];
$address = $ccg->address($addressParams);
// You may daisy chain addContactable method
$applicant->addContactable($phone)
->addContactable($email)
->addContactable($address);
// Add Applicant to Order
$applicant->addToOrder();
// Alternative: Add Applicant to Order
$ccg->order->addApplicant($applicant);
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Add Product to Order
// Add Applicant(s) to Order
// Add Payable to Order
// Request Voice Verification Script
$verification = $ccg->quote()->verifications('voice')->fetch();
// Getting available script variables
$variables = $verification->getVariables();
// Update the value of each variable
// Doing so will parse and replace the voice
// script content w/ new values
// Setting Values
$verification->setVariables($variables);
// Request Formatted Script
$verification->format();
// Accessing Formatted Script
$verification->format()->script;
// Alternative: Accessing Formatted Script
// must have previously called ->format() method
$verification->script;
// Display Script to Agent
// Record audio & save
// You may pass a URL and/or audio file
// Formats accepted are: mp3, wav, url
// Local File Path
$recording = '/path/to/audio/file';
// Alternative: Remote File
$recording = 'https://www.dropbox.com/s/euygas65j1y7/john_doe_ver.mp3?dl=1';
// Adding recorded voice verification
$verification->addRecording($recording);
// Adding Verification to Order
// Recording must be attached
$verification->addToOrder();
// Alternative: Adding Verification to Order
// Recording must be attached
$ccg->order->addVerification($verification);
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Add Product to Order
// Add Applicant(s) to Order
// Add Payable to Order
// Optional: Setting a $callbackUrl
// Passing a callbackUrl will fire automatically to the url upon
// successful esign by customer. This will eliminate the need for
// a status check and allow you to be notified immediately.
$callbackUrl = 'https://some.callback.url.com/';
// Request Esign
$esign = $ccg->quote()->verifications('esign');
// Sending Invitation
// Calling invite will push the verification to the order
$esign->invite($callbackUrl);
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Add Product to Order
// Add Applicant(s) to Order
// Add Payable to Order
// Optional: Setting a $callbackUrl
// Passing a callbackUrl will fire automatically to the url upon
// successful esign by customer. This will eliminate the need for
// a status check and allow you to be notified immediately.
$callbackUrl = 'https://some.callback.url.com/';
// Request Esign
$esign = $ccg->quote()->verifications('esign');
// Sending Invitation
// Calling invite will push the verification to the order
$esign->invite($callbackUrl);
// Wait for customer to complete esign if you are using the status method
// use a queue and/or manual checking if not using a $callbackUrl.
// Manually checking esign status
$esign->status();
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Add Product to Order
// Add Applicant(s) to Order
// Add Payable to Order
// Add Verification to Order
return $ccg->order->charge();
// Include the Library
use Nexusvc\CcgSalesApi\CCG;
$ccg = new CCG;
// Authenticate
// See Authenticating
// Add Product to Order
// Add Applicant(s) to Order
// Add Payable to Order
// Add Verification to Order
return json_encode($ccg->order->toArray());
// Pass the $ccg->order
$schema = new \Nexusvc\CcgSalesApi\Schema\Schema($ccg->order);
return $schema->load('version-one')->format();