Tuesday, June 9, 2015

PHP and JavaScript SDKs Now Available

Bill & Pay is now making available SDKs for PHP and JavaScript. The SDK consists of a helper class that makes calling our API really easy along with an example of how to use it.

Download the Bill & Pay SDK


Let Us Write the Code for You


The "Try It" feature in the Bill & Pay API Documentation has been expanded to include the ability show the exact source code you would use to make a request through the SDK.

Here is how you use it:
The "Try It" form in the
Bill & Pay Documentation.


  1. Go to the Bill & Pay API Documentation.
     
  2. Go to the class and method you are interested in using.
     
  3. Expand the "Try It" section and fill out the form to specify the parameters you want to pass to the API method.
     
  4. Click "Generate XML Request". This will create the XML request that needs to be sent to the Bill & Pay API.
     
  5. Try out your method call by clicking the "Execute Request" button. The results will be shown below the generated XML.
     
  6. Once you have the XML request that works the way you want it to you can translate the XML request into the source code for your chosen SDK programming language. Just click the "Select an SDK language." drop-down list. Select your programming language that Bill & Pay provides an SDK for.
     
  7. The source code for the chosen programming language will appear below the XML request. You can copy the source code and paste it into your programming environment to use it immediately.
The Try It feature generates
the request XML.

A simple generated sample source code for
making an API method call using the
PHP version of the SDK.

Here is an example of the PHP SDK source code generated for a complex API method call:


$BPBiller = new BPBillerAPI();
$BPBiller.billerid = "99999";
$BPBiller.password = "xxxxxxxxx";
$customerinfo = $BPBiller->sendRequest(array('customerinfo' => array('limit' => array('rows' => '50', 'page' => '1'), 'field' => array('internalid', 'id', 'active', 'login', 'companyname', 'firstname', 'middlename', 'lastname', 'phone', 'billingaddress'), 'where' => array('active' => '1', 'enrolled' => '1'))));
if ($customerinfo !== false) {
    //Process response here using $customerinfo variable.
} else {
    //Handle errors here.
}


And the same API method call using source code generated for the JavaScript SDK:

var BPBiller = BPBillerAPI();
BPBiller.billerid = "99999";
BPBiller.password = "xxxxxxxxx";
BPBiller.sendRequest(customerinfo_response, {"customerinfo":{"limit":{"rows":"50","page":"1"},"field":["internalid","id","active","login","companyname","firstname","middlename","lastname","phone","billingaddress"],"where":{"active":"1","enrolled":"1"}}});
function customerinfo_response(customerinfo) {
    if (BPBiller.errorNumber == 0) {
        //Process response here using customerinfo variable.
    } else {
        //Handle errors here.
    }
}


No comments:

Post a Comment