# Get Transaction Status

| 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)       |

## Get Transaction Status

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

This endpoint allows to get transaction' status.

#### Request Body

| Name       | Type   | Description                       |
| ---------- | ------ | --------------------------------- |
| merchantId | string | Merchant's Identifier             |
| amount     | string | Transaction's amount              |
| currency   | string | Currency (Format as USD)          |
| txId       | string | Merchant's transaction Identifier |
| termId     | string | Merchant Terminal Identifier      |

{% tabs %}
{% tab title="200 Transaction successfully retrieved." %}

```
{
    "resultMsg": "Success",
    "resultCode": "0000",
    "resultData": {
        "txDt": "20210212",
        "txSeqNo": "20210212",
        "txStCd": "COMPLETE",
        "trt": "PURCHASE",
        "paymentMethod": "CREDIT_DEBIT",
        "merchantId": "C0000143",
        "termId": "CT03000003",
        "wdlAcNo": "************0022",
        "tracNo": "1613104202987",
        "amount": 2,
        "currencyCode": "USD",
        "apprNo": "763647",
        "apprDttm": "20210212113016"
    }
}
```

{% endtab %}

{% tab title="302 Transaction No Found /  Not successful " %}

```
{
    "resultMsg": "System error",
    "resultCode": "9999",
    "resultData": null
}
```

{% endtab %}

{% tab title="401 Invalid token" %}

```
1
```

{% endtab %}
{% endtabs %}

### Example Request

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

```bash
curl --location --request POST 'http://pgtest.payon.com.kh/pg/transaction/status' \
--data-raw '{
    "termId":"CT03000003",
    "txId":"1613104202987",
    "merchantId":"C0000143",
    "currency":"USD",
    "amount":"1"
}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST /pg/transaction/status HTTP/1.1
Host: pgtest.payon.com.kh
Content-Length: 126

{
    "termId":"CT03000003",
    "txId":"1613104202987",
    "merchantId":"C0000143",
    "currency":"USD",
    "amount":"1"
}
```

{% endtab %}

{% tab title="PHP-Http\_Request2" %}

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('http://pgtest.payon.com.kh/pg/transaction/status');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody('{\n    "termId":"CT03000003",\n    "txId":"1613104202987",\n    "merchantId":"C0000143",\n    "currency":"USD",\n    "amount":"1"\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

{% endtab %}

{% tab title="PHP cURL" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://pgtest.payon.com.kh/pg/transaction/status',
  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":"CT03000003",
    "txId":"1613104202987",
    "merchantId":"C0000143",
    "currency":"USD",
    "amount":"1"
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

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

```javascript
var settings = {
  "url": "http://pgtest.payon.com.kh/pg/transaction/status",
  "method": "POST",
  "timeout": 0,
  "data": "{\n    \"termId\":\"CT03000003\",\n    \"txId\":\"1613104202987\",\n    \"merchantId\":\"C0000143\",\n    \"currency\":\"USD\",\n    \"amount\":\"1\"\n}",
};

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

{% endtab %}

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

```javascript
var data = "{\n    \"termId\":\"CT03000003\",\n    \"txId\":\"1613104202987\",\n    \"merchantId\":\"C0000143\",\n    \"currency\":\"USD\",\n    \"amount\":\"1\"\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://pgtest.payon.com.kh/pg/transaction/status");

xhr.send(data);
```

{% endtab %}
{% endtabs %}


---

# 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.payon.com.kh/payon-api-reference/get-transaction-status.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.
