Integration LoanPro with Salesforce

Jan 20, 2024


 

 

After completing this unit, you will able to:

1.  Introduction

2.  The Power of Integration

3.  Create New Customer

4.  Create New Loan

5.  Activate Loan

6.  Link Customer to Loan

 

1.  Introduction

Welcome to the intersection of innovation and financial prowess – welcome to the LoanPro-Salesforce integration revolution.

In the ever-evolving landscape of financial services, staying ahead of the curve is crucial for success. One of the most effective ways to achieve this is through seamless integration between different software platforms. In this blog post, we'll delve into the benefits of integrating LoanPro with Salesforce, exploring how this synergy can enhance operational efficiency and elevate your overall business performance.

In this blog, we embark on a journey to explore the transformative potential of integrating LoanPro with Salesforce, two industry leaders in their own right. This synergy is not just a collaboration of platforms; it's a strategic move toward operational efficiency, customer-centricity, and a competitive edge in the financial landscape.

Join us as we unravel the intricacies of this integration, discovering how it reshapes the way financial institutions operate, communicate, and elevate customer experiences.

 

2.  The Power of Integration

Efficient data management is at the core of any successful financial operation. Integrating LoanPro with Salesforce allows businesses to combine the strengths of two powerful platforms, creating a unified ecosystem that streamlines processes and facilitates data-driven decision-making.

By integrating LoanPro with Salesforce, you can consolidate customer information into a single, comprehensive view. This unified customer profile empowers your team to provide personalized and targeted services, enhancing customer satisfaction and loyalty.

Breaking down silos between different systems is essential for effective communication within your organization. Salesforce and LoanPro integration enables seamless data flow, ensuring that information is shared in real-time, reducing delays and enhancing collaboration across teams.

Integration allows you to create automated processes that save time and reduce manual errors. From loan origination to payment processing, automation ensures a smoother and more efficient journey for both your team and your customers.

Salesforce, known for its robust customer relationship management (CRM) capabilities, serves as a central hub for managing customer interactions and data. When integrated with LoanPro, it becomes a powerful tool for financial institutions to drive growth and enhance customer satisfaction.

Integrating LoanPro with Salesforce provides access to robust reporting and analytics features. This allows you to gain valuable insights into your loan portfolio, track key performance indicators, and make data-driven decisions to optimize your lending processes.

 

3.  Create New Customer

The integration between LoanPro and Salesforce provides a revolutionary approach to customer onboarding. Leveraging LoanPro's API documentation within the Salesforce platform, financial institutions can now initiate the creation of new customer profiles with unprecedented ease. This not only accelerates the onboarding process but ensures that customer data is consistently accurate, eliminating the risk of errors associated with manual data entry.

For more information you can refer this link: https://developers.loanpro.io/reference/create-customer

To create new loan, we need to create an apex class named createCustomer. In this class, we will call the api to manage the organization record on the LoanPro application.

