Introduction

The reference is your key to a comprehensive understanding of the Notion API.

<aside> ❗ As a solution provider you might find yourself in need of a service that allows you to provide loans to your customers. MIM’s embedded lending service allows you to do this quick and easy with a little bit of HTML, CSS and a little bit more of Javascript.

</aside>

Requirements

  1. Completed aggregator form - https://embed.moneyinminutes.ng/
  2. Your account public and secret key
  3. A little knowledge of HTML, CSS & JavaScript

Sign Up with MIM

The first thing is to click on the link to complete the onboarding form where you are required to supply the information below and submit. A member of our team will verify your submission and confirm approval via email. You will receive another email containing your public and secret key.

| Info | Description | | --- | --- | | Name | Company name | | RC Number | Company rc number | | Email | Company email | | Phone number | Company contact phone number | | Description | About the company | | Website | Company website | | Address | Company address | | TIN | Company tax identification number | | Industry | Company industry | | Company Size | Size of the users expected to take loans | | Consistent Payday | Date for loan repayments | | Highest Staff/Customer Income | Maximum income of user the company will offer loan to | | Lowest Staff/Customer Income | Minimum income of user the company will offer loan to | | Terms and Condition URL | Url where the user can see the company terms and conditions | | Loan Application Redirect URL | Webhook Url for MIM to call to pass the users loan status at the point of submission | | Loan Status URL | Webhook Url for MIM to call to pass the users loan status at any point after submission | | Customer History URL | Url to provide us with the users financial transaction history on your platform | | Product URL | The URL that your customers will use in accessing a loan on your platform |

Integration Options

Now that we have a key and a secret, what next?

In order to gain access to MIM’s library for embedded lending, you simply have to link the library as shown below:

<script src="[<https://devembed.azurewebsites.net/embed/js>](<https://devembed.azurewebsites.net/embed/js>)" type="text/javascript"></script>

This gives you access to the loadMimEmbedded() function.

There are two (2) options to proceed with after this and both of them are described below:

1. Affiliate Lending

This option is necessary when you do not have a need for full integration but want to offer lending on your website. You do not need to implement any callback and all you need is your API key, which you will pass as a parameter to the function.

To implement Affiliate Lending, simply follow the steps below:

  1. Add an HTML button anywhere on your page, where you want the user to click to start the lending process:
<button id="MIMLoanBtn" type="button" class="btn btn-primary">Take Loan</button>
  1. Copy the code below and replace the API key with yours and paste it right after the JavaScript code above:
<script> loadMimEmbedded('MIMLoanBtn', { apiKey: "<Your API key>" }); </script>

That’s all. You are now set to start offering lending on your website.

2. Embedded Lending Integration

This option is necessary when you have a fully functioning system and want to do a full integration, which controls everything from:

To use this option, simply do the following:

  1. Add an HTML button anywhere on your page, where you want the user to click to start the lending process. The ID of the button triggers the beginning of a loan application process:
<button id="MIMLoanBtn" type="button" class="btn btn-primary">Take Loan</button>
  1. Create a JSON object containing the information required to take a loan.

    The JSON object needs to conform to the structure below:

    {
    	email: "[email protected]",
    	phoneNumber: "08093773683",
    	bvn: "09578490230",
    	nin: "09578490232",
    	apiKey: "{{ *Your API key goes here* }}",
    	authorisation: "{{ *Your Authorisation goes here* }}",
    	requestKey: "{{ *Your Request Key goes here* }}",
    	loanId: "{{ *Your  Loan ID goes here* }}",
    	bankCode: "200",
    	customerId: "{{ Your application's unique ID for the customer }}",
    	bankAccountNumber: "0987654321",
    	employmentRecord:
    	{
    		sector: EmployerSector.Banking,
    		employmentType: EmploymentType.Employed,
    		employerName: "MIM Finance Ltd",
    		employerAddress: "Lekki Phase 1, Lekki",
    		city: "Lagos",
    		state: "Lagos",
    		employerPhone: "08093773683",
    		employmentDate: '2020-03-07T00:00:00',
    		netMonthlyIncome: 150000.00,
    		duration: EmploymentLength.Four,
    		nextPayDay: '2023-06-30T00:00:00',
    		toleranceDays: 2,
    		totalMonthlyExpense: 100000,
    		salaryFrequency: PayFrequency.Monthly,
    		incomeReceiptMode: IncomeReceiptMode.Bank
    	}
    }
    
  2. Both Step 1 and Step 2 above comes together in the script you eventually add to the page. The script should be added after the <script> described above and should be in the format below:

<script> loadMimEmbedded('MIMLoanBtn', <The JSON object from Step 2.>); </script>

Clearing possible sources of confusion

There are a few parameters in the JSON object that may not be intuitive

Parameter Description
requestKey This is a Guid generated for every request. It is used to calculate the value of the Authorisation parameter.
authorisation This is generated by computing the Sha512 of the concatenation of the strings; apiKey, requestKey and apiSecret (In this order).
loanId This is the key to be used as the primary key for accessing information about the loan on your database, it also allows MIM send information pertaining to your loan directly to your server.
employmentDate and nextPayDay The datetime parameters are required to conform to this format: YYYY-MM-DD

There are objects that make it easy provide values to some of the parameters.

employerSector:
{
	Public: 1,
	Private: 2,
	Banking: 3,
	OilAndGas: 4,
	FMCG: 5,
	Construction: 6,
	Manufacturing: 7,
	Other: 8
};

employmentType:
{
	Employed: 1,
	SelfEmployed: 2,
	Contract: 3,
	PartTime: 4,
	Unemployed: 5
};

employmentLength:
{
	LessThanOne: 0,
	One: 1,
	Two: 2,
	Three: 3,
	Four: 4,
	Five: 5,
	Six: 6,
	Seven: 7,
	Eight: 8,
	Nine: 9,
	Ten: 10,
	TenPlus: 11
};

payFrequency:
{
	Weekly: 2,
	Monthly: 3
};

incomeReceiptMode:
{
	Bank: 1,
	Cheque: 2,
	Cash: 3
};

If all goes well, a click on our button should give us something like this:

Untitled

Callbacks

For the loans to be properly serviced and interactions maintained between or systems, a number of callbacks are required to be made available from you. These are in addition to the ones we have made available on our end.

These callbacks are described below:

1. Loan Status Check Callback (MIM)

This is an MIM URL you call whenever you want to verify the status of a loan taken by a user on your system.

The status check is done by making a POST request to the URL below. This check can be done at any time, if you wish to know the status of the loan:

METHOD: POST

PAYLOAD SAMPLE:

curl <https://devembed.azurewebsites.net/embed/webhook/request-loan-status>
  {
    "loanId" : "2561065d-77e3-4c77-a623-6428caa70d51",
    "apiKey" : "{{ Your API Key goes here }}",
    "requestKey" : "{{ Your Request Key goes here }}",
    "authorisation" : "{{ Your Authorisation goes here }}"
}

RESPONSE SAMPLE:

{
    "success": true,
    "message": null,
    "data": "Approved"
}

The data parameter of this JSON object tells us the status of the loan.

Loan Status

We can use this data to make updates on our web app and redirect users as appropriate.

Status Description
None The user has no loan
Application The user is in the process of a loan application
In Review The user’s loan has been submitted for review
Approved The user’s loan has been approved and yet to be disbursed
Active The user’s loan has been disbursed
Expired The user’s loan application expired before it was submitted
InArrears The user’s loan is yet to be settled and has passed the due date
Bad The user’s loan has been InArrears for more than 30days
Settled The user’s loan has been completely paid off
Cancelled The user’s loan has been cancelled by early repayment within 24 hours of disbursement

2. Loan Repayment Callback URL (MIM)

If you wish to do the loan collection on your system, this is the endpoint you invoke to inform MIM whenever you successfully make any collection on the loan repayment schedule. Invoking of this URL before a collection schedule is due compels MIM system to not attempt to effect a collection for that particular schedule.

PAYLOAD SAMPLE:

curl <https://devembed.azurewebsites.net/embed/webhook/notify-loan-repayment>
  {
    "mimLoanId" : 341,
    "apiKey" : "{{ Your API Key goes here }}",
    "requestKey" : "{{  Your Request Key goes here  }}",
    "authorisation" : "{{ Your Authorisation goes here }}",
    “amount”: 35000,
    “transactionRef”: "{{ Your Transaction Reference }}"
}

RESPONSE: This callback returns HTTP 200 code to indicate that it was successfully registered. No message body.

3. Loan Application Redirect URL

You are required to supply a URL that users are redirected to at the end of a loan application process. MIM will redirect the page to that URL after the loan process is completed (success or failure).

When MIM redirects to the URL, the parameter loanId is supplied as a query to the URL. This is the same Loan ID you supplied in the JSON above. You are required to do a status check, using the loan ID to determine the correct message to display to your customer.

