
## 开发指引

沙盒环境api地址： <http://sandbox-va.fusionpay.one/open-api>
生产环境api地址： <http://va.fusionpay.one/open-api>

### 协议规则，访问 Fusion Pay 支付API的请求规则

传输模式
使用 HTTPS 进行安全交易
提交模式
POST/PUT/GET，取决于业务API定义
数据格式（内容类型）
提交的数据和响应都是 application/json 格式
字符编码
使用 UTF-8 字符编码
签名算法
HMAC-SHA256
illustration

### 所有 REST API 请求都必须包含以下标头

FusionPay-Key
string
商户后台获取的Key
FusionPay-Timestamp
long
请求发送的 UnixTimestamp，以毫秒为单位，保证机器时间与网络同步
FusionPay-Nonce
string
32 字节的随机字符串，例如a-z 和 A-Z 中的随机 ascii 小数并循环 32 次以形成随机字符串
FusionPay-Sign
string
签名，使用SHA256，并且是大写

### 签名步骤

FusionPay-Sign 是使用字符串 timestamp + nonce + body 和 API密钥 通过 HMAC-SHA256 加密生成

#### 第一步

时间戳
请求发送的Unix时间戳，以毫秒为单位，保证机器时间与网络同步
Nonce
32字节的随机字符串，例如a-z 和 A-Z 中的随机 ascii 小数并循环 32 次以形成随机字符串
Body
请求正文字符串——如果没有请求正文则省略（通常用于 GET 请求）

```json
{
  "out_user_id": "1234567890",
  "out_user_name": "out_user_name",
  "amount": 100.0,
  "currency": "ETH",
  "name": "name",
  "description": "description",
  "redirect_url": "https://your-company.com/RedirectURL",
  "cancel_url": "https://your-company.com/CancelURL",
  "webhook_url": "https://your-company.com/CheckoutCallBack",
  "out_order_no": "20230315122829182"
}
```

#### 第二步

在签名字符串上使用您的API秘钥通过
HMAC-SHA256
加密
构建内容 ：String payload = timestamp + nonce + body

注意不要在有效负载中包含转义字符，例如 / “

```
1678854509192a360c030bb7945e1bd0ca83de09213cd{"out_user_id":"1234567890","out_user_name":"out_user_name","amount":100,"currency":"ETH","name":"name","description":"description","redirect_url":"https://your-company.com/RedirectURL","cancel_url":"https://your-company.com/CancelURL","webhook_url":"https://your-company.com/CheckoutCallBack","out_order_no":"20230315122829182"}
```

API Secret:
提交的数据和响应都是 application/json 格式

```
49bb3a138404f56ccf6a04554288ddbac0fc5267e5775c5340a83eb4391b67cc
```

对内容进行签名：
String signature = hex(hmac("sha256", payload, API Secret)).toUpperCase()

```
A9F9C40EE9AEBC61FC57C596AFC3C2A3577D238DF9F1D0B478A7775B7585B86F
```

签名测试网站： <https://www.devglan.com/online-tools/hmac-sha256-online>

## 1、账户

### 1.1、创建账户

#### 字段说明

##### Request Object

###### `request_id`

- **Type:** `string`
- **Description:** 请求 ID
- **Required:** Yes

##### Legal Entity Object

###### `legal_entity`

- **Type:** `object`
- **Description:** Legal entity information
- **Required:** Yes