public class CreateCustomer {
    public static void createCustomerAPICall() {
        Map<String, Object> jsonGenMap = new Map<String, Object>();
        jsonGenMap.put('status', 'Active');
        jsonGenMap.put('customerType', 'customer.type.individual');
        jsonGenMap.put('customerIdType', 'customer.idType.ssn');
        if(personAccount.FirstName != null)
            jsonGenMap.put('firstName', personAccount.FirstName);
        if(personAccount.MiddleName != null)
            jsonGenMap.put('middleName', personAccount.MiddleName);
        if(personAccount.LastName != null)
            jsonGenMap.put('lastName', personAccount.LastName);
        if(personAccount.customerIdType__pc != null)
            jsonGenMap.put('ssn', personAccount.customerIdType__pc);
        if(personAccount.PersonBirthdate != null)
            jsonGenMap.put('birthDate', personAccount.PersonBirthdate);
        if(personAccount.PersonGenderIdentity != null)
            jsonGenMap.put('gender', personAccount.PersonGenderIdentity);
        jsonGenMap.put('generationCode', 'customer.generationCode.none');
       
        Map<String, Object> jsonEmployerMap = new Map<String, Object>();
        Map<String, Object> jsonEmployerUpdateMap = new Map<String, Object>();
        if(employement != null){
            if(employement.Employer_Phone_Number__c != null)
                jsonEmployerMap.put('phone', employement.Employer_Phone_Number__c);
            Map<String, Object> jsonEmployerAddressMap = new Map<String, Object>();
            if(employement.Employment_Address__Street__s != null)
                addAddress(jsonEmployerAddressMap, employement.Employment_Address__Street__s);
            if(employement.Employment_Address__City__s != null)
                jsonEmployerAddressMap.put('city', employement.Employment_Address__City__s);
            if(employement.Employment_Address__PostalCode__s != null)
                jsonEmployerAddressMap.put('zipcode', employement.Employment_Address__PostalCode__s);
           
            if(employement.Employment_Address__StateCode__s != null)
                jsonEmployerAddressMap.put('state', 'geo.state.' + employement.Employment_Address__StateCode__s.ToUpperCase());
           
            if(employement.Employment_Address__CountryCode__s == 'US')
                jsonEmployerAddressMap.put('country', 'company.country.usa');
            else if(employement.Employment_Address__CountryCode__s == 'CA')
                jsonEmployerAddressMap.put('country', 'company.country.can');
           
            jsonEmployerMap.put('Address', jsonEmployerAddressMap);
           
            jsonEmployerMap.put('incomeFrequency', 'customerEmployer.incomeFrequency.annually');
            if(employement.Employment_Annual_Income__c != null)
                jsonEmployerMap.put('income', employement.Employment_Annual_Income__c);
            if(employement.Employment_Company_Name__c != null)
                jsonEmployerMap.put('companyName', employement.Employment_Company_Name__c);
            if(employement.Employment_Job_Title__c != null)
                jsonEmployerMap.put('title', employement.Employment_Job_Title__c);
            jsonGenMap.put('Employer', jsonEmployerMap);
            jsonEmployerUpdateMap.put('Employer', jsonEmployerMap);
        }
        Map<String, Object> jsonReferencesMap = new Map<String, Object>();
        List<Map<String, Object>> referencesResults = new List<Map<String, Object>>();        
       
        for(Reference__c reference: references)
        {
            Map<String, Object> referencesResultsMap = new Map<String, Object>();
            if(reference.First_Name__c != null || reference.Last_Name__c != null)
                referencesResultsMap.put('name', reference.First_Name__c + ' ' + reference.Last_Name__c);
            if(reference.Relation__c != null)
                referencesResultsMap.put('relation', reference.Relation__c);
           
            Map<String, Object> referencesResultAddMap = new Map<String, Object>();
            if(reference.Address__Street__s != null)
                referencesResultAddMap.put('address1', reference.Address__Street__s);
            if(reference.Address__City__s != null)
                referencesResultAddMap.put('city', reference.Address__City__s);
            if(reference.Address__StateCode__s != null)
                referencesResultAddMap.put('state', reference.Address__c.getState());
            if(reference.Address__PostalCode__s != null)
                referencesResultAddMap.put('zipcode', reference.Address__PostalCode__s);
            if(reference.Address__CountryCode__s == 'US')
                referencesResultAddMap.put('country', 'company.country.usa');
            else if(reference.Address__CountryCode__s == 'CA')
                referencesResultAddMap.put('country', 'company.country.can');
           
            referencesResultsMap.put('Address', referencesResultAddMap);
           
            if(reference.Mobile__c != null)
                referencesResultAddMap.put('primaryPhone', reference.Mobile__c);
            referencesResults.add(referencesResultsMap);
        }
       
        jsonReferencesMap.put('results', referencesResults);
        jsonGenMap.put('References', jsonReferencesMap);
       
        Map<String, Object> jsonPhonesMap = new Map<String, Object>();
        List<Map<String, Object>> phoneResults = new List<Map<String, Object>>();
        Map<String, Object> phoneResultMap = new Map<String, Object>();
       
        if(personAccount.PersonMobilePhone != null)
            phoneResultMap.put('phone', personAccount.PersonMobilePhone);
        phoneResultMap.put('isPrimary', '1');
        phoneResultMap.put('isSecondary', '0');
        phoneResultMap.put('type', 'customer.phoneType.cell');
        phoneResultMap.put('__ignoreWarnings', true);
       
        phoneResults.add(phoneResultMap);
        jsonPhonesMap.put('results', phoneResults);
        jsonGenMap.put('Phones', jsonPhonesMap);
       
        Map<String, Object> jsonPrimaryAddressMap = new Map<String, Object>();
        addAddress(jsonPrimaryAddressMap, personAccount.PersonMailingStreet);
       
        if(personAccount.PersonMailingCity != null)
            jsonPrimaryAddressMap.put('city', personAccount.PersonMailingCity);
        if(personAccount.PersonMailingState != null)
            jsonPrimaryAddressMap.put('state', personAccount.PersonMailingState);
        if(personAccount.PersonMailingPostalCode != null)
            jsonPrimaryAddressMap.put('zipcode', personAccount.PersonMailingPostalCode);
        if(personAccount.PersonMailingCountry != null)
            jsonPrimaryAddressMap.put('country', personAccount.PersonMailingCountry );
       
        jsonGenMap.put('PrimaryAddress', jsonPrimaryAddressMap);
       
        Map<String, Object> jsonCreditScoreMap = new Map<String, Object>();
        if(personAccount.equifaxScore__pc != null)
            jsonCreditScoreMap.put('equifaxScore', personAccount.equifaxScore__pc);
        if(personAccount.transunionScore__pc != null)
            jsonCreditScoreMap.put('transunionScore', personAccount.transunionScore__pc);
        if(personAccount.experianScore__pc != null)
            jsonCreditScoreMap.put('experianScore', personAccount.experianScore__pc);
        jsonGenMap.put('CreditScore',jsonCreditScoreMap);
       
        Map<String, Object> jsonMailAddressMap = new Map<String, Object>();
        addAddress(jsonMailAddressMap, personAccount.PersonMailingStreet);
       
        if(personAccount.PersonMailingCity != null)
            jsonMailAddressMap.put('city', personAccount.PersonMailingCity);
        if(personAccount.PersonMailingState != null)
            jsonMailAddressMap.put('state', personAccount.PersonMailingState);
        if(personAccount.PersonMailingPostalCode != null)
            jsonMailAddressMap.put('zipcode', personAccount.PersonMailingPostalCode);
        if(personAccount.PersonMailingCountry != null)
            jsonMailAddressMap.put('country', personAccount.PersonMailingCountry);
       
        jsonGenMap.put('MailAddress', jsonMailAddressMap);
        if(personAccount.PersonEmail != null)
            jsonGenMap.put('email', personAccount.PersonEmail);
        jsonGenMap.put('__ignoreWarnings', true);
       
        String jsonstring = JSON.serialize(jsonGenMap);
       
        HttpRequest req = new HttpRequest();
        req.setHeader('content-type', 'application/json');
        req.setMethod('POST');
        req.setEndpoint('https://loanpro.simnang.com/api/public/api/1/odata.svc/Customers()');
        req.setBody(jsonstring);
        req.setTimeout(120000);
        Http http = new Http();
        HttpResponse res = http.send(req);
        if(res.getStatusCode() == 200)
        {  
            System.debug('res.getStatusCode() >> '+res.getStatusCode());
            System.debug('res.getStatus() >> '+res.getStatus());
        }
        else
        {
            System.debug('res.getStatusCode() >> '+res.getStatusCode());
            System.debug('res.getStatus() >> '+res.getStatus());
            System.debug('res.getBody() >> '+res.getBody());
        }
    }
}

 

