info@getoncrm.com
+91-7405042484
GetOnCRM Solutions
  • Company
    • About
  • Services
    • Salesforce Sales Cloud
    • Salesforce Service Cloud
    • Salesforce Community Cloud
    • Salesforce Lightning
    • Salesforce Pardot
    • Salesforce CPQ
    • Contract Lifecycle Management
    • Salesforce Appexchange
    • Salesforce Integration
    • Data Management
    • Salesforce Mobile Application
    • Salesforce Commerce Cloud
    • Apttus CPQ
    • Salesforce Einstein
    • Salesforce Marketing Cloud
  • Case Study
  • Blog
  • Career
  • Contact Us
  • Let’s talk
GetOnCRM Solutions
  • Company
    • About
  • Services
    • Salesforce Sales Cloud
    • Salesforce Service Cloud
    • Salesforce Community Cloud
    • Salesforce Lightning
    • Salesforce Pardot
    • Salesforce CPQ
    • Contract Lifecycle Management
    • Salesforce Appexchange
    • Salesforce Integration
    • Data Management
    • Salesforce Mobile Application
    • Salesforce Commerce Cloud
    • Apttus CPQ
    • Salesforce Einstein
    • Salesforce Marketing Cloud
  • Case Study
  • Blog
  • Career
  • Contact Us
  • Let’s talk
GetOnCRM Solutions
  • Company
    • About
  • Services
    • Salesforce Sales Cloud
    • Salesforce Service Cloud
    • Salesforce Community Cloud
    • Salesforce Lightning
    • Salesforce Pardot
    • Salesforce CPQ
    • Contract Lifecycle Management
    • Salesforce Appexchange
    • Salesforce Integration
    • Data Management
    • Salesforce Mobile Application
    • Salesforce Commerce Cloud
    • Apttus CPQ
    • Salesforce Einstein
    • Salesforce Marketing Cloud
  • Case Study
  • Blog
  • Career
  • Contact Us
  • Let’s talk
  • Company
    • About
  • Services
    • Salesforce Sales Cloud
    • Salesforce Service Cloud
    • Salesforce Community Cloud
    • Salesforce Lightning
    • Salesforce Pardot
    • Salesforce CPQ
    • Contract Lifecycle Management
    • Salesforce Appexchange
    • Salesforce Integration
    • Data Management
    • Salesforce Mobile Application
    • Salesforce Commerce Cloud
    • Apttus CPQ
    • Salesforce Einstein
    • Salesforce Marketing Cloud
  • Case Study
  • Blog
  • Career
  • Contact Us
  • Let’s talk
Blog
Home Salesforce Integration Steps to Integrate Quickbooks with Salesforce
Salesforce Integration

Steps to Integrate Quickbooks with Salesforce

getoncrm March 23, 2020 0 Comments

Quickbooks is an accounting software package built and marketed by intuit. Quickbooks products are geared mainly toward small and medium sized organizations and offer on-premises accounting applications as well as cloud-based versions that accept business payments, manage and pay bills, and payroll functions.

Quickbooks and Salesforce are two cloud based software and they are widely used by small to large companies. With the help of integration between these two can save hours in manual data migration and give information about how your business is operating and where it can be optimized. It will also help to share information among accounting and sales, client data, sales order, costs, and invoicing.

Key Features of Salesforce and Quickbooks Integration

  • It will synchronize Salesforce items with Quickbooks items
  • It will synchronize the update Quickbooks lists with Salesforce items
  • New client in Quickbooks makes a record in Salesforce
  • It will synchronise account with clients in Quickbooks on the web
  • Salesforce cloud-won have opportunities automatically make Quickbooks invoices/receipt

Below are the steps of Salesforce Integration with Quickbooks

Step 1: Create an visualforce page to authorize the quickbook for the access token

Visualforce Page:

<apex:page id="pg" controller="QuickbooksConnector" action="{!getAccessToken}" showHeader="false" sidebar="false" lightningStylesheets="true">
<html>
<head>
<title>Quickbook Integration</title>
<apex:slds />
</head>
<body>
<div class="slds-scope slds-box slds-box_x-small">
<apex:form id="theForm">
<apex:actionFunction action="{!GetAuthorization}" oncomplete="overridePageMessages()" name="Auth" reRender="theForm" />
<apex:actionstatus id="status">
<apex:facet name="start">
<div id="spinner" class="slds-spinner_container slds-is-relative" style="position: fixed;">
<div role="status" class="slds-spinner slds-spinner--large slds-spinner--brand">
<div class="slds-spinner__dot-a"></div>
<div class="slds-spinner__dot-b"></div>
</div>
</div>
</apex:facet>
</apex:actionstatus>
<div class="slds-page-header " role="banner">
<div class="slds-grid slds-grid_vertical">
<div class="slds-col slds-has-flexi-truncate" align="center">
<h1 class="slds-page-header__title slds-truncate h1-size" title="Quickbook Authentication">Quickbook Authentication</h1>
<hr/>
<div class="slds-col slds-medium-size" align="center">
<apex:pageMessages id="showmsg"></apex:pageMessages>
</div>
<div class="slds-col slds-medium-size" align="center">
<table align="center" style="width:80%">
<tr>
<td>
<button class=" buttonWidth slds-button slds-button_brand slds-m-top_large " align="center" onclick="Auth(); return false;"
reRender="theForm">
Authorization
</button>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</apex:form>

Apex Class:

public String authToken  { get; set; }
public String QBPageURL { get; set; }
private static QuickBookIntuit__c serviceObject;
public pagereference GetAuthorization() {
serviceObject = getServiceSettings();
 
String timestamp = string.valueof(dateTime.now().getTime()/1000);
 
Map<String,String> parameters = new Map<String,String>();
parameters.put('client_id', serviceObject.Consumer_Key__c);
parameters.put('scope', 'com.intuit.quickbooks.accounting');
parameters.put('redirect_uri', EncodingUtil.urlEncode(URL.getSalesforceBaseUrl().toExternalForm() + '/apex/QuickbooksConnectorPage', 'UTF-8'));
parameters.put('response_type', 'code');
parameters.put('state', timestamp);
 
String url = serviceObject.Authorization_URL__c+'?client_id=' +
serviceObject.Consumer_Key__c + '&scope=com.intuit.quickbooks.accounting&redirect_uri=' +
EncodingUtil.urlEncode(URL.getSalesforceBaseUrl().toExternalForm() + '/apex/QuickbooksConnectorPage', 'UTF-8') +
'&response_type=code&state=' + timestamp;
 
HttpRequest req = new HttpRequest();
HttpResponse res;
req.setEndpoint(url);
req.setMethod(serviceObject.Http_Request_Type__c);
req.setHeader('Content-Length', '146');
 
QBPageURL = 'https://c71.qbo.intuit.com/Connect/Begin?oauth_token=' + authToken;
 
pagereference redirect = new PageReference( url );
return redirect.setRedirect(true);
 
}

/* =============================================================================
//
//    Function: Get Authorization Code With Accounting Online Scope
//
/*=============================================================================*/
 
public pagereference GetAuthorization() {
serviceObject = getServiceSettings();
 
String timestamp = string.valueof(dateTime.now().getTime()/1000);
 
Map<String,String> parameters = new Map<String,String>();
parameters.put('client_id', serviceObject.Consumer_Key__c);
parameters.put('scope', 'com.intuit.quickbooks.accounting');
parameters.put('redirect_uri', EncodingUtil.urlEncode(URL.getSalesforceBaseUrl().toExternalForm() + '/apex/QuickbooksConnectorPage', 'UTF-8'));
parameters.put('response_type', 'code');
parameters.put('state', timestamp);
 
String url = serviceObject.Authorization_URL__c+'?client_id=' +
serviceObject.Consumer_Key__c + '&scope=com.intuit.quickbooks.accounting&redirect_uri=' +
EncodingUtil.urlEncode(URL.getSalesforceBaseUrl().toExternalForm() + '/apex/QuickbooksConnectorPage', 'UTF-8') +
'&response_type=code&state=' + timestamp;
 
HttpRequest req = new HttpRequest();
HttpResponse res;
req.setEndpoint(url);
req.setMethod(serviceObject.Http_Request_Type__c);
req.setHeader('Content-Length', '146');
 
QBPageURL = 'https://c71.qbo.intuit.com/Connect/Begin?oauth_token=' + authToken;
 
pagereference redirect = new PageReference( url );
return redirect.setRedirect(true);
 
}
 