| Field Name                  | Type                   | Description                                                 | Required |
|-----------------------------|------------------------|-------------------------------------------------------------|----------|
| `aoa`                       | `string`, `null`       | [香港企业] 公司章程 （文件）                                 | No       |
| `dob`                       | `string`               | 出生日期 或 企业成立日期（格式为 2020-01-01）               | Yes      |
| `name`                      | `string`               | 姓名 或 企业名称                                            | Yes      |
| `type`                      | `string` (`enum`)      | 实体类型，值为 "PERSON" 或 "COMPANY"                        | Yes      |
| `email`                     | `string`               | 邮箱                                                       | Yes      |
| `owner`                     | `object`               | Owner information                                           | No       |
| `phone`                     | `string`               | 联系方式                                                   | No       |
| `gender`                    | `string`, `null` (`enum`) | [个人] 性别，值为 "MALE" 或 "FEMALE"                      | No       |
| `region`                    | `string`               | 国家地区代码（ISO 3166-1 alpha-2）                          | Yes      |
| `address`                   | `string`               | 居住地址 或 企业注册地址                                   | Yes      |
| `id_type`                   | `string`, `null` (`enum`) | [个人] 证件类型，值为 "ID_CARD" 或 "PASSPORT"            | No       |
| `website`                   | `string`, `null`       | [企业] 公司网址                                            | No       |
| `br_image`                  | `string`, `null`       | [香港企业] 商业登记证                                      | No       |
| `cr_image`                  | `string`, `null`       | [非大陆企业] 公司注册证明书照片                            | No       |
| `industry`                  | `string`, `null` (`enum`) | [企业必输] 所属行业                                      | Yes      |
| `br_number`                 | `string`, `null`       | [香港企业] 商业登记证编号                                  | No       |
| `cr_number`                 | `string`, `null`       | [非大陆企业] 公司注册证明书编号                            | No       |
| `documents`                 | `array`, `null`        | [企业] 补充材料                                            | No       |
| `issue_date`                | `string`               | 证件发行日期                                               | Yes      |
| `nc1_images`                | `array`, `null`        | [非大陆企业] 法团成立表格                                  | No       |
| `occupation`                | `string`, `null` (`enum`) | [个人] 职业                                              | No       |
| `expiry_date`               | `string`               | 证件失效日期                                               | Yes      |
| `company_type`              | `string`, `null` (`enum`) | [企业] 企业类型                                          | No       |
| `issue_agency`              | `string`               | [个人] 证件发行机构                                        | Yes      |
| `shareholders`              | `array`                | 股东信息                                                    | No       |
| `license_image`             | `string`, `null`       | [大陆企业] 营业执照图片                                    | No       |
| `phone_country`             | `string`, `null`       | 填写值请参考 Country Calling Codes                         | No       |
| `business_scope`            | `string`               | [企业] 经营范围                                            | Yes      |
| `id_card_number`            | `string`, `null`       | [个人] 身份证号                                            | No       |
| `license_number`            | `string`, `null`       | [大陆企业] 营业执照号                                      | No       |
| `company_name_en`           | `string`               | [企业] 企业英文名，支持 a-z, A-Z, 0-9 / - ? : ( ) . , + 空格 | Yes      |
| `passport_number`           | `string`, `null`       | [个人] 护照号                                              | No       |
| `id_card_back_image`        | `string`, `null`       | [个人] 身份证背面图片                                      | No       |
| `address_proof_image`       | `string`               | 地址证明                                                   | Yes      |
| `id_card_front_image`       | `string`, `null`       | [个人] 身份证正面图片                                      | No       |
| `passport_front_image`      | `string`, `null`       | [个人] 护照正面图片                                        | No       |
| `id_card_handheld_image`    | `string`, `null`       | [个人] 身份证手持图片                                      | No       |
| `passport_handheld_image`   | `string`, `null`       | [个人] 护照手持图片                                        | No       |
| `ownership_structure_image` | `string`, `null`       | [企业] 企业股权架构图                                      | No       |

###### Owner Object