4.  Create New Loan

Through the utilization of robust APIs, the process of creating new loans becomes not just a task but a strategic advantage. Salesforce, as the central hub for customer relationship management, becomes the conduit for this transformative action. With the integration's API functionalities, financial institutions can initiate the creation of new loans directly from within Salesforce, eliminating the need for manual data entry and minimizing the risk of errors. This not only accelerates the loan origination process but also ensures that customer data is consistently accurate and up-to-date across both platforms. In this blog, we'll delve into the intricacies of using APIs to create new loans, unlocking a world of efficiency, accuracy, and unparalleled customer service within the Salesforce ecosystem.

For more information you can refer this link: https://developers.loanpro.io/reference/getting-started-with-your-api

To create new loan, we need to create an apex class named CreateLoan.

public class CreateLoan {
    public static void createLoanAPICall() {
        Map<String, Object> mainMap = new Map<String, Object>();        
        Map<String, Object> loanSetupMap = new Map<String, Object>();
        if(opp.Amount != null)
            loanSetupMap.put('loanAmount', opp.Amount);
        if(opp.Discount__c != null)
            loanSetupMap.put('discount', opp.Discount__c);
        if(opp.Underwriting__c != null)
            loanSetupMap.put('underwriting', opp.Underwriting__c);
        if(opp.Loan_Rate__c != null)
            loanSetupMap.put('loanRate', opp.Loan_Rate__c);
        if(opp.Loan_Rate_Type__c != null)
            loanSetupMap.put('loanRateType', opp.Loan_Rate_Type__c);
        if(opp.Loan_Term__c  != null)
            loanSetupMap.put('loanTerm', opp.Loan_Term__c   );
        if(opp.Payment_Frequency__c != null)
            loanSetupMap.put('paymentFrequency ', opp.Payment_Frequency__c);
        if(opp.Contract_Date__c != null)
            loanSetupMap.put('contractDate', opp.Contract_Date__c);
        if(opp.First_Payment_Date__c != null)
            loanSetupMap.put('firstPaymentDate', opp.First_Payment_Date__c);
        if(opp.Residual__c != null)
            loanSetupMap.put('residual', opp.Residual__c);
        if(opp.Money_Factor__c != null)
            loanSetupMap.put('moneyFactor', opp.Money_Factor__c);
        if(opp.Interest_Tiers__c != null)
            loanSetupMap.put('useInterestTiers', opp.Interest_Tiers__c);
        if(opp.Credit_Limit__c != null)
            loanSetupMap.put('creditLimit', opp.Credit_Limit__c);
        if(opp.Loan_Class__c != null)
            loanSetupMap.put('loanClass', opp.Loan_Class__c);
        if(opp.Loan_Type__c != null)
            loanSetupMap.put('loanType', opp.Loan_Type__c);
        if(opp.Preferred_Down_Payment__c != null)
            loanSetupMap.put('amountDown', opp.Preferred_Down_Payment__c);
        if(opp.Sales_Price__c != null)
            loanSetupMap.put('salesPrice', opp.Sales_Price__c);
        if(opp.Taxes__c != null)
            loanSetupMap.put('taxes', opp.Taxes__c);
        if(opp.GAP__c != null)
            loanSetupMap.put('gap', opp.GAP__c);
        if(opp.Dealer_Profit__c != null)
            loanSetupMap.put('dealerProfit', opp.Dealer_Profit__c);
        if(opp.Warranty__c != null)
            loanSetupMap.put('warranty', opp.Warranty__c);
        if(opp.Reserve__c != null)
            loanSetupMap.put('reserve', opp.Reserve__c);
        if(opp.Calculation_Type__c != null)
            loanSetupMap.put('calcType', opp.Calculation_Type__c);
        if(opp.Discount_Split__c != null)
            loanSetupMap.put('discountSplit', opp.Discount_Split__c);
        if(opp.Discount_Calc__c != null)
            loanSetupMap.put('discountCalc', opp.Discount_Calc__c);
        if(opp.Days_in_Year__c != null)
            loanSetupMap.put('daysInYear', opp.Days_in_Year__c);
        if(opp.Interest_Application__c != null)
            loanSetupMap.put('interestApplication', opp.Interest_Application__c);
        if(opp.Beginning_End__c != null)
            loanSetupMap.put('begEnd', opp.Beginning_End__c);
        if(opp.Last_as_Final__c != null)
            loanSetupMap.put('lastAsFinal', opp.Last_as_Final__c);
        if(opp.Round_Decimals__c != null)
            loanSetupMap.put('roundDecimals', opp.Round_Decimals__c);
        if(opp.Loan_Calculation__c != null)
            loanSetupMap.put('nddCalc', opp.Loan_Calculation__c);
        if(opp.Grace_Days__c != null)
            loanSetupMap.put('graceDays', opp.Grace_Days__c);
        if(opp.Schedule_Round__c != null)
            loanSetupMap.put('scheduleRound', opp.Schedule_Round__c);
        if(opp.First_Day_Interest__c != null)
            loanSetupMap.put('firstDayInterest', opp.First_Day_Interest__c);
        if(opp.End_Interest__c != null)
            loanSetupMap.put('endInterest', opp.End_Interest__c);
        if(opp.Fees_Paid_by__c != null)
            loanSetupMap.put('feesPaidBy', opp.Fees_Paid_by__c);
        if(opp.Payment_Date_Application__c != null)
            loanSetupMap.put('paymentDateApp', opp.Payment_Date_Application__c);
        if(opp.Late_Fee_Type__c != null)
            loanSetupMap.put('lateFeeType', opp.Late_Fee_Type__c);
        if(opp.Loan_First_Period_Days__c != null)
            loanSetupMap.put('firstPeriodDays', opp.Loan_First_Period_Days__c);
        if(opp.Schedule_Template__c != null)
            loanSetupMap.put('scheduleTemplate', opp.Schedule_Template__c);
       
        mainMap.put('LoanSetup', loanSetupMap);
        if(opp.Opportunity_Number__c != null)
            mainMap.put('displayId', opp.Opportunity_Number__c);
       
        String jsonString = Json.serialize(mainMap);
       
        HttpRequest req = new HttpRequest();
        req.setHeader('content-type', 'application/json');
        req.setMethod('POST');
        req.setEndpoint('https://loanpro.simnang.com/api/public/api/1/odata.svc/Loans');
        req.setBody(jsonstring);
        req.setTimeout(120000);
        Http http = new Http();
        HttpResponse res = http.send(req);
        if(res.getStatusCode() == 200)
        {  
            System.debug('res.getStatusCode() >> '+res.getStatusCode());
            System.debug('res.getStatus() >> '+res.getStatus());
        }
        else
        {
            System.debug('res.getStatusCode() >> '+res.getStatusCode());
            System.debug('res.getStatus() >> '+res.getStatus());
            System.debug('res.getBody() >> '+res.getBody());
        }
    }
}

 

