# Hold and Release Settlement

Hold & Release Settlement is a feature that enables you to hold the settlement for a payment. This is a good solution for a merchant that needs to hold and release the settlement when needed. It is suitable for merchants who have a marketplace or ecommerce business.

#### Case Study <a href="#case-study" id="case-study"></a>

"Pasar Kelontong" is an online marketplace where sellers and buyers meet. They need to hold the settlement to their sellers and will only settle it after the buyers confirmed they have received the goods.

Therefore, they implement Hold and Release Settlement feature which makes the settlement hold until they trigger the release settlement API.

***

### Implementation <a href="#implementation" id="implementation"></a>

#### Hold Settlement <a href="#hold-settlement" id="hold-settlement"></a>

To do hold settlement, please add this `additional_info.hold_settlement` object into your payment request:

```json
{
...
    "additional_info": {
        "hold_settlement": true
    }
...
}
```

You can validate whether the settlement is hold by checking to [DOKU Back Office](https://jokul.doku.com/bo/login) and go to **Report > Reconciled Transactions**. You should see the transaction will have **Settlement Schedule** with `HOLD`.

<figure><img src="https://3092822868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqCxtvLoJNNxvp4U7kLHd%2Fuploads%2FROXK5ogM3hfM0xHQP2Pr%2FScreenshot%202024-07-12%20at%2007.51.49.png?alt=media&#x26;token=bd4873d8-c1cb-4489-a164-0a0e7a709045" alt=""><figcaption></figcaption></figure>

#### Sample usage <a href="#sample-usage" id="sample-usage"></a>

Let's assume you are using the Checkout integration. You can simply add these parameters into your API Initiate Payment:

```json
{
    "order": {
        "invoice_number": "INV-20210231-0001",
        "amount": 90000,
        "line_items": [
            {
                "name": "T-Shirt Red",
                "price": 30000,
                "quantity": 2
            },
            {
                "name": "Polo Navy",
                "price": 30000,
                "quantity": 1
            }
        ],
        "currency": "IDR",
        "callback_url": "https://merchant.com/return-url"
    },
    "payment": {
        "payment_due_date": 60,
        "payment_method_types": [
            "VIRTUAL_ACCOUNT_BCA",
            "VIRTUAL_ACCOUNT_BANK_MANDIRI",
            "VIRTUAL_ACCOUNT_BANK_SYARIAH_MANDIRI",
            "VIRTUAL_ACCOUNT_DOKU",
            "ONLINE_TO_OFFLINE_ALFA",
            "CREDIT_CARD",
            "DIRECT_DEBIT_BRI"
        ]
    },
    "customer": {
        "id": "CUST-0001",
        "name": "Anton Budiman",
        "email": "anton@example.com",
        "phone": "6285694566147",
        "address": "Menara Mulia Lantai 8",
        "country": "ID"
    },
    "additional_info": {
        "hold_settlement": true
    }
}
```

#### Release Settlement <a href="#release-settlement" id="release-settlement"></a>

To release the settlement, you will need to hit this API through your backend:

**API Request**

<table><thead><tr><th width="252">Type</th><th>Value</th></tr></thead><tbody><tr><td><strong>HTTP Method</strong></td><td>POST</td></tr><tr><td><strong>API endpoint (Sandbox)</strong></td><td><code>https://api-sandbox.doku.com/finance/v1/release</code></td></tr><tr><td><strong>API endpoint (Production)</strong></td><td><code>https://api.doku.com/finance/v1/release</code></td></tr></tbody></table>

Here is the sample of request header to release transaction into settlement:

```json
Client-Id: MCH-0001-10791114622547
Request-Id: fdb69f47-96da-499d-acec-7cdc318ab2fe
Request-Timestamp: 2021-05-08T08:45:42Z
Signature: HMACSHA256=1jap2tpgvWt83tG4J7IhEwUrwmMt71OaIk0oL0e6sPM=
```

<details>

<summary>Request Header Explanation</summary>

</details>

#### Request Header Explanation&#x20;

<table><thead><tr><th width="210">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Client-Id</strong></td><td>Client ID retrieved from DOKU Back Office</td></tr><tr><td><strong>Request-Id</strong></td><td>Unique random string (max 128 characters) generated from merchant side to protect duplicate request</td></tr><tr><td><strong>Request-Timestamp</strong></td><td>Timestamp request on UTC time in ISO8601 UTC+0 format. It means to proceed transaction on UTC+7 (WIB), merchant need to subtract time with 7. Ex: to proceed transaction on September 22th 2020 at 08:51:00 WIB, the timestamp should be 2020-09-22T01:51:00Z</td></tr><tr><td><strong>Signature</strong></td><td>Security parameter that needs to be generated on merchant Backend and placed to the header request to ensure that the request is coming from valid merchant. Please refer to <a href="../../get-started-with-doku-api/signature-component/non-snap/signature-component-from-request-header">this section</a> to generate the signature</td></tr></tbody></table>

Here is the sample of request body:

```json
{
    "order": {
        "invoice_number": "INV-20210231-0001",
        "amount": 90000,
        "currency": "IDR"
    },
    "transaction": {
        "original_request_id": "fdb69f47-96da-499d-acec-7cdc318ab2fe"
    },
    "override_settlement": 
        [
            {
                "bank_account_settlement_id": "SBA-0001-123123123",
                "value": 10,
                "type": "PERCENTAGE"
            },
            {
                "bank_account_settlement_id": "SBS-0002-321321321",
                "value": 90,
                "type": "PERCENTAGE"
            }
        ]
}

```

#### Request Body Explanation

<table><thead><tr><th width="227">Parameter</th><th width="107">Type</th><th width="122">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td><code>order.invoice_number</code></td><td><code>string</code></td><td>Mandatory</td><td>Same as the request that merchant sent on the payment initiation</td></tr><tr><td><code>order.amount</code></td><td><code>number</code></td><td>Mandatory</td><td>Same as the request that merchant sent on the payment initiation</td></tr><tr><td><code>order.currency</code></td><td><code>string</code></td><td>Mandatory</td><td>Same as the currency of original payment<br>Default value: <code>IDR</code></td></tr><tr><td><code>transaction.original_request_id</code></td><td><code>string</code></td><td>Mandatory</td><td>The request ID that sent when initiate the payment</td></tr><tr><td><code>override_settlement.bank_account_settlement_id</code></td><td><code>string</code></td><td>Optional</td><td>The bank_account_settlement_id that you retrieved from the DOKU Back Office</td></tr><tr><td><code>override_settlement.value</code></td><td><code>numeric</code></td><td>Optional</td><td>The value of the settlement can be in IDR or percentage based on the type defined. If you are using FIX type then the value should be the exact amount. If you are using PERCENTAGE type then the value should be the percentage</td></tr><tr><td><code>override_settlement.type</code></td><td><code>string</code></td><td>Optional</td><td>The type of the splitting funds.<br>Possible value: <code>FIX</code>, <code>PERCENTAGE</code></td></tr></tbody></table>

**API Response**

After hitting the above API request, DOKU will give the response.

| Type            | Value   |
| --------------- | ------- |
| **HTTP Status** | 200     |
| **Result**      | SUCCESS |

```jsonp
Client-Id: MCH-0001-10791114622547
Request-Id: fdb69f47-96da-499d-acec-7cdc318ab2fe
Response-Timestamp: 2021-05-08T08:45:42Z
Signature: HMACSHA256=9UPUFzOqJc47aJzD9ESOTcWg6TMsg3mqSP+DnUO8ENE=
```

#### Response Header Explanation&#x20;

<table><thead><tr><th width="222">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Client-Id</strong></td><td>Same as the request</td></tr><tr><td><strong>Request-Id</strong></td><td>Same as the request</td></tr><tr><td><strong>Response-Timestamp</strong></td><td>Timestamp Response on UTC with format ISO8601 UTC+0 from DOKU</td></tr><tr><td><strong>Signature</strong></td><td>Signature generated by DOKU based on the response body</td></tr></tbody></table>

Here is the sample response body:

```json
{
    "order": {
        "invoice_number": "INV-20210231-0001",
        "amount": 90000,
        "currency": "IDR"
    },
    "transaction": {
        "original_request_id": "fdb69f47-96da-499d-acec-7cdc318ab2fe",
        "settlement_date": "2021-05-09",
        "settlement_amount": 85500,
    }
}
```

#### Response Body Explanation&#x20;

<table><thead><tr><th>Parameter</th><th width="124">Type</th><th width="120">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td><code>order.invoice_number</code></td><td><code>string</code></td><td>Mandatory</td><td>Same as the request</td></tr><tr><td><code>order.amount</code></td><td><code>number</code></td><td>Mandatory</td><td>Same as the request</td></tr><tr><td><code>order.currency</code></td><td><code>string</code></td><td>Mandatory</td><td>Same as the request</td></tr><tr><td><code>transaction.original_request_id</code></td><td><code>string</code></td><td>Mandatory</td><td>Same as the request</td></tr><tr><td><code>transaction.settlement_date</code></td><td><code>string</code></td><td>Mandatory</td><td>Settlement date of this transaction (H+1)<br>Format: <code>yyyy-mm-dd</code></td></tr><tr><td><code>transaction.settlement_amount</code></td><td><code>number</code></td><td>Mandatory</td><td>The settlement amount after deducted with fee</td></tr></tbody></table>

{% hint style="success" %}
The funds will be settled to the defined bank account within one business day (H+1)
{% endhint %}

***

### FAQs <a href="#faqs" id="faqs"></a>

#### When will I receive my funds after I hit the release API? <a href="#when-will-i-receive-my-funds-after-i-hit-the-release-api" id="when-will-i-receive-my-funds-after-i-hit-the-release-api"></a>

You will receive your funds H+1 after you hit the release API

#### What currency supported for the settlement? <a href="#what-currency-supported-for-the-settlement" id="what-currency-supported-for-the-settlement"></a>

We support IDR, SGD, and USD settlement. Please make sure that your defined bank account is on respective currency.

#### Can I use this feature with split settlement or custom settlement report? <a href="#can-i-use-this-feature-with-split-settlement-or-custom-settlement-report" id="can-i-use-this-feature-with-split-settlement-or-custom-settlement-report"></a>

Of course, you can!