| Field Name               | Type                   | Description                                                 | Required |
|--------------------------|------------------------|-------------------------------------------------------------|----------|
| `type`                   | `string` (`enum`)      | 实体类型，值为 "PERSON"                                     | Yes      |
| `region`                 | `string` (`enum`)      | 国籍，值为 "CN" 或 "HK"                                    | Yes      |
| `name`                   | `string`               | 姓名                                                        | Yes      |
| `dob`                    | `string`               | 出生日期：格式 2020-01-01                                   | Yes      |
| `address`                | `string`               | 居住地址                                                    | Yes      |
| `id_type`                | `string` (`enum`)      | [个人] 证件类型，值为 "ID_CARD" 或 "PASSPORT"              | Yes      |
| `id_card_number`         | `string`               | [个人] 身份证号                                             | No       |
| `id_card_front_image`    | `string`               | [个人] 身份证正面图片                                       | No       |
| `id_card_back_image`     | `string`               | [个人] 身份证背面图片                                       | No       |
| `id_card_handheld_image` | `string`               | [个人] 身份证手持图片                                       | No       |
| `passport_number`        | `string`               | [个人] 护照号                                               | No       |
| `passport_front_image`   | `string`               | [个人] 护照正面图片                                         | No       |
| `passport_handheld_image`| `string`               | [个人] 护照手持图片                                         | No       |
| `issue_date`             | `string`               | 证件发行日期                                               | Yes      |
| `expiry_date`            | `string`               | 证件失效日期                                               | Yes      |
| `issue_agency`           | `string`               | 证件发行机构                                               | Yes      |
| `address_proof_image`    | `string`               | 地址证明                                                   | No       |

###### Shareholders Object

| Field Name               | Type                   | Description                                                 | Required |
|--------------------------|------------------------|-------------------------------------------------------------|----------|
| `name`                   | `string`               | 姓名                                                        | Yes      |
| `type`                   | `string`               | PERSON                                                      | Yes      |
| `dob`                    | `string`               | 出生日期                                                    | Yes      |
| `region`                 | `string`               | 国家地区代码（ISO 3166-1 alpha-2）                          | Yes      |
| `address`                | `string`               | 地址                                                        | Yes      |
| `id_type`                | `string`               | 证件类型                                                    | Yes      |
| `issue_date`             | `string`               | 发行日期                                                    | Yes      |
| `expiry_date`            | `string`               | 过期日期                                                    | Yes      |
| `issue_agency`           | `string`               | 发行机构                                                    | Yes      |
| `id_card_number`         | `string`               | 身份证号码(证件类型为身份证时)                              | Yes      |
| `passport_number`        | `string`               | 护照号码(证件类型为护照时)                                  | Yes      |
| `id_card_front_image`    | `string`               | 身份证正面图片地址                                          | Yes      |
| `id_card_back_image`     | `string`               | 身份证背面图片地址                                          | Yes      |
| `passport_front_image`   | `string`               | 护照正面图片地址                                            | Yes      |
| `ratio`                  | `string`               | 占股比 0~1 之间                                             | Yes      |
| `address_proof_image`    | `string`               | 地址证明                                                   | No       |

###### 请求示例

