# Payment Request API

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

|  Params Name |          Description         | Required |          Notes         |
| :----------: | :--------------------------: | :------: | :--------------------: |
|    action    | Action name (Constant Value) |     Y    |        "MAPPPAY"       |
|    version   |        Version number        |     Y    |          "1.1"         |
| 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
{
    "action":"MAPPPAY",
    "version":"1.0",
    "merchant_id":"QC00005496",
    "data": "RqlbPF0gZ0VnGnpQPnO/v1FSeVY81iMrJd0ejTx+g8Bj8y3XImosyzBF75PW LxyHffCAidLCVxW7lfr60lHVK9FtsEP+V0F1Wp6xDW0ZnJyCpC6inmC9i4NV iEqo50yGS4vtaf+mHz6ZtoWtn9ihYNAOEr1grr/F684cJ+f0D4ZaAkdkI5HV H4BTUPG78lAiJqv1hNmYZIIDucxxyghKFAEdgrfkM13f6Jig9CIHhXW8Xkfl nVSEoVz6v63jX2NS1Ls0bAZTeJC9YFS/hkTjbloaR7hvKU+zx5SZrhGNpjTX OjpKopp57IzWMd4LF4TgXsV8Eqib/ygz6n6wJ5zR6HtcWexC0DnxVoE0DMAz FW3cIIsCDLVkw++eZAZohk6e+Zpbke82apdigJm8xtLam5Esn2N3khpBFpfu oQ3LTPqKnj9mxjUtm/slblJ+ve3hOQ6ZA01QJHBEOxx4UJgm+pTxdyIQuRAH 7Df8XIfP0NE=",
    "md5":"6AFB2E94A70D9A208F101723700EB287"
}
```

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

|   Params Name   |        Description        | Required |                                                 Notes                                                 |
| :-------------: | :-----------------------: | :------: | :---------------------------------------------------------------------------------------------------: |
|    order\_id    |          Order ID         |     N    |             OrderID could be generated by client's code, or generated by OTTPay as default            |
|   operator\_id  |        Operator ID        |     Y    |                                     Operator ID provided by OTTPay                                    |
|      amount     |     Transaction Amount    |     Y    |                                      String, 100 for 1.00 dollar                                      |
|       Tip       |            Tip            |     N    |                                      String, 100 for 1.00 dollar                                      |
|    biz\_type    |       Message Digest      |     Y    |                                            "**WECHATPAY**"                                            |
|     app\_id     | mini-prog ID with WebChat |     Y    | refer to [WebChat Developer API Website](https://developers.weixin.qq.com/miniprogram/dev/framework/) |
|     open\_id    |    User id with WebChat   |     Y    | refer to [WebChat Developer API Website](https://developers.weixin.qq.com/miniprogram/dev/framework/) |
| call\_back\_url |       Call Back URL       |     Y    |                         OTT Pay send back with payment result to call back URL                        |

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

```
{
  "amount":"1",
  "biz_type":"WECHATPAY",
  "operator_id":"0000020156",
  "order_id":"2020041468976O124O000857",
  "appId": "wx5f89682208cf8e88",
  "call_back_url":"https://ezshops.ott.ca/AliQrOTTPAY_callback.php"
}
 
