# Payment Request API

## :white\_check\_mark: API Request Parameter&#x73;**(HTTP-Request-Body )**

|       Params Name      |         Description        | Required |          Notes         |
| :--------------------: | :------------------------: | :------: | :--------------------: |
|         action         |         Action name        |     Y    |           <p>          |
| <br>"PREPAY\_INIT"</p> |                            |          |                        |
|         version        |       Version number       |     Y    |          "2.0"         |
|      merchant\_id      |         Merchant ID        |     Y    |   Provided by OTT Pay  |
|          data          | Encrypted Transaction Data |     Y    | See "Data" table below |
|           md5          |       Message Digest       |     Y    |                        |

:ballot\_box\_with\_check: **Request Example(JSON Data):**

```php
{
  "data": "wcpIWJbpAsQmDO5+qdXyjiSqHLo/YXsPpgLDZvNKUCj55IVE81CZUgLRX7t0 JKn5QRh74Plh3x/AyBTsvnhlTr16or1/aTZEeZfhgQaqtiNY4zDU16PCBvZ+ zggxNlLW7h28uXdpFVF9BTqwv1CrWNfNwjov1ZRGBzTXW19grayi9PKzM5so H1RjZR2o/IsYtnYQQ8L+XR+Wlx1kbupDuy8Pvgk63MIhba3ujlkwHL37WRkA RJWQTITqaNHAu3bQn+YH6Nl3i9RFwPoNlGG15vDSOo0yWxSzkayG6o6LxU7Z Af4fUamERkQOK26PQURqSpI7qn9vOAXv2ahgsdD0dvA4MHFK3RyXyO+vGUqB LnuI/oOPAcACzP2gP0BB+HI+yFBGczAsRO0t2OTxrXVPl27tFTBXm4uYfsSx 6UQ1hOqgLy75repl8CML8OKrCODloBRIpEiMDxk8+xjPFvMqv364e3gQXM1Q 0wEgKa7nQofTW1uV6NJjykNjtluawNEbFgDRSza/NChSs5tDklcuBQ==",
  "action": "PREPAY_INIT",
  "merchant_id": "ON00004652",
  "version": "2.0",
  "md5": "0ECB498672C0EAF9805522AFEE5A91BA"
}
```

#### :ballot\_box\_with\_check: Dat&#x61;**(JSON Data, to be encrypted):**

|    Params Name    |     Description    | Required |                                                                                        Notes                                                                                        |
| :---------------: | :----------------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|    merchant\_id   |     Merchant ID    |     Y    |                                                                                                                                                                                     |
|      shop\_id     |       Shop ID      |     Y    |                                                                                                                                                                                     |
|    operator\_id   |     Operator ID    |     Y    |                                                                                                                                                                                     |
| prepay\_order\_id |   Prepay Order ID  |     Y    |                                                                                                                                                                                     |
|     sale\_num     |     Sale number    |     Y    |                                                                                                                                                                                     |
|   currency\_type  |      Currency      |     Y    |                                                                 “CAD”/”USD”/”CNY” match with settings of merchant ID                                                                |
|     biz\_type     |    Business type   |     Y    |                                                                                       “PREPAY”                                                                                      |
|   redirect\_url   |    Redirect URL    |     Y    |                                                                                                                                                                                     |
|  call\_back\_url  |     Notify URL     |     Y    |                                                                                                                                                                                     |
|      duration     |  Payment duration  |     Y    | Duration of payment, unit in seconds. Please note, expire time will be calculated by the duration and the time the prepay order is created. The expire time will return in response |
|       email       |    Client email    |     N    |                                                                                                                                                                                     |
|      remarks      | Transaction remark |     N    |                                                                                                                                                                                     |

:ballot\_box\_with\_check: **Data Example(JSON Data):**

```
{
  "amount": "5",
  "sale_num": "20220727132626764",
  "operator_id": "0000000696",
  "prepay_order_id": "prepay20220727132626764",
  "biz_type": "PREPAY",
  "merchant_id": "ON00004652",
  "duration": "100",
  "shop_id": "ON00004652001",
  "currency_type": "CAD",
  "email": "inforsa@ott.ca",
  "remarks": "BLA",
  "redirect_url": "http://uatqrpay.ottpay.com/redirectBus",
  "call_back_url": "http://uatqrpay.ottpay.com/back_response"
}
```

