# Payments

## Step 1

## Create a payment order

<mark style="color:green;">`POST`</mark> `https://service.xxx.com/platformapi/chainup/open/opay/createThirdOrder`

It is necessary to package the data in the parameter table into JSON strings and use rsa for parameter encryption and signature as data and sign in the body

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Content-Type	<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                      | Type   | Description     |
| ----------------------------------------- | ------ | --------------- |
| app\_id<mark style="color:red;">\*</mark> | String | Merchant AppKey |
| sign<mark style="color:red;">\*</mark>    | String |                 |
| data<mark style="color:red;">\*</mark>    | String |                 |
| time<mark style="color:red;">\*</mark>    | String |                 |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": "", //Return code	
    "msg": "", //Success or failure message	
    "data": "",
    "sign": ""
}

data:
{
    "orderNum":"xxxx"  //Order Number		
}
```

{% endtab %}
{% endtabs %}

The following are the parameters involved in rsa encryption:

<table><thead><tr><th>name</th><th>type</th><th>required</th><th width="250">example</th><th>Description</th></tr></thead><tbody><tr><td>appOrderId</td><td>String</td><td>YES</td><td>11321</td><td>Merchant Order ID</td></tr><tr><td>openId</td><td>String</td><td>YES</td><td>2ae04ed9165624419bad68e9e0f3f29fbd</td><td>Paying user's unique ID: payerUserId</td></tr><tr><td>userId</td><td>String</td><td>YES</td><td>22033390</td><td>Paying user's UID (either UID or OpenID must exist, OpenID takes priority if both exist): payerUid</td></tr><tr><td>orderAmount</td><td>String</td><td>YES</td><td>10</td><td>amount</td></tr><tr><td>orderSceneType</td><td>String</td><td>NO</td><td>1000011</td><td>Scene type of the order, numerical enumeration</td></tr><tr><td>payCoinSymbol</td><td>String</td><td>YES</td><td>BTC</td><td>Payment currency, capitalized as BTCappKey</td></tr><tr><td>returnPage</td><td>String</td><td>YES</td><td>https://www.google.com</td><td>Front-end jump to merchant's page</td></tr><tr><td>notifyPage</td><td>String</td><td>YES</td><td>https://www.google.com</td><td>Address for back-office notification to merchants</td></tr><tr><td>token</td><td>String</td><td>NO</td><td>2ae04ed9165624419bad68e9e0f3f29fbd</td><td>Authorized token</td></tr><tr><td>goods</td><td>String</td><td>NO</td><td>Product description information, can not be passed, passed must be legal json format, otherwise the order creation failure; json in the subfield for name : product name desc: product description Example: [{"name": "Product 1", "desc": "Product information 123balabala"},{"name": "Product 2", "desc":" Product information 23balabala"},{"name": "Product 3", "desc": "Product information 33balabala"}]</td><td></td></tr></tbody></table>

## Step 2

## Payment Page

<mark style="color:blue;">`GET`</mark> `https://service.xxx.com/platform/pay.html`