5.  Activate Loan

This request activates a loan. When a loan is created, it also needs to be activated.

Typically, the "Activate Loan" functionality in loan management systems involves the process of making a loan ready for disbursement or active status. This can include steps such as verifying borrower information, confirming documentation, and ensuring that all necessary criteria are met before the funds are released. The integration of LoanPro with Salesforce likely streamlines this activation process, providing a more efficient and seamless experience for financial institutions managing loans within the Salesforce platform.

For more information you can refer this link: https://developers.loanpro.io/reference/activate-a-loan

To create new loan, we need to create an apex class named ActivateLoan.

public class ActivateLoan {
    public static void activateLoanAPICall(Id oppId) {
        Opportunity opp = [Select Id, LoanProId__c, Loan_Status__c from Opportunity where Id = :oppId];
        Map<String, Object> mainMap = new Map<String, Object>();        
        mainMap.put('__ignoreWarnings', true);
       
        String jsonString = Json.serialize(mainMap);
        System.debug('jsonString = '+jsonString);
       
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://loanpro.simnang.com/api/public/api/1/Loans('+opp.LoanProId__c+')/AutoPal.Activate()');
        req.setHeader('content-type', 'application/json');
        req.setMethod('POST');
        req.setBody(jsonstring);
       
        Http http = new Http();
        HttpResponse res = http.send(req);
       
        if(res.getStatusCode() == 200)
        {
            System.debug('res.getStatusCode() >> '+res.getStatusCode());
            System.debug('res.getStatus() >> '+res.getStatus());
            System.debug('res.getBody() >> '+res.getBody());
           
            opp.Loan_Status__c = 'Active';
            update opp;
        }
        else
        {
            System.debug('Error >> '+res.getBody()+ ' Status Code >> ' +res.getStatusCode());
        }
    }
}

 

