> For the complete documentation index, see [llms.txt](https://docs.payon.com.kh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payon.com.kh/payon-api-reference/merchant-reconciliation.md).

# Merchant Reconciliation

This endpoint is uses for reconciliation request between merchant and PAYON Aggregator.

| Environment | URL                                                            |
| ----------- | -------------------------------------------------------------- |
| TEST        | [http://pgtest.payon.com.kh](http://pgtest.payon.com.kh:36605) |
| PRODUCTION  | [https://pg.payon.com.kh](https://pg.payon.com.kh:35505)       |

<mark style="color:green;">`POST`</mark> `{{URL}}/pg/merchant/reconcilation`

#### Request Body

| Name                                              | Type   | Description                                                                                                                                                                                       |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| termId<mark style="color:red;">\*</mark>          | String | Terminal's Identification                                                                                                                                                                         |
| merchantId<mark style="color:red;">\*</mark>      | String | Merchant's Identification                                                                                                                                                                         |
| buyerId                                           | String | Customer's Identification                                                                                                                                                                         |
| sellerId                                          | String | Customer's Identification                                                                                                                                                                         |
| txId<mark style="color:red;">\*</mark>            | String | Transaction's Identification                                                                                                                                                                      |
| grandToTAmt<mark style="color:red;">\*</mark>     |        | Grand total amount, including Fee                                                                                                                                                                 |
| transactionType<mark style="color:red;">\*</mark> | String | <p>Transaction's Type, Possible value are PURCHASE, </p><p>REFUND, </p><p>PRE\_AUTH, </p><p>PRE\_AUTH\_COMPLETE, PURCHASE\_REVERSAL, PRE\_AUTH\_REVERSAL,</p><p>PRE\_AUTH\_COMPLETE\_REVERSAL</p> |

{% tabs %}
{% tab title="200: OK Merchant Reconciliation Approved Case" %}

```javascript
[
    {
        "merchantId": "O0000021",
        "reconciliationDv": "APPROVED",
        "termId": "OW04000007",
        "txId": "1652858955940000",
        "buyerId": "becbd0f6-39b7-4b81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "grandToTAmt": 2.3,
        "resultMsg": "Success",
        "resultCode": "0000"
    },
    {
        "merchantId": "O0000021",
        "reconciliationDv": "APPROVED",
        "termId": "OW04000007",
        "txId": "1652886005159000",
        "buyerId": "becbd0f6-39b7-4b81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "grandToTAmt": 2.3,
        "resultMsg": "Success",
        "resultCode": "0000"
    }
]
```

{% endtab %}

{% tab title="200: OK Merchant Reconciliation Rejected Case" %}

```javascript
[
    {
        "merchantId": "O0000021",
        "reconciliationDv": "REJECTED",
        "termId": "OW04000007",
        "txId": "1652858955940000",
        "buyerId": "becbd0f6-39b7-4b81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "grandToTAmt": 2.3,
        "resultMsg": "Invalid CUSTOMER ID",
        "resultCode": "0006"
    },
    {
        "merchantId": "O0000021",
        "reconciliationDv": "REJECTED",
        "termId": "OW04000007",
        "txId": "1652886005159000",
        "buyerId": "becbd0f6-39b7-4b81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "grandToTAmt": 2.3,
        "resultMsg": "Invalid CUSTOMER ID",
        "resultCode": "0006"
    }
]
```

{% endtab %}
{% endtabs %}

## Respond Code

| ResultCode | ResultMsg           | Description                                        |
| ---------- | ------------------- | -------------------------------------------------- |
| 0000       | Success             | Reconciliation's Success                           |
| 9999       | System Error        | Reconciliation's Not Success                       |
| 0001       | Invalid Merchant ID | Reconciliation's Not Success - Invalid Merchant ID |
| 0002       | Invalid Term ID     | Reconciliation's Not Success - Invalid Term ID     |
| 3003       | Invalid Transaction | Reconciliation's Not Success - Invalid Transaction |
| 0006       | Invalid Customer ID | Reconciliation's Not Success - Invalid customer ID |

## Example Request&#x20;

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

```
curl --location -g --request POST '{{url}}:{{pg_port}}/pg/merchant/reconcilation' \
--data-raw '[
    {
        "termId": "OW04000007",
        "merchantId": "O0000021",
        "buyerId": "becbd0f6-39b7-4db81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "txId": "1652858955940000",
        "transactionType": "PURCHASE",
        "grandToTAmt": 2.3
    },{
        "termId": "OW04000007",
        "merchantId": "O0000021",
        "buyerId": "becbd0f6-39b7-4bd81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "txId": "1652886005159000",
        "transactionType": "PURCHASE",
        "grandToTAmt": 2.3
    }
]'
```

{% endtab %}

{% tab title="Http" %}

```http
POST /pg/merchant/reconcilation HTTP/1.1
Host: {{url}}:{{pg_port}}
Content-Length: 521

[
    {
        "termId": "OW04000007",
        "merchantId": "O0000021",
        "buyerId": "becbd0f6-39b7-4db81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "txId": "1652858955940000",
        "transactionType": "PURCHASE",
        "grandToTAmt": 2.3
    },{
        "termId": "OW04000007",
        "merchantId": "O0000021",
        "buyerId": "becbd0f6-39b7-4bd81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "txId": "1652886005159000",
        "transactionType": "PURCHASE",
        "grandToTAmt": 2.3
    }
]
```

{% endtab %}

{% tab title="JavaScript-jQuery" %}

```javascript
var settings = {
  "url": "{{url}}:{{pg_port}}/pg/merchant/reconcilation",
  "method": "POST",
  "timeout": 0,
  "data": "[\n    {\n        \"termId\": \"OW04000007\",\n        \"merchantId\": \"O0000021\",\n        \"buyerId\": \"becbd0f6-39b7-4db81-ba36-6c374ae8eaee\",\n        \"sellerId\": \"5f31c1ec-97ff-4940-b5ad-5d6b79eba748\",\n        \"txId\": \"1652858955940000\",\n        \"grandToTAmt\": 2.3\n    },{\n        \"termId\": \"OW04000007\",\n        \"merchantId\": \"O0000021\",\n        \"buyerId\": \"becbd0f6-39b7-4bd81-ba36-6c374ae8eaee\",\n        \"sellerId\": \"5f31c1ec-97ff-4940-b5ad-5d6b79eba748\",\n        \"txId\": \"1652886005159000\",\n        \"grandToTAmt\": 2.3\n    }\n]",
};

$.ajax(settings).done(function (response) {
  console.log(response);
});a
```

{% endtab %}

{% tab title="PHP-cURL" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{{url}}:{{pg_port}}/pg/merchant/reconcilation',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'[
    {
        "termId": "OW04000007",
        "merchantId": "O0000021",
        "buyerId": "becbd0f6-39b7-4db81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "transactionType": "PURCHASE",
        "txId": "1652858955940000",
        "grandToTAmt": 2.3
    },{
        "termId": "OW04000007",
        "merchantId": "O0000021",
        "buyerId": "becbd0f6-39b7-4bd81-ba36-6c374ae8eaee",
        "sellerId": "5f31c1ec-97ff-4940-b5ad-5d6b79eba748",
        "transactionType": "PURCHASE",
        "txId": "1652886005159000",
        "grandToTAmt": 2.3
    }
]',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}