4. Customer Financial History Callback

MIM uses these information (essentially a history of payment made to users' accounts) from your service to evaluate the user’s eligibility for a loan.

If you provide this URL, at the point of making the loan request, MIM will make a call to this URL and retrieve the financial history of the customer available on your service. You are required to provide a 6-month record, starting from the date of loan application and going back.

Depending on the product and/or your API key settings, if this record is not provided the loan application either fails or MIM will retrieve the customer's bank statement and use it to determine loan eligibility.

METHOD: POST

PAYLOAD SAMPLE

  {
    "apiKey": "{{ Your API Key goes here }}",
    "customerId" : [email protected],
    "requestKey" : "{{ Your request key goes }}",
    "authorisation" : "{{ Your authorisation goes here }}"
	 }

RESPONSE SAMPLE

  [
    {
        "transactionId": "021b9f44-9829-4c81-a5db-f3d914d27754",
        "customerId": "8a33b97e-7015-4c18-b76d-865d32c65c17",
        "date": "2023-02-28T00:00:00",
        "amount": "550378.551755848"
    },

    {
        "transactionId": "58dcc048-fa6b-48d7-8bd2-ebeed214a981",
        "customerId": "8a33b97e-7015-4c18-b76d-865d32c65c17",
        "date": "2023-05-28T00:00:00",
        "amount": "292381.447654273"
    },

    {
        "transactionId": "6bf1fce2-aca7-41d0-a0ed-c18c8d812bf8",
        "customerId": "8a33b97e-7015-4c18-b76d-865d32c65c17",
        "date": "2023-01-28T00:00:00",
        "amount": "571175.137770237"
    },

    {
        "transactionId": "6c43f0e3-6a40-4328-a745-c20c959f50f3",
        "customerId": "8a33b97e-7015-4c18-b76d-865d32c65c17",
        "date": "2023-04-28T00:00:00",
        "amount": "299452.533760001"
    },

    {
        "transactionId": "8e07c2e7-d0a4-4454-a81f-cc62abaeb8bc",
        "customerId": "8a33b97e-7015-4c18-b76d-865d32c65c17",
        "date": "2023-03-28T00:00:00",
        "amount": "204858.889490624"
    }
]

5. Activities on Customer Loans

As the loan lifecycle changes, MIM pushes updates to you on the activities happening to loans taken on your platform.

To receive these updates, you are required to expose an endpoint for MIM to push data to. This endpoint receives a JSON object in a post request and the JSON object looks like this:

{
   "apiKey":"{{ Your API Key goes here }}",
   "authorisation":"{{ Authorisation Code goes }}",
   "requestKey":"{{ The Request Key used to form authorisation code }}",
   "mimLoanId":"{{ Loan’s ID in MIM’s database }}",
   "status":"{{ Current status of the loan }}",
   "loanId":"{{ Loan ID in your database }}",
   "activity":"{{ Latest activity on the loan here}}",
   "repaymentSchedule":[
      {
         "dueDate":"YYYY-MM-DD ",
         "amount":"{{amount in Naira}}"
      },
      {
         "dueDate":"YYYY-MM-DD ",
         "amount":"{{amount in Naira}}"
      }
   ]
}

repaymentSchedule is null or empty array for all activities but is only available when Activity value is moneyDisbursed

The Status sent is as described above.

The Activity option is one of the options described below:

| --- | --- |

6. Get Disbursement Account

For the loan to be appropriately disbursed to the correct account, MIM needs to make a call to your system requesting for the right account to disburse the loan to. This happens during the loan application process.

This is appropriate if you wish the payment to be made to a customer wallet or your business account for a BNPL product/service. The account detail sent is checked for validity and if not valid, the payment is made to the customer’s bank account.

To make this happen, you need to expose a URL that takes the parameters below and returns the data as specified below:

PAYLOAD SAMPLE:

 {
    “apiKey”: "{{ Your API Key goes here }}",
    "customerId" : "[email protected]",
    "requestKey" : "{{ Your request key goes here }}",
    "authorisation" : "{{ Your authorisation goes here }}"
}

RESPONSE SAMPLE:

  {
		"accountName": "{{The name of the account}}",
		"accountNumber": "{{The account number}}",
		"bankCode": "{{The CBN bank code for the account}}"
	}

Loan Processing APIs

The following apis are available for your company to use in the processing of loan applications.

1. Get All Loans