public void getAccessToken(){
serviceObject = getServiceSettings();
if( !ApexPages.currentPage().getParameters().containskey('code') )
return;
 
String encodedString = EncodingUtil.base64Encode(Blob.valueOf(serviceObject.Consumer_Key__c+':'+serviceObject.Consumer_Secret__C));
String endPoint = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer';
String redirectUrl = EncodingUtil.urlEncode(URL.getSalesforceBaseUrl().toExternalForm() + '/apex/QuickbooksConnectorPage', 'UTF-8');
String oAuthCode = ApexPages.currentPage().getParameters().get('code');
String companyId = ApexPages.currentPage().getParameters().get('realmId');
String stateID = ApexPages.currentPage().getParameters().get('state');
String requestBody = 'grant_type=authorization_code&code='+oAuthCode+'&redirect_uri='+redirectUrl;
String errorMessage ='';
 
HttpRequest httpReq = new HttpRequest();
HttpResponse httpRes = new HttpResponse();
Http http = new Http();
httpReq.setMethod( serviceObject.Http_Request_Type__c );
httpReq.setEndPoint( endPoint );
httpReq.setHeader( 'Authorization' , 'Basic '+encodedString );
httpReq.setHeader( 'Content-Type' , 'application/x-www-form-urlencoded' );
httpReq.setBody( requestBody );
 
try{
httpRes = http.send(httpReq);
 
if( httpRes.getStatusCode() == 200 ){
 
Map<String, Object> response_Map = (Map<String, Object>)JSON.deserializeUntyped(httpRes.getBody());
serviceObject.StateID__c = stateID;
serviceObject.CompanyId__c = companyId;
serviceObject.OAuth_Token_Secret__c = oAuthCode;
serviceObject.OAuth_Token__c = string.valueof(response_Map.get('access_token'));
serviceObject.Temporary_Token_Secret__c = string.valueof(response_Map.get('refresh_token'));
serviceObject.Expire_In_Seconds__c = (Decimal)response_Map.get('expires_in');
serviceObject.Refresh_Token_Expires_In__c = (Decimal)response_Map.get('x_refresh_token_expires_in');
serviceObject.Expires_In_Time__c = System.Now().addSeconds(Integer.valueOf((Decimal)response_Map.get('expires_in')));
 
ApexPages.addmessage( new ApexPages.message(ApexPages.severity.Confirm,+' '+'Successfully Authenticated with Quickbooks System!!!') );
update serviceObject;
 
} else {
 
ApexPages.addmessage( new ApexPages.message(ApexPages.severity.ERROR,+' '+'Unexpected Error while communicating with Quickbooks API'+
'Status '+httpRes.getStatus()+' and Status Code '+httpRes.getStatuscode()) );
}
 
} catch(System.Exception e) {
 
if(String.valueOf(e.getMessage()).startsWith('Unauthorized endpoint')){
errorMessage = 'Unauthorize endpoint: An Administrator must go to Setup -> Administer -> Security Control ->'
+' Remote Site Setting and add '+' '+ endPoint +' Endpoint';
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMessage));
}else{
errorMessage = 'Unexpected Error while communicating with Quickbooks API. '
+'Status '+httpRes.getStatus()+' and Status Code '+httpRes.getStatuscode();
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMessage));
}
}
}
}

Steps 2: Click On Authorization

It will redirect you to quickbook login.
Create an account in the intuit and use the credential.

 

 

Configure all details in the Intuit related to your company and other information.

Create a company record and manage all the financial account details in the Quickbook.
If you have a multiple company details in quickbook then select the company.

On select you will get an authorization code and store the authorization all details in the Salesforce Object.

You can create the other button for the Sync Account, Product & Customers details.

Step 3:  Create an salesforce object to store the All authorization details as per your requirement. 

 

 

Step 4: Get the refresh token.

Create an Apex Batch class and call the method from apex class at the 15 min interval so you will get an refresh token on the 15 min interval.

Apex Method:

public void doRefreshAccessToken(){
serviceObject = getServiceSettings();
String encodedString = EncodingUtil.base64Encode( Blob.valueOf(serviceObject.Consumer_Key__c + ':' + serviceObject.Consumer_Secret__c));
String endPoint = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer';
String requestBody = 'grant_type=refresh_token&refresh_token=';
if(serviceObject.Temporary_Token_Secret__c != null){
requestBody += serviceObject.Temporary_Token_Secret__c;
} else {
 
}
String errorMessage = '';
HttpRequest httpReq = new HttpRequest();
HttpResponse httpRes = new HttpResponse();
Http http = new Http();
httpReq.setMethod('POST');
httpReq.setEndPoint(endPoint);
httpReq.setHeader('Authorization' , 'Basic '+encodedString);
httpReq.setHeader('Content-Type' , 'application/x-www-form-urlencoded');
httpReq.setBody(requestBody);
try{
httpRes = http.send(httpReq);
if(httpRes.getStatusCode() == 200){
Map<String, Object> response_Map = (Map<String, Object>)JSON.deserializeUntyped(httpRes.getBody());
serviceObject.OAuth_Token__c = string.valueof(response_Map.get('access_token'));
serviceObject.Temporary_Token_Secret__c = string.valueof(response_Map.get('refresh_token'));
serviceObject.Expire_In_Seconds__c = (Decimal)response_Map.get('expires_in');
serviceObject.Refresh_Token_Expires_In__c = (Decimal)response_Map.get('x_refresh_token_expires_in');
serviceObject.Expires_In_Time__c = System.Now().addSeconds(Integer.valueOf((Decimal)response_Map.get('expires_in')));
update serviceObject;
}
} catch ( System.Exception e ){
if(String.valueOf(e.getMessage()).startsWith('Unauthorized endpoint')){
errorMessage = 'Unauthorize endpoint: An Administrator must go to Setup -> Administer -> Security Control ->'
+' Remote Site Setting and add '+' '+ endPoint +' Endpoint';
}else{
errorMessage = 'Unexpected Error while communicating with Quickbooks API. '
+'Status '+httpRes.getStatus()+' and Status Code '+httpRes.getStatuscode();
}
}
}

