Skip to content

Before you start

Maduka Jayalath edited this page Nov 3, 2016 · 4 revisions

As per the SiteLink API doc there are couple of things you need to aware

  • When making web service calls, all parameters must be included. They also must be spelled exactly as they are in the below WSDL. https://api.smdservers.net/CCWs_3.5/CallCenterWs.asmx?WSDL
  • Dates should be formatted as follows: 1800-01-01T00:00:00
  • Boolean values do not always convert properly. When passing in a boolean/bit value, use TRUE/FALSE (all caps).

Important

Use SoapUI to reveal all the methods and parameters of the API since some variable names are wrongly spelled or with different cases to the API doc. It's one of the best tool to do that!

I have made couple of things in this project to make your life easier.


Sitelink Configuration Data

File path: application/config/sitelink.php

$config['sitelink_url'] = 'https://www.smdservers.net/CCWs_3.5/CallCenterWs.asmx?WSDL'; - Sitelink API URL

$config['sitelink_corp_code'] = '<Corporate Code>'; - Corporate Code

$config['sitelink_loc_code'] = '<Location Code>'; - Location Code

$config['sitelink_corp_login'] = '<Corp Username>:::<API License Key>'; - The API License Key has to be used on every SiteLink API call. The API License Key must be passed in conjunction with the Corporate Username parameter which exists for all API method calls. The structure for this parameter should be the Corporate Username appended by 3 colons (":::") appended by the API License Key.

$config['sitelink_corp_pass'] = '<Corp Password>'; - Corporate Password

$config['sitelink_test_mode'] = TRUE; - TRUE: the credit card will not be processed but SiteLink will process the payment. False: the credit card will be processed and SiteLink will process the payment.

$config['sitelink_cc_emails'] = array(); - This is for sending email notifications.

$config['sitelink_bcc_emails'] = array(); - This is for sending email notifications.


Data Library

Since there is no database involving with this project some predefined data in this library

File path: application/libraries/Data.php

get_countries - This function returns counties

get_states - This function returns states in the USA and Canada

get_card_types - This function returns all card types

get_months - This function returns 12 months names

get_years - This function returns next 20 years based on the current year


Sitelink Library

File path: application/libraries/Sitelink.php

This is the heart of the project. All the API calls can be found in this Library so gonna explain one by one of each functions.

Since the API returns are XML based, those are need to be converted to arrays. To do that, there is a small function called xml2array at line #19. One small thing you need to keep in mind. When there is a Boolean value this function returns as a string so you have to check as a string value.

Also the __construct method has been initialized with some data as below,

public function __construct()
{
    $this->CI =& get_instance(); - Assign the CodeIgniter object to a variable
    $this->CI->config->load('sitelink'); - Load Sitelink configuration file
    $this->client = new SoapClient($this->CI->config->item('sitelink_url')); - get the SoapClient object
    $this->params = new stdClass(); - Initialized an empty stdClass object 
    $this->params->sCorpCode = $this->CI->config->item('sitelink_corp_code'); - Set Corporate Code
    $this->params->sCorpUserName = $this->CI->config->item('sitelink_corp_login'); - Set Corporate Username
    $this->params->sCorpPassword = $this->CI->config->item('sitelink_corp_pass'); - Set Corporate Password
}