# Loan disbursement

## Prerequisites

To disburse funds for a new loan, you need to decide which payment method you will use. Each payment method requires different information and has its own particularities in speed, pricing, and KYC requirements.&#x20;

{% stepper %}
{% step %}

### Prerequisite

* [ ] Make sure you have a sandbox account for testing and read the developer quickstart as [described here](https://docs.zumrails.com/getting-started/quickstart)&#x20;
* [ ] Get the api username and password in the sandbox portal as [described here](https://docs.zumrails.com/getting-started/your-zum-rails-account#get-access-to-api-credentials)
* [ ] Get your funding source id. You can find this information in your portal under settings/funding source page or via API, as [described here](https://docs.zumrails.com/api-reference/funding-source)
* [ ] Get your wallet id. You can find this information in your portal under the wallet page or via API, as [described here](https://docs.zumrails.com/api-reference/wallets)
* [ ] Decide which payment method you would want to use to disburse the loan. Each payment method has its own pros and cons, as [described here](https://docs.zumrails.com/payments/payment-rails)
  {% endstep %}

{% step %}

### Authenticate with Zūm APIs

Authenticate with the  Zūm Rails API as indicated below, or view more details [here](https://docs.zumrails.com/api-reference/authentication)

```
Endpoint: /api/authenticate
Method: POST
```

```json
{
  "Username": "abc...123",
  "Password": "xyz...321"
}
```

{% endstep %}

{% step %}

### Fund Zūm Wallet

To disburse loans, funds must first be deposited into the Zūm Rails platform. A good idea is to fund the Zūm Wallet at the beginning of the week and then use these funds to issue new loans throughout the week.&#x20;

Create a transaction to fund the wallet from your funding source. A funding source is your operating bank account from your business with your bank. Make sure you inform the FundingSourceId and the WalletId in the payload, as well as the amount that will be enought to the loans you plan to issue.

If needed, you can check the Zūm Wallet balance before as described [here](https://docs.zumrails.com/api-reference/wallets)

```
Endpoint: /api/transaction
Method: POST
```

```json
{
  "ZumRailsType": "FundWallet",
  "TransactionMethod": "Eft",
  "Amount": 123.45,
  "Memo": "Fund 01",
  "Comment": "Funding Zum Wallet for weekly loan disbursements",
  "FundingSourceId": "<your-funding-source-id>",
  "WalletId": "<your-wallet-id>"
}
```

{% endstep %}

{% step %}

### Create a user - The loan recipient

Create a user, the recipient of the loan. There are different ways to add a new user. API, Zūm Connect (widget), or manually through the portal. More details can be found [here](https://docs.zumrails.com/getting-started/quickstart#ways-to-integrate).

Depending on the information stored on Zūm Rails, different payment methods will be enabled. For example, if an email is provided, Interac can be enabled; if bank account information is provided, then EFT or ACH can be enabled; if a credit card is provided, then credit card payments can be enabled.&#x20;

```
Endpoint: /api/user
Method: POST
```

#### Example of creating a user that will enable Interac e-transfer:

```json
{
  "FirstName": "John",
  "LastName": "Doe",
  "Email": "johndoe@zumrails.com"
}
```

#### Example of creating a user that will enable EFT payments:

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "FirstName": "John",
  "LastName": "Doe",
  "Email": "johndoe@zumrails.com",
  "BankAccountInformation": {
    "InstitutionNumber": "123",
    "TransitNumber": "12345",
    "AccountNumber": "1234567"
  }
}
</code></pre>

#### Example of creating a user that will enable Interac and EFT payments via data aggregation:

To add a user via data aggregation, you can use Zūm Rails data aggregation, either standalone as described [here](https://docs.zumrails.com/data-aggregation/overview) or with PAD consent page as described [here](https://docs.zumrails.com/tokenization-1/zum-connect#user-tokenization-add-payment-profile).

{% hint style="info" %}
After creating the user, you have to store the Zūm Rails user id, received in the response of the api call.&#x20;
{% endhint %}
{% endstep %}

{% step %}

### Create transaction - **Disburse** the loan

Now, to disburse the loan, you can create a transaction like the example below.

```
Endpoint: /api/transaction
Method: POST
```

#### Loan disbursement via Interac e-transfer

```json
{
  "ZumRailsType": "AccountsPayable",
  "TransactionMethod": "Interac",
  "Amount": 123.45,
  "Memo": "Laon 01",
  "Comment": "Issuing a loan via Interac e-transfer to John Smith",
  "UserId": "<the-user-id-from step 4",
  "WalletId": "<your-wallet-id>",
  "InteracHasSecurityQuestionAndAnswer": true,
  "InteracSecurityQuestion": "Your question",
  "InteracSecurityAnswer": "Your answer"
}
```

#### Loan disbursement via EFT

```json
{
  "ZumRailsType": "AccountsPayable",
  "TransactionMethod": "Eft",
  "Amount": 123.45,
  "Memo": "Laon 01",
  "Comment": "Issuing a loan via EFT to John Smith",
  "UserId": "<the-user-id-from step 4",
  "WalletId": "<your-wallet-id>"
}
```

{% hint style="info" %}
After creating the transaction, you have to store the Zūm Rails transaction id, received in the response of the api call.&#x20;
{% endhint %}
{% endstep %}

{% step %}

### Receive payment updates

The recommended way to receive payment updates is through webhooks.

You can configure your webhook URL and which events you might want to receive in the Zūm Rails portal, under settings/webhook and api settings.

<figure><img src="https://1258268478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKJSaSy1sLkMkigNL7ONH%2Fuploads%2FHABsRYDakzj2FtGxEtaH%2Fimage.png?alt=media&#x26;token=f86361db-5d32-4bd3-b895-90aa92704128" alt="" width="272"><figcaption></figcaption></figure>

We recommend setting up the transaction status events, selecting all statuses.

<p align="center"><img src="https://1258268478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKJSaSy1sLkMkigNL7ONH%2Fuploads%2FmeOaakWL2A5ge1gybDGp%2Fimage.png?alt=media&#x26;token=f7cbc829-b63b-4246-b22e-7d5fb6ff2fb2" alt=""> </p>

When the transaction status changes, we will post to your webhook URL with the transaction GET payload, as [described here](https://docs.zumrails.com/api-reference/transactions#get-a-specific-transaction)&#x20;
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zumrails.com/recipes/loan-disbursement.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