Note: After the Authorization if you want to Sync other Details from the Quickbook then you can create the custom button on the record level so you can manually sync the single records with the Quickbook.

Useful Link for the Quickbook Integration:

https://developer.intuit.com/app/developer/qbpayments/docs/develop/authentication-and-authorization

https://developer.intuit.com/app/developer/qbpayments/docs/develop/explore-the-quickbooks-payments-api/postman#using-postman

https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/account

16
726 Views
Top Benefits of using Salesforce for Nonprofit Organizations (NGOs)PrevTop Benefits of using Salesforce for Nonprofit Organizations (NGOs)March 13, 2020
How to Make Use of Salesforce to Manage the Employee Reimbursement System?March 31, 2020How to Make Use of Salesforce to Manage the Employee Reimbursement System?Next

Related Posts

Salesforce Integration

Building Angular Applications on Salesforce

In this post, I am going to share the information about salesforce...

getoncrm September 26, 2019
Salesforce Integration

Steps to Integrate Quickbooks with Salesforce

Quickbooks is an accounting software package built and marketed by intuit....

getoncrm March 23, 2020

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • How Salesforce Community Cloud Help Nonprofit Organizations?
  • Most Popular Salesforce Integration For Your Business
  • Salesforce Community Cloud: Why It Is Important For Your Business?
  • Ways how CRM software converts leads into opportunities
  • Reasons Why CRM Is Essential For SMBs
Categories
  • Apttus 1
  • Contract Lifecycle Management 1
  • CRM 4
  • Sales Cloud 1
  • Salesforce 23
  • Salesforce AppExchange 2
  • Salesforce Commerce Cloud 3
  • Salesforce Community Cloud 4
  • Salesforce CPQ 9
  • Salesforce CRM 5
  • Salesforce Einstein 3
  • Salesforce Integration 9
  • Salesforce Lightning 10
  • Salesforce Mobile App 6
  • Salesforce Pardot 5
  • Service Cloud 3

We are a global Salesforce consulting company that serves a broad mix of businesses, ranging from startups to big corporations. We help our clients make significant and lasting improvements to their performance and realize their most important goals, using Salesforce as a platform to enable digital processes.

  • About
  • Career
  • Services
  • Case Study
  • Blog
  • Contact Us
  • Let’s Talk
GetOnCRM Solutions
INDIA
Ahmedabad: B/706, Ganesh Plaza, Nr. Navrangpura Bus Stand, Navrangpura, Ahmedabad, Gujarat-380009,India.
info@getoncrm.com
minkesh.asc
info@getoncrm.com            
minkesh.asc
+91-7405042484
info@getoncrm.com            
minkesh.asc
Vadodara: 1008, 10th floor, OCEAN, Nr. Centre Square Mall, Sarabhai Compound, Dr. Vikram Sarabhai Marg, Vadodara, Gujarat, India.
USA
Address: 3080 Cowper Street Palo Alto, California 94306, USA
+1 (650) 704-5436
CANADA
Address: 1204 29 Ave NW Edmonton, AB T6T 0K8, Canada
+1 (250) 329-6480

Terms of use | Privacy Environmental Policy

Copyright © 2020 GetonCRM.  All Rights Reserved.

Copyright © 2020 GetOnCRM.  All Rights Reserved.

Copyright © 2019 GetOnCRM.
All Rights Reserved.

Book a Consultation

    We use cookies to deliver the best possible experience to you. By using our website, you agree to the use of cookies Find out more.