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

:arrow_left: [Guide](https://hackmd.io/QA2NYRliRLGviJl5P4-ZCw)
# [90001/90002/90003/90004/90005] Operation Preparation
## Usage
Operation procedure **via terminal** is formed from two requests:
|OperationType |Usage |
|----|----|
|`90001/90002/90003/90004/90005`|Preparation of the operation.|
|`90000`|[Execution of the operation](https://hackmd.io/5aeqF-2PRQSkO85QIMXbqw).|
As a result of the operation preparation request, the possibility of funds transfer to the specified details is checked.
## Requests for Operation Preparation
*See the description of the "Partner", "KeyAES" and "Sign" attributes in the section "[General API Integration Information](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ)".*
Requests for preparation of any operation contains the same set of parameters, which differs only in the value of the field `Recipient`, depending on the type of operation. Operation type is transmitted in the field `OperationType`.
|"OperationType" |Type of operation|"Recipient"| Example |
|:----:|----|----|:----:|
|`90001`|Funds transfer to the card.| PAN card (bank card number).| `8888888888888888` |
|`90002`|Funds transfer to the wallet.|Wallet ID: phone or email. | `380679335544` |
|`90003`^1^|Funds transfer by details.|^1^ Structure that transmits the data of the details. | See example below.|
|`90004`^2^|Payment for utility services.| ^2^ Personal account number of the service payer.|`55-23`|
|`90005`|Phone top-up. | Phone number in format: "380xxxxxxxxxxxx". |`380679335544`|
### 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>
~~~
{
"Sum": ,
"Recipient": "",
"Email": "",
"Phone": "",
"Address": "",
"CashIn": [
{
"n": ,
"value":
}
],
"Transaction": {
"TransactionID": "",
"TerminalID": "",
"DateTime": ""
}
}
~~~
</details>
:::
|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
| `Sum` |No|Integer|Probable operation sum in kopecks. Parameter is used to check the possibility of transferring funds for the specified sum. |1UAH=>`100`|
|`Recipient`|Yes|String / Structure|Details for transferring funds. Value of the field is formed depending on the operation type (see above).|`380679335544`|
| `Email` | No | String | Client's email. |`index@gmail.com`|
| `Phone`| No | String | Client's phone number in format: "380xxxxxxxxxxxx". |`380679335544`|
| `Address` | No | String | Address of the self-service software and technical complex. |`Khreshchatyk, 1`|
|`CashIn` |No|Array|Array transmits the banknote report (for self-service software and technical complex), where: `n` - number of deposited banknote, `value` - denomination of banknote. |`[{"n":1, "value":100}, {"n":2, "value":200}]`|
|`Transaction`|Yes|Structure|Structure transmits the transaction data. See section "[Transaction Structure](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ?view#2-Data)".|See example below.|
^1^ **"Recipient"** structure parameters for the **request [90003]** (funds transfer by details):
|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
| `EDRPOU` | Yes | String | Recipient ["EDRPOU"](https://uk.wikipedia.org/wiki/%D0%9A%D0%BE%D0%B4_%D0%84%D0%94%D0%A0%D0%9F%D0%9E%D0%A3) code. |`34190717`|
| `Account` | Yes | String | Recipient IBAN (International Bank Account Number). | `UA1730529900000-26207893720887` |
| `MFO`| Yes | String | Recipient "[Bank Sort Code](https://en.wikipedia.org/wiki/Sort_code). | `305299` |
| `Purpose` | Yes | String | Payment purpose. | `Order Payment No.543345` |
| `SenderName` | Yes | String | Sender full name. | `Dzyuba A.I.` |
| `RecipientName` | Yes | String | Recipient full name. | `Shevchenko T.G.` |
:::success
<details>
<summary>Example of the request [90001]</summary>
<br>
~~~md
{
"Partner": {
"PartnerToken": "72a8ddb8-9145-4a41-af1a-8c48ecaa4be1",
"OperationType": 90001,
"Locale": "uk"
},
"Data": "{\"Recipient\": \"545708******2369\", \"Phone\": \"380987654321\", \"Email\": \"offer@gmail.com \", \"Sum\": 12000, \"Transaction\":{\"TransactionID\": \"321\", \"TerminalID\": \"1\", \"DateTime\": \" 20210205 12:50:33\"}}",
"KeyAES": "",
"Sign": "O5fnW4no66gLKhFsW8PAD2MX4kOuZn3R4g="
}
~~~
</details>
:::
^2^ **"Recipient"** structure parameters for the **request [90004]** (funds transfer by details):
|Parameter|Required|Type|Description|Example|
|:-:|:-:|:-:|-|:-:|
| `SenderName` | Yes |String | Payer name. |`Bykov Vasyl Serhiyovych`|
| `Account` | Yes |String | Payer personal account number. |`№859485`|
| `Address` | Yes |String | Address payment. | `Kyiv, Khreschatyk st., 1`|
| `Order` | Yes |String | Account number. |`№433`|
| `Contract` | Yes |String | Contract number. |`№МВ-848`|
| `MID` | Yes |String | Payee ID. |`117`|
| `Phone` | No | String | Client phone number in the format: "380xxxxxxxxxxxx" |`380679335544`|
## Response
*See the general information on the response structure formation in the section "[General API Integration Information](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ)"*.
:::warning
Operation identifier (the value `OperationID` received in the response to request) must be displayed in the client's check. The identifier will be used to analyze disputed situations.
:::
### Response Examples
:::success
<details>
<summary>Preparation Successfully Completed</summary>
<br>
~~~md
{
"Code": 102,
"Message": "Done",
"Data": {
"OperationDate": "2018-12-25T14:48:10.977847+02:00",
"OperationID": 167813,
"OperationStatus": 7
},
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
:::success
<details>
<summary>Operation Failed</summary>
<br>
~~~md
{
"Code": 400,
"Message": "Fail",
"Data": {
"OperationDate": "2018-12-25T14:48:10.977847+02:00",
"OperationID": 0,
"OperationStatus": 21
},
"KeyAES": "",
"Sign": ""
}
~~~
</details>
:::
## Related Requests
[[90000] Operation Execution](https://hackmd.io/5aeqF-2PRQSkO85QIMXbqw)
## 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>