[УКР](https://hackmd.io/fvd8btZLQXywluia6w5uxg) | ENG

:arrow_left: [Guide](https://hackmd.io/QA2NYRliRLGviJl5P4-ZCw)
# [20003] Get Operation Status
## Usage
Request [20003] is used to get the current status of any operation at any moment.
## Request
*See the description of the "Partner", "KeyAES" and "Sign" attributes in the section "[General API Integration Information](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ)".*
### Data Structure
The Data structure for this operation is formed from the following parameters:
:::info
<details>
<summary>Data structure formation (examples are below)</summary>
<br>
~~~
{
"TransactionID": "",
"TerminalID": "",
"OperationID": ""
}
~~~
</details>
:::
|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
|`TransactionID`^1^|Yes/No|String|Unique transaction identifier in the Partner system, the status of which must be got.|`459132be0cbf58`|
|`TerminalID`^1^|Yes/No|String|Unique terminal identifier in the Partner system, that was used for transaction, the status of which must be got.|`1`|
|`OperationID`^1^|Yes/No|Integer|Unique operation identifier in the Operator system, the status of which must be got.|`111`|
:::warning
^1^ **Request [20003] can be sent in one of two ways:**
1. By parameter `OperationID` - in this case, the fields `TransactionID` and `TerminalID` are transmitted empty.
**Or**
2. By pair of fields `TransactionID` and `TerminalID` - in this case, the parameter `OperationID` is not transmitted.
:::
### Transaction Status for Two-Step Interaction
To get the current transaction status during [two-step interaction](https://hackmd.io/XcDW0oOKRLyIho-DOpOHjA) in the request [20003], the parameters `TransactionID` and `TerminalID` of the operation [[10005]](https://hackmd.io/qSkRHz6gRKmxNrWRwwrjqg) should be transmitted. At the same time, the operation status "pay" will be transmitted in the response, according to the table “[Operation Status](https://hackmd.io/16yLv895Qo-FWTvrWWQwbg#Operation-Status)”.
:::success
<details>
<summary>Example of the request [20003]</summary>
<br>
~~~md
{
"Partner": {
"PartnerToken": "72a8ddb8-9145-4a41-af1a-8c48ecaa4be1",
"OperationType": 20003
},
"Data": "{\"TransactionID\":\"321456\",\"TerminalID\":\"1\",\"Transaction\":{\"TransactionID\":\"321466\",\"TerminalID\":\"1\",\"DateTime\":\"2019-02-11 13:37:17\"}}",
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
## Response
*See the general information on the response structure formation in the section "[General API Integration Information](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ)"*.
### Data Structure
Successful response to the request [20003] contains the structure `OperationResponse` -> `Data`, that transmits the requested operation data and operation status:
|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
|`OperationID`|Yes|Integer|Unique operation identifier in the Operator system, the status of which is got.|`111`|
|`OperationStatus`|Yes|Integer|Operation status, according to the table “[Operation Status](https://hackmd.io/16yLv895Qo-FWTvrWWQwbg#Operation-Status)”.|`10`|
|`DateTime`|No|String|Transaction processing date and time in format: YYYYMMDD HH24:MM:SS.|`20220521 06:41:04`|
|`OperationType`|No|String|Operation type, the status of which is got. According to the table ["Operation Type"](https://hackmd.io/16yLv895Qo-FWTvrWWQwbg#Operation-Type).|`10102`|
|`ExtraData`^2^|No|Structure|Data structure transmits the additional operation information. Parameter is used only for the request [[10005]](https://hackmd.io/qSkRHz6gRKmxNrWRwwrjqg).|See example below.|
^2^ **"ExtraData"** Structure Parameters:
|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
| `OriginalSum` |No | Integer | Operation sum in kopecks, where 1UAH=>`100`.|`111`|
| `Refund` | No | Integer | Sum of successful refunds in kopecks. |`11`|
| `RestSum` |No| Integer | Final operation sum in kopecks: `RestSum`=`OriginalSum`–`Refund`.|`100` |
| `Bank` |No | String | Bank name issuing the card. |`BankName`|
| `CardType` | No |String | International payment system. |`Visa`|
| `PAN` |No|String|Masked card number.|`123456******1234`|
| `Currency` | No | String | Currency debit code is an abbreviated currency designation described in the standard [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217#Non_ISO_4217_currencies) (“UAH”, “GBP”, “USD”, etc.). |`UAH`|
| `TxnID` | No | Integer | Unique transaction identifier in the Operator system. | `321455` |
| `TicketURL` | No | String | URL to get the receipt file. |`https:\\server\ticket`|
| `RRN` | No | String | Retrieval reference number. |`1486751612`|
| `AuthCode` | No | String | Authorization code. |`123455`|
| `AccountPayments`^3^ |No | Array | Array of structures transmitted to get the status of completed payments for "Packet of services by details". See ["AccountPayments"](https://hackmd.io/qSkRHz6gRKmxNrWRwwrjqg?view#%E2%80%9CAccountPayments%E2%80%9D-Array) in [10005] request. | See example below.|
^3^ **"AccountPayments"** Structure Parameters:
|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
|`ID`|No|String|Unique payment identifier transmitted in the array ["AccountPayments"](https://hackmd.io/qSkRHz6gRKmxNrWRwwrjqg?view#%E2%80%9CAccountPayments%E2%80%9D-Array) of the request [10005]. |`af1377`|
|`Status`|No|Integer|Operation status, according to the table "[Operation Status](https://hackmd.io/16yLv895Qo-FWTvrWWQwbg#Operation-Status)".|`10`|
### Response Examples
:::success
<details>
<summary>Operation Successfully Completed</summary>
<br>
~~~md
{
"Code": 200,
"Message": "done",
"Data": {
"OperationID": 17,
"OperationStatus": 10,
"OperationResponse": "{\"Code\":200,\"Message\":\"done\",\"Data\":{\"OperationID: 11\",\"OperationStatus: 10\",\"DateTime\":\"20180510 13:23:19\",\"OperationType\":10102},\"KeyAES\":\"\",\"Sign\":\"\"}"
},
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
:::success
<details>
<summary>Operation Successfully Completed (data with the structure "ExtraData")</summary>
<br>
~~~md
{
"Code": 200,
"Message": "done",
"Data": {
"OperationID": 17,
"OperationStatus": 10,
"OperationResponse": "{\"Code\":200,\"Message\":\"done\",\"Data\":{\"OperationID: 11\",\"OperationStatus: 10\",\"DateTime\":\"20180510 13:23:19\",\"OperationType\":10102,\"ExtraData\":{\"OriginalSum\":111,\"Refund\":11,\"RestSum\":100,\"Bank\":\"BankName\",\"CardType\":\"visa\",\"Currency\":\"UAH\",\"PAN\":\"123456******1234\"}},\"KeyAES\":\"\",\"Sign\":\"\"}"
},
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
:::success
<details>
<summary>Operation Failed</summary>
<br>
~~~md
{
"Code": 200,
"Message": "done",
"Data": {
"OperationID": 17,
"OperationStatus": 10,
"OperationResponse": "{\"Code\":200,\"Data\":{\"OperationStatus\":21},\"Sign\":\"\",\"KeyAES\":\"\",\"Message\":\"refund operation 144377 fail: 3 - Parameters not matching\",\"OperationType\":30201},\"KeyAES\":\"\",\"Sign\":\"\"}"
},
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
:::success
<details>
<summary>Operation Rejected - Transaction Not Found</summary>
<br>
~~~md
{
"Code": 400,
"Message": "Transaction not found",
"Data": {
"OperationID": 0,
"OperationStatus": 21
},
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
## Related Requests
[[20001] Get Wallet Balance](https://hackmd.io/SVZQwSioRiGRiy0JwUQFWw)
[[20002] Get Wallet Statement](https://hackmd.io/ChiiYaRgQVeZcjvM5Wt7VA)
[[20004] Get Transaction Receipt](https://hackmd.io/k3KrwPbcRK-1G7qxG0ORlg)
[[20008] Get Exchange Rate](https://hackmd.io/k_ZnVoMwQ-i4WelDZ0wtZA)
[[20009] Get Limit for Operation [10101]](https://hackmd.io/rQ7epWnbQmG9kM0rFjUfhA)
[[20110] Get Card Data](https://hackmd.io/WruG7PGDRsuF0gL0Wl21bA)
## Reference Materials
General parameters of the XPAY system are given in the section ["Reference Materials"](https://hackmd.io/16yLv895Qo-FWTvrWWQwbg): operation types, payment types, response codes, operation status, reasons of operation rejection, etc.

:arrow_left: [Guide](https://hackmd.io/QA2NYRliRLGviJl5P4-ZCw)
:arrow_left: [General API Integration Information](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ)
<details>
<summary>XPAY Support</summary>
</br>
Phone: +38 093 891 92 00
Email: info@xpay.com.ua
Telegram: @xpaysupportbot
</details>