> For the complete documentation index, see [llms.txt](https://useepay.gitbook.io/developer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://useepay.gitbook.io/developer/reference/local-pay-ben-di-hua/ben-di-hua-jie-kou/dian-zi-qian-bao/wechat-hk/native.md).

# 扫码支付

## 产品说明

用户扫描商户展示在各种场景的二维码进行支付。

1. 商户根据微信支付的规则，为不同商品生成不同的二维码，展示在各种场景，用于用户扫描购买。步
2. 用户使用微信“扫一扫”扫描二维码后，获取商品支付信息，引导用户完成支付
3. 用户确认支付，输入支付密码
4. 支付完成后会提示用户支付成功（如图6.5），商户后台得到支付成功的通知，然后进行发货处理。

![](/files/HMPWAg6b0ibIwIXjHbD6)

![](/files/5wZuAPf1wtFXbuRPz6WB)

## 业务流程说明

1. 商户后台系统根据用户选购的商品生成订单。
2. 用户确认支付后调用UseePay微信支付（Server To Server）生成预支付交易；
3. 微信支付系统收到请求后生成预支付交易单，并返回交易会话的二维码链接code\_url。
4. 商户后台系统根据返回的code\_url生成二维码。
5. 用户打开微信“扫一扫”扫描二维码，完成支付
6. UseePay 异步通知(notifyUrl)商户系统订单完成
7. &#x20;未收到支付通知的情况，商户后台系统调用[【查询订单API】](/developer/reference/api-reference-xin-yong-ka/order/order-detail.md)
8. 商户确认订单已支付后给用户发货

## 微信扫码支付wechat\_native

<mark style="color:green;">`POST`</mark> `USEEPAY_PATH/api`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| content-type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                              | Type         | Description                                                                                                                 |
| ------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------- |
| transactionType<mark style="color:red;">\*</mark> | String       | <p></p><p></p><p>交易类型 : <strong>pay</strong> </p>                                                                           |
| version<mark style="color:red;">\*</mark>         | String(5)    | 目前固定为 1.0 (5)                                                                                                               |
| signType<mark style="color:red;">\*</mark>        | String       | 商户生成签名字符串所使用的签名算法类型，目前支持：RSA/MD5                                                                                            |
| merchantNo<mark style="color:red;">\*</mark>      | String(16)   | 商户号                                                                                                                         |
| transactionId<mark style="color:red;">\*</mark>   | String(64)   | 商户订单号                                                                                                                       |
| transactionExpirationTime                         | String(6)    | 可选，默认为20分钟 .范围1-20                                                                                                          |
| appId<mark style="color:red;">\*</mark>           | String (128) | 网站域名                                                                                                                        |
| amount<mark style="color:red;">\*</mark>          | String(12)   | 支付金额，单位为对应币种的最小货币单位[(详见 ISO 4217)](/developer/gui-fan-xing-shuo-ming/huo-bi-dan-wei.md)                                     |
| currency<mark style="color:red;">\*</mark>        | String(3)    | 3 位 ISO 大写字母货币代码[(详见 ISO 4217)](/developer/gui-fan-xing-shuo-ming/huo-bi-dan-wei.md) 目前仅支持HKD                               |
| notifyUrl<mark style="color:red;">\*</mark>       | String(512)  | [异步通知](/developer/reference/notify/notifyurl.md)                                                                            |
| echoParam                                         | String(256)  | 回声参数，响应报文会原样返回                                                                                                              |
| payerInfo<mark style="color:red;">\*</mark>       | String       | Json格式的String 付款方信息, 请下方                                                                                                    |
| orderInfo                                         | String       | json string, 订单信息, 请参考下方                                                                                                    |
| userInfo                                          | String       | json string, 消费者信息, 请参考[消费者信息](https://useepay.gitbook.io/developer/reference/api-reference/parameter-description#userinfo) |

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

```javascript
{
    "codeUrl": "weixin://wxpay/bizpayurl?pr=qCJcd2azz",
    "amount": "2",
    "resultCode": "pending",
    "sign": "1213b8dd73dff60c62e6c12d7000d32f",
    "errorCode": "3200",
    "transactionId": "202201180239183",
    "errorMsg": "Transaction is pending",
    "transactionType": "pay",
    "reference": "1012201181439650764",
    "echoParam": "echoParam",
    "signType": "MD5",
    "currency": "HKD",
    "merchantNo": "500000000007264"
}
```

{% endtab %}
{% endtabs %}

## 请求参数详情说明

### payerInfo

| 参数                                | 必选 | 类型          | 说明                   |
| --------------------------------- | -- | ----------- | -------------------- |
| paymentMethod                     | Y  | String      | 目前固定为 wechat\_native |
| authorizationMethod               | Y  | String      | 固定为 cvv              |
| [billingAddress](#billingaddress) | N  | Json String | 账单地址                 |

### orderInfo

| 参数              | 必选 | 类型          | 说明                                                                               |
| --------------- | -- | ----------- | -------------------------------------------------------------------------------- |
| subject         | Y  | String（128） | 订单标题，可以是商品名称                                                                     |
| goodsInfo       | N  | array       | 商品信息, 请参考 [goodsInfo](broken://pages/-MVKobi5BxjIFLiFPvkG#goodsinfo)             |
| shippingAddress | N  | object      | 收货地址, 请参考 [shippingAddress](broken://pages/-MVKobi5BxjIFLiFPvkG#shippingaddress) |

## 返回参数说明

| 字段              | 是否必须 | 描述                                                                                                                      |
| --------------- | ---- | ----------------------------------------------------------------------------------------------------------------------- |
| codeUrl         | N    | wechat支付url, 当请求成功时存在                                                                                                   |
| amount          | Y    | 订单金额                                                                                                                    |
| currency        | Y    | 3 位 ISO 大写字母货币代码[(详见 ISO 4217)](/developer/gui-fan-xing-shuo-ming/huo-bi-dan-wei.md)                                    |
| errorCode       | Y    | 错误码（详见 错误码 errorCode）                                                                                                   |
| errorMsg        | Y    | 错误码消息描述                                                                                                                 |
| echoParam       | N    | 回声参数，响应报文会原样返回                                                                                                          |
| sign            | Y    | 签名                                                                                                                      |
| transactionId   | Y    | 商户订单号                                                                                                                   |
| transactionType | Y    | 支付类型 pay                                                                                                                |
| reference       | N    | USEEPAY 订单号                                                                                                             |
| resultCode      | Y    | 业务结果（详见 [业务结果码](/developer/reference/resultcode.md)）**判断交易是否成功的依据** 当前交易涉及的&#x6709;**:** succeed,pending,failed, closed |

## 时序图

![](/files/2pnUJTRVKim8R8dDNNns)

商户也可以调用[UseePay订单查询](/developer/reference/api-reference-xin-yong-ka/order/order-detail.md)接口查询支付最终结果

## 二、Redirect&#x20;

## 微信扫码支付收银台模式 wechat\_native

<mark style="color:green;">`POST`</mark> `USEEPAY_PATH/cashier`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| content-type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                              | Type         | Description                                                                                                                 |
| ------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------- |
| transactionType<mark style="color:red;">\*</mark> | String       | <p></p><p></p><p>交易类型 : <strong>pay</strong> </p>                                                                           |
| version<mark style="color:red;">\*</mark>         | String(5)    | 目前固定为 1.0 (5)                                                                                                               |
| signType<mark style="color:red;">\*</mark>        | String       | 商户生成签名字符串所使用的签名算法类型，目前支持：RSA/MD5                                                                                            |
| merchantNo<mark style="color:red;">\*</mark>      | String(16)   | 商户号                                                                                                                         |
| transactionId<mark style="color:red;">\*</mark>   | String(64)   | 商户订单号                                                                                                                       |
| transactionExpirationTime                         | String(6)    | 可选，默认为20分钟 .范围1-20                                                                                                          |
| appId<mark style="color:red;">\*</mark>           | String (128) | 网站域名                                                                                                                        |
| amount<mark style="color:red;">\*</mark>          | String(12)   | 支付金额，单位为对应币种的最小货币单位[(详见 ISO 4217)](/developer/gui-fan-xing-shuo-ming/huo-bi-dan-wei.md)                                     |
| currency<mark style="color:red;">\*</mark>        | String(3)    | 3 位 ISO 大写字母货币代码[(详见 ISO 4217)](/developer/gui-fan-xing-shuo-ming/huo-bi-dan-wei.md) 目前仅支持HKD                               |
| notifyUrl<mark style="color:red;">\*</mark>       | String(512)  | [异步通知](/developer/reference/notify/notifyurl.md)                                                                            |
| echoParam                                         | String(256)  | 回声参数，响应报文会原样返回                                                                                                              |
| payerInfo<mark style="color:red;">\*</mark>       | String       | Json格式的String 付款方信息, 请下方                                                                                                    |
| orderInfo                                         | String       | json string, 订单信息, 请参考下方                                                                                                    |
| userInfo                                          | String       | json string, 消费者信息, 请参考[消费者信息](https://useepay.gitbook.io/developer/reference/api-reference/parameter-description#userinfo) |
| autoRedirect                                      | String       | 是否自动跳转 'false', 'true' 默认为'true'                                                                                            |

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

```javascript
```

{% endtab %}
{% endtabs %}

### 2.2 请求参数详情说明

#### 2.2.1 payerInfo

| 参数                                | 必选 | 类型          | 说明                   |
| --------------------------------- | -- | ----------- | -------------------- |
| paymentMethod                     | Y  | String      | 目前固定为 wechat\_native |
| authorizationMethod               | Y  | String      | 固定为 cvv              |
| [billingAddress](#billingaddress) | N  | Json String | 账单地址                 |

#### 2.2.2 orderInfo

| 参数              | 必选 | 类型          | 说明                                                                               |
| --------------- | -- | ----------- | -------------------------------------------------------------------------------- |
| subject         | Y  | String（128） | 订单标题，可以是商品名称。这个最终会提现在微信支付账单中                                                     |
| goodsInfo       | N  | array       | 商品信息, 请参考 [goodsInfo](broken://pages/-MVKobi5BxjIFLiFPvkG#goodsinfo)             |
| shippingAddress | N  | object      | 收货地址, 请参考 [shippingAddress](broken://pages/-MVKobi5BxjIFLiFPvkG#shippingaddress) |

### 2.3 返回参数说明

| 字段              | 是否必须 | 描述                                                                                                                                |
| --------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------- |
| redirectUrl     | N    | wechat支付url, 当resultCode为recevied时存在                                                                                              |
| amount          | Y    | 订单金额                                                                                                                              |
| currency        | Y    | 3 位 ISO 大写字母货币代码[(详见 ISO 4217)](/developer/gui-fan-xing-shuo-ming/huo-bi-dan-wei.md)                                              |
| errorCode       | Y    | 错误码（详见 错误码 errorCode）                                                                                                             |
| errorMsg        | Y    | 错误码消息描述                                                                                                                           |
| echoParam       | N    | 回声参数，响应报文会原样返回                                                                                                                    |
| sign            | Y    | 签名                                                                                                                                |
| transactionId   | Y    | 商户订单号                                                                                                                             |
| transactionType | Y    | 支付类型 pay                                                                                                                          |
| reference       | N    | USEEPAY 订单号                                                                                                                       |
| resultCode      | Y    | 业务结果（详见 [业务结果码](/developer/reference/resultcode.md)）**判断交易是否成功的依据** 当前交易涉及的&#x6709;**:** succeed,pending,failed, closed, recevied |