After the final payment page is assembled as:\
[**https://service.xxx.com/**](https://platform.xxx.com/pay.html?appKey=xxx\&openId=xxx\&token=xxx\&orderNum=xxx)[**platform**](http://platform.apple.com/?appKey=apple_6746\&redirectUrl=https://www.chainup.com)**/**[**pay.html?appKey=xxx\&openId=xxx\&token=xxx\&orderNum=xxx**](https://platform.xxx.com/pay.html?appKey=xxx\&openId=xxx\&token=xxx\&orderNum=xxx)

#### Query Parameters

| Name     | Type   | Description                                             |
| -------- | ------ | ------------------------------------------------------- |
| appKey   | String | Merchant AppKey                                         |
| orderNum | String | Platform number payer openId, must be the order creator |
| openId   | String | payer openId, must be the order creator                 |
| userId   | String | Payment user uid (one must exist with openid)           |
| token    | String | Authorized token                                        |

parameters:

Either UID or OpenID is required.

<table><thead><tr><th>name</th><th>type</th><th>required</th><th width="250">example</th><th>Description</th></tr></thead><tbody><tr><td>orderNum</td><td>String</td><td>YES</td><td>1000000009</td><td>Platform number payer openId, must be the order creator</td></tr><tr><td>openId</td><td>String</td><td>NO</td><td>2ae04ed9165624419bad68e9e0f3f29fbd</td><td>payer openId, must be the order creator</td></tr><tr><td>userId</td><td>String</td><td>NO</td><td>2023203</td><td>Payment user uid (one must exist with openid)</td></tr><tr><td>token</td><td>String</td><td>NO</td><td>2ae04ed9165624419bad68e9e0f3f29fbd</td><td>Authorized token</td></tr></tbody></table>

## Step 3

## Payment result callback interface

<mark style="color:green;">`POST`</mark> `https://service.xxx.com/notifyPage`

The interface URL is provided by the docking merchant, and the parameter passed in the first step of creating the order: notifyPage After the payment is completed, the payment result will be notified through the URL corresponding to the notifyPage

It is necessary to package the data in the parameter table into JSON strings and use rsa for parameter encryption and signature as data and sign in the body

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                      | Type   | Description     |
| ----------------------------------------- | ------ | --------------- |
| app\_id<mark style="color:red;">\*</mark> | String | Merchant AppKey |
| sign<mark style="color:red;">\*</mark>    | String | Signature       |
| data<mark style="color:red;">\*</mark>    | String |                 |
| time<mark style="color:red;">\*</mark>    | String |                 |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": "", //Return code	
    "msg": "", //Success or failure message	
    "data": "",//The client receives the request and returns success, which means the request has been received		
    "sign":""      
}
```

{% endtab %}
{% endtabs %}

The following are the parameters involved in rsa encryption:

<table><thead><tr><th>name</th><th width="124">type</th><th>required</th><th width="250">example</th><th>Description</th></tr></thead><tbody><tr><td>outOrderId</td><td>String</td><td>YES</td><td>1000000009</td><td>Merchant side order number</td></tr><tr><td>orderNum</td><td>String</td><td>YES</td><td>10000000002</td><td>Open Platform Order Number</td></tr><tr><td>orderStatus</td><td>String</td><td>YES</td><td>1</td><td>Order status (1 Pending payment; 2 Payment failed; 3 Payment successful; 0 Closed)</td></tr><tr><td>payAmount</td><td>String</td><td>YES</td><td>200</td><td>Order amount</td></tr><tr><td>returnUrl</td><td>String</td><td>YES</td><td>https://www.google.com</td><td>Synchronized notification page (order placement interface incoming)</td></tr></tbody></table>

## Query Payment Order

## Query Payment Order

<mark style="color:green;">`POST`</mark> `https://service.xxx.com/platformapi/chainup/open/opay/orderDetail`

It is necessary to package the data in the parameter table into JSON strings and use rsa for parameter encryption and signature as data and sign in the body

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Content-Type	<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                       | Type   | Description                |
| ------------------------------------------ | ------ | -------------------------- |
| appKey<mark style="color:red;">\*</mark>   | String | Merchant AppKey            |
| orderNum<mark style="color:red;">\*</mark> | String | Platform side order number |
| token                                      | String | Authorized token           |

{% tabs %}
{% tab title="200: OK " %}

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>        "totalAccount": [ // List of all accounts supported by the merchant
            {
                "accountName": "name", // Account name (displayed in the dropdown menu)
                "accountType": 202001, // Account type (equivalent to the ID to be passed back to the backend)
                "accountBalance": 1000.21 // Balance of the account for the payment user
            },
            {
                "accountName": "name",
                "accountType": 203001,
                "accountBalance": 1000.21
            }
        ],
        "googleStatus": 1, // Whether Google verification is enabled; 0 - Disabled, 1 - Enabled
        "appOrderId": "100000009", // Merchant order ID
        "sign": "2ae04ed9165624419bad68e9e0f3f29fbdqws2ae04ed9165624419bad68e9e0f3f29fbd", // Signature
        "orderNum": "12321", // Order number
        "orderStatus": "1", // Order status (1 - Pending payment; 2 - Payment failed; 3 - Payment successful; 0 - Closed)
        "userId": 230000, // User ID
        "isOpenMobileCheck": "1", // Whether mobile SMS verification is enabled; 0 - Disabled, 1 - Enabled
        "orderAmount": "20001.21", // Order amount
        "payCoinSymbol": "btc", // Payment currency
        "ctime": "20000000",
        "appKey": "xxx_xxx",
        "showPrecision": "8" // Display precision
}
</code></pre>

{% endtab %}
{% endtabs %}

parameters :