```

## :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**  | Transaction Data Encrypted |     Y    | See "Data" table below |
|     md5     |       Message Digest       |     Y    |                        |

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

```
{
"rsp_code":"SUCCESS",
"rsp_msg":"success",
"data":"41kiLvjVBO8AW4wTOthI92OQu+8fwac5cIDx0DoZpitLvSJU8WKQbk5Bii5ZYrgLz4hepQ865QZFWqj2PRZ1FjxxipxEy2KoOKchWK09e42Se3CMAxt/+8UGrnAHDJLbU/BBlZLJoLpruSNKBeVfwhI7TtGdP4ciwzKPmv5aS2DWoU4Jl26IAPa8PeGhPNLuT99HwBGXa7aUz5adYk3uAR5Ww9HkBlPrqzJlUQ4zdMgjxaM2bROldcKTK8NxPM7X",
"md5":"3D3B2F0000EFBF3427A5A67E656E838B"
}
```

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

|  Params Name |         Description         | Required |                                Notes                               |
| :----------: | :-------------------------: | :------: | :----------------------------------------------------------------: |
|  **payInfo** | data to activate WeChat-Pay |     Y    |                        refer to **payInfo**                        |
| merchant\_id |    order id from Acquirer   |     Y    | Returned by the Payment Service Provider (e.g. WeChat Pay, Alipay) |
|   order\_id  |           Order ID          |     Y    |                                                                    |
|    amount    |            amount           |     Y    |                     String, 100 for 1.00 dollar                    |
|   sale\_num  |          sale\_num          |     Y    |                                                                    |

#### :ballot\_box\_with\_check: payInfo parameters

| Params Name |        Description       | Required | Notes |
| :---------: | :----------------------: | :------: | :---: |
|    appId    | appId in WeChat-MiniProg |     Y    |       |
|  timeStamp  |         timeStamp        |     Y    |       |
|   nonceStr  |         nonceStr         |     Y    |       |
|  packageStr |        packageStr        |     Y    |       |
|   signType  |         signType         |     Y    | "MD5" |
|   paySign   |          paySign         |     Y    |       |

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

```
{"payInfo":"
   {"appId": "wx5f89682208cf8e88",
    "timeStamp":"2018091015",
    "nonceStr":"fGzn4apm4g33UnYU",
    "packageStr":"prepay_id\\u003dwx11030407018895349c421ab82302468473",
    "signType":"MD5",
    "paySign":"0961D43010DF42EA6021D76915F36F7A"
   }",
   "merchant_id":"ON00009999",
   "order_id":"TEST0000008",
   "amount":1,
   "sale_num":"1536606245849717"
}
 

```

#### :ballot\_box\_with\_check: Code example to activate WeChat Pay Wallet

By using of above **payInfo** parameters: appid, timestamp, nonceStr, packageStr, signType, paySign,  make payment request within Mini-Program as below,&#x20;

```
wx.request({
            url: 'https://mapp.ottpay.com/weixin/MappPay', //payment service URL
            data: {
              code: res.code //要去换取openid的登录凭证
            },
            success: function (res) {
              console.log("res=====>" + res.data);
              console.log("appId=====>" + res.data.appId);
              console.log("timeStamp=====>" + res.data.timeStamp);
              console.log("nonceStr=====>" + res.data.nonceStr);
              console.log("packageStr=====>" + res.data.packageStr);
              console.log("signType=====>" + res.data.signType);
              console.log("paySign=====>" + res.data.paySign);
              wx.requestPayment({
                appId: res.data.appId,
                timeStamp: res.data.timeStamp,
                nonceStr: res.data.nonceStr,
                package: res.data.packageStr,
                signType: 'MD5',
                paySign: res.data.paySign,
                success: function (res) {
                  // success
                  console.log(res);
                },
                fail: function (res) {
                  // fail
                  console.log(res);
                },
                complete: function (res) {
                  // complete
                  console.log(res);
                }
              })
            }

```

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

{% hint style="info" %}
Once API server finished the request process, it 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    |                                                                    |
| bizpay\_order\_id | order id from Acquirer |     Y    | Returned by the Payment Service Provider (e.g. WeChat Pay, Alipay) |
|    merchant\_id   |       Merchant ID      |     Y    |                         Provided by OTT Pay                        |

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

```
{
 "amount":"1",
 "bizpay_order_id":"AL781266859681754",
 "tip":"0",
 "merchant_id":"QC00005496",
 "order_id":"2020041553699O153O0407",
 "finish_time":"20200416050429"
}
```


---

# 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.ottpay.com/payment-api/api-for-wechat-mini-program/payment-request-api-1.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.
