# Traditional Lending

#### if you are building a digital lending system, abierta can help you&#x20;

* [manage origination](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/loan-request#create-loan-request) - you can use abierta to create and track loan requests
* [disburse loans](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/disbursement) - we can help you disburse your loans automatically
* [decisioning](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/decisioning) - we can help you make better decisions, and help you lend smarter and more effectively
* [manage collections](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/collections) - our API enables you to handle collections automatically using either the `remita debit mandate` or `cards`

For traditional lending, abierta pairs well with [configure](https://www.getconfigure.io/) the core lending platform to enabling you to track all loan requests, loans, and repayments and provide you with insights to lend smarter with metrics

Now, let's take you through one way you could implement these endpoints to maximize abierta for your lending process. You are welcome to customize the workflow by consulting the [API reference](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference) to suit your specific needs.

#### 1. Creating a User `server side`

Every loan request is tied to a user - the person who the loan was requested for, so the first step when creating a loan request for a new user is usually to [create a user](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/users#create-a-user-for-a-lender-organization) on the configure platform.

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://configure-abierta-test.herokuapp.com/api/v1/user' \
--header 'Authorization: Bearer cnfg_tst_LjZcK1wWEU5gac04IaeeBf188' \
--header 'Content-Type: application/json' \
--data-raw '{
    "firstname": "Daniel",
    "lastname": "Josiah",
    "email": "isongjosiah+34@gmail.com",
    "password": "password",
    "phone": "+2348182791196",
    "gender":"Male"
}'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "firstname": "John",
  "lastname": "Doe",
  "email": "johndoe@gmail.com",
  "password": "password",
  "phone": "+2348182791196",
  "gender": "Male"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};
var baseURL = "https://configure-abierta-test.herokuapp.com"
fetch(baseURL + "/api/v1/user", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Java" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://configure-abierta-test.herokuapp.com/api/v1/user")
  .header("Authorization", "Bearer cnfg_tst_LjZcK1wWEU5gac04IaeeBf188")
  .header("Content-Type", "application/json")
  .body("{\n    \"firstname\": \"Daniel\",\n    \"lastname\": \"Josiah\",\n    \"email\": \"isongjosiah+34@gmail.com\",\n    \"password\": \"password\",\n    \"phone\": \"+2348182791196\",\n    \"gender\":\"Male\"\n}")
  .asString();
java
```

{% endtab %}
{% endtabs %}

#### &#x20;2. Create a loan request for a user

This integration, uses two configure API objects, to [create a loan request](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/loan-request#creating-a-new-loan-request).

1. A User. To create a loan request, it must be attached to a User. Create a User object when your customer creates an account on your platform.
2. A Loan Request is an object that represents a customer's request for a loan.

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://configure-abierta-test.herokuapp.com/api/v1/user/1/loan_request?product-id=1' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "amount": 20000,
    "purpose": "House Rent"
}'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer ");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "amount": 20000,
  "purpose": "House Rent"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};
var baseURL = "https://configure-abierta-test.herokuapp.com"
fetch(baseURL + "/api/v1/user/1/loan_request?product-id=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Java" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("http://localhost:6000/api/v1/user/1/loan_request?product-id=1")
  .header("Authorization", "Bearer ")
  .header("Content-Type", "application/json")
  .body("{\n    \"amount\": 20000,\n    \"purpose\": \"House Rent\"\n}")
  .asString();
```

{% endtab %}
{% endtabs %}

#### 3. Submit a loan request

This integration allows you to submit a loan request.\
When a user has created a loan request and added additional information that you require for your loan product such as the [bank details](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/loan-request#add-bank-details), [employment information](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/loan-request#add-employment-information),[ guarantor information](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/loan-request#add-guarantor), you can trigger this endpoint to [submit the loan request](https://evolvecredit.gitbook.io/evolve-credit-api-suite/api-reference/loan-request#submit-loan-request) for consideration.

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request PUT 'https://configure-abierta-test.herokuapp.com/api/v1/loan_request/1/submit?product-id=1' \
--header 'Authorization: Bearer cnfg_tst_LjZcK1wWEU5gac04IaeeBf188'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer cnfg_tst_LjZcK1wWEU5gac04IaeeBf188");

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  redirect: 'follow'
};

var baseURL = "https://configure-abierta-test.herokuapp.com"
fetch(baseURL + "/api/v1/loan_request/1/submit?product-id=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Java" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.put("https://configure-abierta-test.herokuapp.com/api/v1/loan_request/1/submit?product-id=1")
  .header("Authorization", "Bearer cnfg_tst_LjZcK1wWEU5gac04IaeeBf188")
  .asString();

```

{% endtab %}
{% endtabs %}

#### 4. Approve a loan request

Loan approval can be triggered either from the configure dashboard or via this integration, allowing you more flexibility in your workflow. Most of our existing customers opt to approve a loan request from the dashboard.\
If you are approving a loan request from the API integration, you are required to send the terms of the approval, containing the following;\
1\. `approved_amount`: how much has been approved for the customer from the required amount.\
2\. `rate`: the interest rate for the loan\
3\. `tenure`: the length of time before the loan matures\
4\. `tenured_in`: what the `tenure` is measured in. allowed values are `months`, `days`, `weeks`\
5\. `rate_type`: allowed values are `simple-interest`, `compound-interest`, and `fixed-amount`\
6\. `frequency`: how often the loan would be paid back within the tenure, allowed values are `daily`, `weekely`, `bi-weekly`, `monthly`\
7\. `note`:&#x20;

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location --request POST 'https://configure-abierta-test.herokuapp.com/api/v1/loan_request/38/action?action=approve&product-id=1' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "approved_amount":200,
    "rate":2.5,
    "tenure":5,
    "tenured_in":"months", 
    "rate_type":"simple-interest",
    "exclude_weekends":true,
    "frequency":"monthly", 
    "grace_period":1,
    "note":"Approved because -- blah, blah, blah..." 
}'c
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "approved_amount": 200,
  "rate": 2.5,
  "tenure": 5,
  "tenured_in": "months",
  "rate_type": "simple-interest",
  "exclude_weekends": true,
  "frequency": "monthly",
  "grace_period": 1,
  "note": "Approved because -- blah, blah, blah..."
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

var baseURL = "https://configure-abierta-test.herokuapp.com"
fetch(baseURL + "/api/v1/loan_request/38/action?action=approve&product-id=1", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Java" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://configure-abierta-test.herokuapp.com/api/v1/loan_request/38/action?action=approve&product-id=1")
  .header("Authorization", "Bearer token")
  .header("Content-Type", "application/json")
  .body("{\n    \"approved_amount\":200,\n    \"rate\":2.5,\n    \"tenure\":5,\n    \"tenured_in\":\"months\", \n    \"rate_type\":\"simple-interest\",\n    \"exclude_weekends\":true,\n    \"frequency\":\"monthly\", \n    \"grace_period\":1,\n    \"note\":\"Approved because -- blah, blah, blah...\" \n}")
  .asString();

```

{% endtab %}
{% endtabs %}
