---
# System prepended metadata

title: '[104021] Card Payment by Token'

---

[УКР](https://hackmd.io/CCEZ0su4T3OBtY-_QBSzew) | ENG
![](https://i.imgur.com/ULmPUgP.jpg)
:arrow_left: [Guide](https://hackmd.io/QA2NYRliRLGviJl5P4-ZCw)

# [104021] Card Payment by Token

*What is "Token Payment" and how the cards are tokenized, see in the section ["Token Payment"](https://hackmd.io/hELnx1lqQwS9RiactYbLEA).*

*What is "Server-Server card payment" and how the sender is authenticated, see in the section "[Server-Server Card Payment](https://hackmd.io/83UDlVHPRf2CxEBCi6ECBg)".*


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

~~~
{
    "Phone": "",
    "Sum": ,
    "ClientToken": "",
    "site": "",
    "Order": "",
    "Action": "Prepare” / “Pay",
    "SuccessCallback": "",
    "FailedCallback": "",
    "Transaction":{
        "TransactionID": "",
        "TerminalID": "",
        "DateTime": ""
    },
    "BrowserData": {
        "device": {
            "channel": ""
        },
        "browserIP": "",
        "browserTZ": ,
        "browserLanguage": "",
        "browserUserAgent": "",
        "browserColorDepth": ,
        "browserJavaEnabled": ,
        "browserScreenWidth": ,
        "browserScreenHeight": ,
        "fraudhuntFingerprint": ""
    }
}
~~~
</details>
:::


|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
| `Phone` | Yes | String | Client phone number in format: "380xxxxxxxxxxxx". |`380679335544`|
| `Sum` | Yes | Integer| Operation sum in kopecks. |1UAH=>`100`|
|`ClientToken`|Yes|String|Client card token.|`d1d2a97aac30.. d12c291f4e669`| 
|`site`|No| String | Site name from which the payment is made. |`https://www.xpay.com.ua/`|
| `Order` | No | String | Order number. |`1234A`|
|`Action`|No|String|Request type: `Prepare` - commission calculation, or `Pay` - payment (default value). |`Prepare` or `Pay`|
| `SuccessCallback` | No | String | URL (server) is called for successful operation. See section ["Server-Server Card Payment"](https://hackmd.io/83UDlVHPRf2CxEBCi6ECBg). |`https://partner.host/ cb_success`|
| `FailedCallback` | No | String | URL (server) is called for failed operation. See section ["Server-Server Card Payment"](https://hackmd.io/83UDlVHPRf2CxEBCi6ECBg). |`https://partner.host/ cb_fail`|
|`BrowserData`|No|Structure|Structure transmits browser data for *3DSecure 2.0*. See section ["BrowserData structure"](https://hackmd.io/83UDlVHPRf2CxEBCi6ECBg#%E2%80%9CBrowserData%E2%80%9D-structure).|See example in section ["BrowserData structure"](https://hackmd.io/83UDlVHPRf2CxEBCi6ECBg#%E2%80%9CBrowserData%E2%80%9D-structure).|
|`Transaction`|Yes|Structure|Structure transmits transaction data. See section "[Transaction Structure](https://hackmd.io/ijxPm0xtTpycgTjuU_NHQQ?view#2-Data)".|See example below.| 

:::success
<details>
<summary>Example of "Data" structure</summary>
<br>

~~~md
{
  "Phone": "380932799111",
  "Sum": 10000,
  "ClientToken": "d1d2a97aac30eefd2d69598425d2bf3b2316a2f84b48e2a1d1b2c291f4e669",
  "Action": "Pay",
  "FailedCallback": "https://api.kf.ua/api/paybox/xpay/process_payment/?status=failed&order_id=PAY_xpay_50b21b8b583247f28bd3d4b0a2fb4bec",
  "SuccessCallback": "https://api.kf.ua/api/paybox/xpay/process_payment/?status=success&order_id=PAY_xpay_50b21b8b583247f28bd3d4b0a2fb4bec",
  "Transaction": {
    "TransactionID": "PAY_xpay_50b21b8b583247f28bd3d4b0a2fb4bec",
    "TerminalID": "1",
    "DateTime": "20220619 063111"
  }
~~~
</details>
:::


:::success
<details>
<summary>Example of request [104021]</summary>
<br>

~~~md
{
  "Partner": {
    "PartnerToken": "72a8ddb8-9145-4a41-af1a-8c48ecaa4be1",
    "OperationType": 104021
  },
  "Data": "{\"Phone\": \"380932799111\", \"Sum\": 10000, \"ClientToken\": \"d1d2a97aac30eefd2695984255d2bf3b236a2f84b4e8e2a1d1b2c291f4e669\", \"Action\": \"Pay\", \"FailedCallback\": \"https://api.kf.ua/api/paybox/xpay/process_payment/?status=failed&order_id=PAY_xpay_50b21b8b583247f28bd3d4b0a2fb4bec\", \"SuccessCallback\": \"https://api.kf.ua .ua/api/paybox/xpay/process_payment/?status=success&order_id=PAY_xpay_50b21b8b583247f28bd3d4b0a2fb4bec\", \"Transaction\": {\"TransactionID\": \"PAY_xpay_50b21b8b583247f28bd3d4b0a2fb4bec\", \"TerminalID\": \"1\" , \"DateTime\": \"20220619 063111\"}}",
  "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?view#Response-Structure)"*.


### Parameter "Action":"Prepare"

When the request value `"Action":"Prepare"` is sent, the commission calculation data is transmitted in the "Data" response structure:

|Parameter|Required|Type|Description|Example|
|:----:|:----:|:----:|----|:----:|
|`Sum`|Yes|Integer|Sum of the operation in kopecks. |`500`|
|`Fee`|Yes|Integer|Sum of commission in kopecks.|`50`|
|`TotalSum`|Yes|Integer|Total operation sum in kopecks, including commission.|`550`| 

:::success
<details>
<summary>Response example for request value "Action":"Prepare"</summary>
<br>

~~~md
{
   "Code": 102,
   "Message": "done",
   "Data": {
     "Sum": 500,
     "Fee": 50,
     "TotalSum": 550,
     "OperationStatus": 7
   },
   "KeyAES": "",
   "Sign": ""
}
~~~
</details>
:::


### Parameter "Action":"Pay"

:::info
For payment, you need to repeat the request [104021] with the same data, but specify the value `Pay` in the parameter `Action`. 
:::

#### Response Examples for Request Value "Action":"Pay"

:::success
<details>
<summary>Request successfully accepted and needs "3DS" verification</summary>
<br>

~~~md
{
  "Code": 102,
  "Message": "need3ds",
  "Data": {
    "OperationID": 111,
    "3dsHtml": "<html page in base64 encoding>",
    "OperationStatus": 2
  },
  "KeyAES": "",
  "Sign": ""
}
~~~
</details>
:::


:::success
<details>
<summary>Request successfully accepted and needs "OTP" verification</summary>
<br>

~~~md
{
  "Code": 102,
  "Message": "needOTP",
  "Data": {
    "OperationID": 111,
    "otpJson": "<JSON structure as string>",
    "OperationStatus": 3
  },
  "KeyAES": "",
  "Sign": ""
}
~~~
</details>
:::


:::success
<details>
<summary>Operation Successfully Completed</summary>
<br>

~~~md
{
  "Code": 200,
  "Message": "done",
  "Data": {
    "OperationID": 555,
    "OperationStatus": 10
  },
  "KeyAES": "",
  "Sign": ""
}
~~~
</details>
:::


:::success
<details>
<summary>Operation Failed</summary>
<br>

~~~md
{
  "Code": 200,
  "Message": "done",
  "Data": {
    "OperationID": 111,
    "OperationStatus": 21,
    "Reason": 3
  },
  "KeyAES": "",
  "Sign": ""
}
~~~
</details>
:::


## Related Requests

[[10101] Card-Card](https://hackmd.io/VYlXRMiWRkimK0sxlTZ2BA)
[[10102/101023/101025] Card-Wallet](https://hackmd.io/MUZzd3mTRQeQfBsE-emVVQ)
[[10103] Card-IBAN of Individual](https://hackmd.io/9c9kaHeMTH-LiGf_mVWwpg)
[[101031] Card-IBAN of Legal Entity](https://hackmd.io/XQDv9qmoRiqFzfzcD0H1uA)
[[10150/10051] Card-Phone-Card](https://hackmd.io/ES9hW5BlS6CozQAmULgnRw) 


**Token Payment**
[[1040217] Bulk Card Payment by Token](https://hackmd.io/6h9zyYaBTwOLzzP8XJDrfg)
[[104121] Auto Debit by Token. MO/TO Operations](https://hackmd.io/X4ImobdtSJ-Hy1qM-p7PWA)


**Get Card Data** 
[[20400/20410] Get Card Data by Phone Number](https://hackmd.io/Xd9OZWXARcSZRTCsu-1jrw)
[[20404] Get Card Data by Token](https://hackmd.io/PSdh1ldNSmmJMR4OIhM_-Q)


**Get Transaction Data**
[[20003] Get Operation Status](https://hackmd.io/_eAjmoG-QPWoWWmsLOGf1g)
    


## 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.


![](https://i.imgur.com/17gAyWb.png)
: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>