## :white\_check\_mark: API Response Parameter&#x73;**(HTTP-Response-Body)**

| Params Name |    Description   | Required |          Notes         |
| :---------: | :--------------: | :------: | :--------------------: |
|  rsp\_code  |   Response code  |     Y    |   refer to Appendix B  |
|   rsp\_msg  | Response message |     Y    |                        |
|     data    |  Encrypted Data  |     Y    | See "Data" table below |
|     md5     |  Message Digest  |     Y    |                        |

:ballot\_box\_with\_check: **Response Example(JSON Data):**

```
{
  "rsp_code": "Success",
  "rsp_msg": "prepay order created",
  "data": "ks1ROTEQ7mkc5L+RPzyv8MVK1ID+s5tXvEh6DHcYD4oryyTd7mDkzNu/cRiR gP/vJoD9eBpa/S6BSTXlUYTEkxV+PULg8e/LRabkkRnm0WIgt9o/N/Gma00N MJGbEI6K7O9wc3c6eqej6zFx2xzFcNX9vCgsoK69lhchrrqCD7vx7GHa7dd6 BGln8QzTBYCxv3JpliV4FFUJJ/hr91aoEj7BilclDwUck+CgKOV9AfU=",
  "md5": "0217F21DB5833A501410501464B05283"
}
```

#### :ballot\_box\_with\_check: Transaction Data(JSON format, After decrypted)

|     Params Name    |  Description | Required |                 Notes                 |
| :----------------: | :----------: | :------: | :-----------------------------------: |
| preypay\_order\_id |   Order ID   |     Y    |                                       |
|       payinfo      | Payment link |     Y    | the redirect link to OTT Pay platform |
|    expire\_time    |  Expire time |     Y    |         Expire time of payment        |

:ballot\_box\_with\_check: **Data Example(JSON Data, after decrypted):**

```
{
  "payInfo": "https://uatqrpay.ottpay.com/payment-platform?prepayid=prepay20220727132626764",
  "prepay_order_id": "prepay20220727132626764",
  "expire_time": "2022-07-27 13:28:11"
}
```

Note:

The **`payinfo`** in the response contains the payment link to OTT Pay’s Checkout Platform. Example:

```
https://qrpay.ottpay.com/payment-platform?prepayid=prepay20220727132626764
```

Additionally, Merchant can add the ***selected*** parameter according to their own settings. Example:

```
https://qrpay.ottpay.com/payment-platform?prepayid=prepay20220727132626764&selected=NONE
```

merchant use **`payinfo`** to redirect the browser to OTT Pay’s Checkout Platform where the client can finish the payment.&#x20;

{% hint style="info" %}
***selected*** can be chosen from the following parameters: NONE, WECHATPAY, ALIPAY, UNIONPAY, GP

This parameter is used to select the payment method that can be activated directly.

For example, if selected=WECHATPAY, the payment method will be activated directly from WeChat wallet. selected=NONE, there is no priority payment method, the user selects the payment method from the payment list.
{% endhint %}

## :white\_check\_mark: Payment Return URL Link

After payment process finished,  the result will be sent back by redirecting to the following payment result Web Page URL link.

### :ballot\_box\_with\_check:Return URL Link Format

```
http://returnURL/xxx?total_fee=XXXX&trade_no=XXXX&out_trade_no=XXXX&trade_status=XXXX
```

### :ballot\_box\_with\_check: Return URL Parameters (need be decoded with Base64)

#### :asterisk\_symbol: Prefixed URL

**Prefixed URL** is a customized page for order processing, /xxx is an additional page for the merchant according to their own business. e.g.

```
https://ezshops.ott.ca/mobile/callback.php
```

#### :asterisk\_symbol:  total\_fee

**total\_fee** is the request amount of the order from the merchant. Number, 100 for 1.00 dollar.

#### :asterisk\_symbol: trade\_no

**trade\_no** is the internal order number.