```bash
curl --location --request POST '/v3/accounts' \
--header 'fusionpay-key;' \
--header 'fusionpay-timestamp;' \
--header 'fusionpay-nonce;' \
--header 'fusionpay-sign;' \
--header 'Content-Type: application/json' \
--data-raw '{
    "request_id": "string",
    "legal_entity": {
        "type": "PERSON",
        "region": "string",
        "name": "string",
        "company_name_en": "string",
        "dob": "string",
        "gender": "MALE",
        "email": "string",
        "phone_country": "string",
        "phone": "string",
        "address": "string",
        "address_proof_image": "string",
        "occupation": "党的机关、国家机关、群众团体和社会组织、企事业单位负责人",
        "company_type": "有限责任公司",
        "business_scope": "string",
        "industry": "农、林、牧、渔业",
        "website": "string",
        "id_type": "ID_CARD",
        "id_card_number": "string",
        "id_card_front_image": "string",
        "id_card_back_image": "string",
        "id_card_handheld_image": "string",
        "passport_number": "string",
        "passport_front_image": "string",
        "passport_handheld_image": "string",
        "license_number": "string",
        "license_image": "string",
        "br_number": "string",
        "br_image": "string",
        "cr_number": "string",
        "cr_image": "string",
        "nc1_images": [
            "string"
        ],
        "ownership_structure_image": "string",
        "aoa": "string",
        "issue_date": "string",
        "expiry_date": "string",
        "issue_agency": "string",
        "documents": [
            "string"
        ],
        "owner": {
            "type": "PERSON",
            "region": "CN",
            "name": "string",
            "dob": "string",
            "address": "string",
            "address_proof_image": "string",
            "id_type": "ID_CARD",
            "id_card_number": "string",
            "id_card_front_image": "string",
            "id_card_back_image": "string",
            "id_card_handheld_image": "string",
            "passport_number": "string",
            "passport_front_image": "string",
            "passport_handheld_image": "string",
            "issue_date": "string",
            "expiry_date": "string",
            "issue_agency": "string"
        },
        "shareholders": [
            {
                "name": "string",
                "type": "string",
                "dob": "string",
                "region": "string",
                "address": "string",
                "address_proof_image": "string",
                "id_type": "string",
                "issue_date": "string",
                "expiry_date": "string",
                "issue_agency": "string",
                "id_card_number": "string",
                "passport_number": "string",
                "id_card_front_image": "string",
                "id_card_back_image": "string",
                "passport_front_image": "string",
                "ratio": "string"
            }
        ]
    }
}'
```

返回

```json
{
    "data": {
        "id": "string",
        "request_id": "string",
        "legal_entity": {
            "type": "PERSON",
            "region": "string",
            "name": "string",
            "company_name_en": "string",
            "dob": "string",
            "gender": "MALE",
            "email": "string",
            "phone_country": "string",
            "phone": "string",
            "address": "string",
            "address_proof_image": "string",
            "occupation": "党的机关、国家机关、群众团体和社会组织、企事业单位负责人",
            "company_type": "有限责任公司",
            "business_scope": "string",
            "industry": "农、林、牧、渔业",
            "website": "string",
            "id_type": "ID_CARD",
            "id_card_number": "string",
            "id_card_front_image": "string",
            "id_card_back_image": "string",
            "id_card_handheld_image": "string",
            "passport_number": "string",
            "passport_front_image": "string",
            "passport_handheld_image": "string",
            "license_number": "string",
            "license_image": "string",
            "br_number": "string",
            "br_image": "string",
            "cr_number": "string",
            "cr_image": "string",
            "nc1_images": [
                "string"
            ],
            "ownership_structure_image": "string",
            "aoa": "string",
            "issue_date": "string",
            "expiry_date": "string",
            "issue_agency": "string",
            "documents": [
                "string"
            ],
            "owner": {
                "type": "PERSON",
                "region": "CN",
                "name": "string",
                "dob": "string",
                "address": "string",
                "address_proof_image": "string",
                "id_type": "ID_CARD",
                "id_card_number": "string",
                "id_card_front_image": "string",
                "id_card_back_image": "string",
                "id_card_handheld_image": "string",
                "passport_number": "string",
                "passport_front_image": "string",
                "passport_handheld_image": "string",
                "issue_date": "string",
                "expiry_date": "string",
                "issue_agency": "string"
            },
            "shareholders": [
                {
                    "name": "string",
                    "type": "string",
                    "dob": "string",
                    "region": "string",
                    "address": "string",
                    "address_proof_image": "string",
                    "id_type": "string",
                    "issue_date": "string",
                    "expiry_date": "string",
                    "issue_agency": "string",
                    "id_card_number": "string",
                    "passport_number": "string",
                    "id_card_front_image": "string",
                    "id_card_back_image": "string",
                    "passport_front_image": "string",
                    "ratio": "string"
                }
            ]
        },
        "status": "SUBMITTED",
        "reason": "string",
        "create_time": "string",
        "update_time": "string"
    }
}
```
