> For the complete documentation index, see [llms.txt](https://doc.mbd.pub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.mbd.pub/api/wei-xin-h5-zhi-fu.md).

# 微信 H5 支付

> 微信H5 支付使用前，请在控制台添加H5域名并确保审核通过

> H5 支付是指手机自带浏览器跳转至微信客户端支付的方式

#### 请求URL

* `https://newapi.mbd.pub/release/wx/prepay`

#### 请求方式

* POST
* Json

#### 请求参数

| **参数名**        | **必选** | **类型** | **说明**                                                                                                                           |
| -------------- | ------ | ------ | -------------------------------------------------------------------------------------------------------------------------------- |
| channel        | 是      | string | 固定为 h5                                                                                                                           |
| app\_id        | 是      | string | 你的 app\_id，可在控制台查看                                                                                                               |
| share\_code    | 否      | string | 分账参数，需[先开通分账权限](/kai-fa-zhe-zhi-chi/ying-yong-he-zuo-fen-zhang-quan-xian.md#shen-qing-fen-zhang-quan-xian-de-qian-zhi-tiao-jian) |
| description    | 是      | string | 支付描述，一般为商品名称                                                                                                                     |
| out\_trade\_no | 否      | string | 订单号，如不填，面包多将随机生成订单号                                                                                                              |
| amount\_total  | 是      | number | 金额，**单位为分**                                                                                                                      |
| sign           | 是      | string | 请求签名，参照[签名算法](/api/qian-ming-suan-fa.md)                                                                                         |

#### 返回示例

```
//成功
{
    "h5_url": "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx120013350995d44tfg4trab07f0000&package=12453942569"
}

//失败
{
    "error": "error sign"
}
```

#### 返回参数说明

| **参数名** | **类型** | **说明** |
| ------- | ------ | ------ |
| error   | string | 错误说明   |
|         |        |        |

#### 备注

* 如果返回结果不包含 error，则请求成功，返回的h5\_url 以链接点击形式跳转，即可在微信外的网页中 唤起微信进行H5支付
* H5支付的使用请参考微信官方文档
* 不需要传递 `callback_url`，因为支付完成后会自动返回并刷新原网页（请做好判断）