<table><thead><tr><th>name</th><th width="124">type</th><th>required</th><th width="250">example</th><th>Description</th></tr></thead><tbody><tr><td>appKey</td><td>String</td><td>YES</td><td>xxx_xxx</td><td>Merchant AppKey</td></tr><tr><td>orderNum</td><td>String</td><td>YES</td><td>10000000002</td><td>Platform side order number</td></tr><tr><td>token</td><td>String</td><td>NO</td><td>2ae04ed9165624419bad68e9e0f3f29fbd</td><td>Authorized token</td></tr></tbody></table>

## Merchant Daily Posting Statement

## Merchant Daily Posting Statement

<mark style="color:green;">`POST`</mark> `https://service.xxx.com/platformapi/chainup/open/opay/merchantBillingDay`

It is necessary to package the data in the parameter table into JSON strings and use rsa for parameter encryption and signature as data and sign in the body

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Content-Type	<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                      | Type   | Description     |
| ----------------------------------------- | ------ | --------------- |
| app\_id<mark style="color:red;">\*</mark> | String | Merchant AppKey |
| sign<mark style="color:red;">\*</mark>    | String | Signature       |
| data<mark style="color:red;">\*</mark>    | String |                 |
| time<mark style="color:red;">\*</mark>    | String |                 |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "code": "",
  "msg": "",
  "data": "",
  "sign: ""
}

data
{
        "count": 1000, // Total number of records for the day
        "list": [
            {
                "merchantUserId": 23000, // Merchant's receiving user ID
                "appOrderId": "100000019", // Merchant's order ID
                "payCoinSymbol": "btc", // Payment currency used
                "orderAmount": 10, // Order amount
                "orderType": 1, // Order type (1 - Payment order; 11 - Transfer (refund) order)
                "userId": 230000, // Payer's user ID
                "openId": "2ae04ed9165624419bad68e9e0f3f29fbd", // Payer's OpenID
                "createTime": "11200321123", // Order creation time in milliseconds
                "payTime": "320012321" // Actual payment completion time in milliseconds
            },
            {
                "merchantUserId": 23000, // Merchant's receiving user ID
                "appOrderId": "100000019", // Merchant's order ID
                "payCoinSymbol": "btc", // Payment currency used
                "orderAmount": 10, // Order amount
                "orderType": 1, // Order type (1 - Payment order; 11 - Transfer (refund) order)
                "userId": 230000, // Payer's user ID
                "openId": "2ae04ed9165624419bad68e9e0f3f29fbd", // Payer's OpenID
                "createTime": "11200321123", // Order creation time in milliseconds
                "payTime": "320012321" // Actual payment completion time in milliseconds
            }
        ]
    }
```

{% endtab %}
{% endtabs %}

The following are the parameters involved in rsa encryption:

<table><thead><tr><th width="136">name</th><th width="124">type</th><th>required</th><th width="214">example</th><th>Description</th></tr></thead><tbody><tr><td>orderType</td><td>String</td><td>YES</td><td>1</td><td>Order type (1=payment order; 11=transfer order), do not pass query all orders</td></tr><tr><td>day</td><td>String</td><td>YES</td><td>2099-01-01</td><td>Statistics of the date, the format: yyyy-MM-dd, does not match the format parameter exception; does not pass the query the order of the day</td></tr><tr><td>pageNum</td><td>String</td><td>YES</td><td>1</td><td>Query the first few pages, the same paging logic; do not pass to check all</td></tr><tr><td>pageSize</td><td>String</td><td>YES</td><td>200</td><td>The size of each page, the same paging logic; do not pass to check 2000 (the maximum is 2000, data more than 2000 please paging query)</td></tr></tbody></table>

## Cancel Pending Orders

## Cancel Pending Orders

<mark style="color:green;">`POST`</mark> `https://service.xxx.com/opay/cancelOrder`

It is necessary to package the data in the parameter table into JSON strings and use rsa for parameter encryption and signature as data and sign in the body

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Content-Type	<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                      | Type   | Description     |
| ----------------------------------------- | ------ | --------------- |
| app\_id<mark style="color:red;">\*</mark> | String | Merchant AppKey |
| time<mark style="color:red;">\*</mark>    | String |                 |
| data<mark style="color:red;">\*</mark>    | String |                 |
| sign<mark style="color:red;">\*</mark>    | String |                 |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

The following are the parameters involved in rsa encryption:

<table><thead><tr><th width="136">name</th><th width="124">type</th><th>required</th><th width="214">example</th><th>Description</th></tr></thead><tbody><tr><td>orderNum</td><td>String</td><td>YES</td><td>10000001</td><td>订单编号</td></tr></tbody></table>