#### :asterisk\_symbol: out\_trade\_no

**out\_trade\_no** is the order number.

#### :asterisk\_symbol: trade\_status

**trade\_status** shows the result of the payment. Payment succeed returns " **Trade\_Finished**".

#### :ballot\_box\_with\_check: Return URL Link Example (URL encoded)

```
https://ezshops.ott.ca/mobile/callback.php?currency=CAD&out_trade_no=AL2192407938683822&total_fee=0.01&trade_no=2020061022001367651432273894&trade_status=TRADE_FINISHED&sign=aTTXuUU8DD4J11vwsu%2Bx%2FonuesJ%2Ba73bIXrDTgbOze1Df35H6x8cSt9Rk9b9hqQksF8QobWU7Zt0%2F0LbPYFSR9kI%2B5rVYQKSP%2Fgad97A89ySV7wi05jLmiRLVHySG131zTwren9XoS81Do13hFUkoTZfEQc745bTxvgDKIMrSRs%3D&sign_type=RSA
```

```
resposdwx:Array
(
    [currency] => CAD
    [out_trade_no] => AL2192407938683822
    [total_fee] => 0.01
    [trade_no] => 2020061022001367651432273894
    [trade_status] => TRADE_FINISHED
    [sign] => aTTXuUU8DD4J11vwsu+x/onuesJ+a73bIXrDTgbOze1Df35H6x8cSt9Rk9b9hqQksF8QobWU7Zt0/0LbPYFSR9kI+5rVYQKSP/gad97A89ySV7wi05jLmiRLVHySG131zTwren9XoS81Do13hFUkoTZfEQc745bTxvgDKIMrSRs=
    [sign_type] => RSA
)
```

## :white\_check\_mark: API Call Back (**HTTP-POST**)

{% hint style="info" %}
After the user completes the payment,, OTTPAY will send back process status to specified URL which been set up as field of **call\_back\_url** within above API request parameters.
{% endhint %}

### :ballot\_box\_with\_check: Message Payload Parameters Level **(HTTP-Response-Body)**

|  Params Name |         Description        | Required |          Notes         |
| :----------: | :------------------------: | :------: | :--------------------: |
|   rsp\_code  |        Response code       |     Y    |   refer to Appendix B  |
|   rsp\_msg   |      Response message      |     Y    |                        |
| merchant\_id |         Merchant ID        |     Y    |                        |
|     data     | Encrypted Transaction Data |     Y    | See "Data" table below |
|      md5     |       Message Digest       |     Y    |                        |

:ballot\_box\_with\_check: **Call-Back Message Example(JSON Data):**

```
{
  "data":"hy0yiXxPH4TDXeY5ET7gqIsUcgY5ykO1vQYOahS5SsbN7/5Ha7+hvcXhgY1hz9kHuf5OxqNfv28kVeiYACrLzngk+hA2o8dVAcifT6h3AquN5micrIi3L9owj6cHT1nJRExC74sNUqF8CDY5fb4jLh9it9tq7r8xFOpcpf19VNWceo/Jt1nHca6HPMvMUEDeX1aUjnxOs7R7B2TUQbAENg\u003d\u003d",
  "rsp_code":"SUCCESS",
  "rsp_msg":"success",
  "merchant_id":"QC00005496",
  "md5":"F70CA0472D1AAA596E720C19A1DD36A0"
 }
```

#### :ballot\_box\_with\_check: Transaction Data (JSON format, after decrypted)

|    Params Name    |       Description      | Required |             Notes             |
| :---------------: | :--------------------: | :------: | :---------------------------: |
|    finish\_time   |      Payment time      |     Y    | yyyyMMddHHmmss (Beijing time) |
|     order\_id     |        Order ID        |     Y    |                               |
|       amount      |   Transaction amount   |     Y    |                               |
|        tip        |           tip          |     N    |                               |
| bizpay\_order\_id | order id from Acquirer |     Y    |                               |
|      remarks      |         remarks        |     N    |                               |
|     sale\_num     |  merchant sale number  |     N    |                               |
|  convenience\_fee |     Convenience fee    |     N    |                               |
