(IN) +91-8625813579 | (USA) +1-512539-0609 hello@cloudredux.com

Recently I did custom Salesforce integration for with Shopify, Bill.Com, LiveChat, Helpscout, etc. The authentication request/response formats are crucial in such integration(s) as they establish the bridge between Salesforce and other platforms. Since I had a chance of working over it, I’m sharing it in this series of posts.

This part of the Salesforce integration series post covers Salesforce integration with Shopify and Bill.Com.

Integration with Shopify.com (using private app in Shopify)

Shopify is a complete eCommerce solution that allows you to set up an online store to sell your goods. It lets you organize your products, customize your storefront, accept credit card payments, track and respond to orders — all with a few clicks of the mouse.

Firstly you need to create private app in Shopify.com which will generate the API key, password, shared secret. We’ll need to use those keys for authentication purpose and while sending REST requests from Salesforce.

Here is the link to Shopify API Documentation: https://docs.shopify.com/api


Create customer in Shopify.com from Salesforce

API: https://help.shopify.com/api/reference/customer#create

POST Request from Salesforce:

[php]JSONGenerator gen = JSON.createGenerator(true);
        gen.writeStringField(’email’, Contact.Email);        
        gen.writeStringField(‘first_name’, Contact.FirstName);
        gen.writeStringField(‘last_name’, Contact.LastName);             

string strRequest = gen.getAsString();

Http objHttp = new Http();

HttpRequest request = new HttpRequest();
Blob headerValue = Blob.valueOf(‘your apikey: your password’);
String authorizationHeader = ‘Basic ‘ + EncodingUtil.base64Encode(headerValue);
request.setHeader(‘Authorization’, authorizationHeader);
request.setHeader(‘Content-Type’, ‘application/json’);

HttpResponse res = objHttp.send(request);

Map<String, Object> mapResponse = (Map<String,Object>)JSON.deserializeUntyped(res.getBody());

Map<String, Object> mapCustomerData = (Map<String, Object>)mapResponse.get(‘customer’);

if(mapCustomerData .containskey(‘id’))


Integration with Bill.Com

Bill.com is a US-based cash flow management software system, provided as a software as a service that integrates with accounting and banking systems. It is intended to serve as a command and control dashboard for cash flow, by businesses, accounting firms and banks.

Documentation: http://developer.bill.com/api-documentation/api/bill

Every API request needs a valid session id, which is obtained by issuing a Login request. Login API takes in an organization id, developer (or application) key, and user credentials (or Token), and returns a valid session id, as well as an end-point URL, which should be used for any subsequent API requests. This session id will remain valid for up to 35 minutes without activity. If the session becomes inactive, you will have to issue a new Login request and obtain a new session ID. You can explicitly end the session by issuing a Logout request.

You need username, password, OrganizationId, Devkey which can obtained from Bill.Com account / support.

Login Request:

[php]String strLoginRequest = ‘userName=’+’Bill_com_Username’+’&password=’+’Bill_com_Password’+’&orgId=’+’Bill_com_OrgId’+’&devKey=’+’Bill_com_Devkey’+’;

HttpRequest objHttpReq = new HttpRequest();

Http http = new Http();
HTTPResponse objHttpResp = http.send(objHttpReq);

if (objHttpResp.getStatusCode()==200) {
    Map<String,object> mapLoginResp = (Map<String,object>)JSON.deserializeUntyped(objHttpResp.getBody());
    if(mapLoginResp.containsKey(‘response_status’) &&   Integer.valueOf(mapLoginResp.get(‘response_status’))==0) {
        if (mapLoginResp.containsKey(‘response_data’) && mapLoginResp.get(‘response_data’) instanceof map<string,object>) {   
            Map<String,Object> mapLoginRespData =  (Map<String,Object>)mapLoginResp.get(‘response_data’);
            if(mapLoginRespData.containskey(‘apiEndPoint’) ) {

The session Id, API end point is needed to use for making next requests:


Create Bill request:

[php]HttpRequest objHttpReq = new HttpRequest();
objHttpReq.setbody(‘devKey=’+’DEVKEY’+’&sessionId=’+’SESSION ID RECEIVED from LOGIN’+’&orgId=’+’Bill_com_OrgId’+’&data=’+’RequestBODY’);
Http http = new Http();
HTTPResponse objHttpResp = http.send(objHttpReq);[/php]