6.  Link Customer to Loan

Generally, linking a customer to a loan in a loan management system involves establishing a connection between the borrower or customer profile and the specific loan or loans associated with that customer. This linkage can be crucial for maintaining a comprehensive view of customer information and ensuring that loan data is accurately attributed to the correct individuals.

In the context of integration with Salesforce, linking a customer to a loan may involve the seamless transfer and synchronization of customer data between LoanPro and Salesforce, creating a unified and consistent view within the Salesforce environment.

For more information you can refer this link: https://developers.loanpro.io/reference/link-customer-to-loan

To create new loan, we need to create an apex class named LinkCustomerToLoan.

public class LinkCustomerToLoan {
    public static void linkCustomerToLoanAPICall(List<ID> ids, String loanId){
        System.debug('Invoked LinkCustomerWithLoan');
       
        Map<String, Object> mainMap = new Map<String, Object>();
        Map<String, Object> customersMap = new Map<String, Object>();
        List<Map<String, Object>> results = new List<Map<String, Object>>();
        Map<String, Object> resultMap = new Map<String, Object>();
       
        resultMap.put('__id', 1);
        resultMap.put('__setLoanRole', 'loan.customerRole.primary');
        results.add(resultMap);
        customersMap.put('results', results);
        mainMap.put('Customers', customersMap);
       
        String jsonString = Json.serialize(mainMap);
        System.debug('jsonString = '+jsonString);
       
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://loanpro.simnang.com/api/public/api/1/odata.svc/Loans('+loanId+')');
        req.setHeader('content-type', 'application/json');
        req.setMethod('PUT');
        req.setBody(jsonstring);
       
        Http http = new Http();
        HttpResponse res = http.send(req);
       
        if(res.getStatusCode() == 200)
        {
            System.debug('res.getStatusCode() >> '+res.getStatusCode());
            System.debug('res.getStatus() >> '+res.getStatus());
            System.debug('res.getBody() >> '+res.getBody());
        }
        else
        {
            System.debug('Error >> '+res.getBody()+ ' Status Code >> ' +res.getStatusCode());
        }
    }
}

 

I hope this blog helped you!