# 支付/预授权

## API

## 跳转式收银台

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

#### Headers

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

#### Request Body

| Name                                                        | Type      | Description                                                                                |
| ----------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------ |
| sign<mark style="color:red;">\*</mark>                      | string    | 签名值                                                                                        |
| signType<mark style="color:red;">\*</mark>                  | string    | 签名类型 MD5 / RSA (4)                                                                         |
| echoParam                                                   | string    | 回声参数，Response 中将会原样返回 (256)                                                                |
| notifyUrl                                                   | string    | 异步通知地址 (512)                                                                               |
| userInfo<mark style="color:red;">\*</mark>                  | string    | json string, 消费者信息, 请参考[消费者信息](../../parameter-description#userinfo)                       |
| payerInfo<mark style="color:red;">\*</mark>                 | string    | json string, 付款方信息, 请参考[payerInfo](../../parameter-description#payerinfo)                  |
| currency<mark style="color:red;">\*</mark>                  | string    | 货币单位，请参考[货币单位](../../../gui-fan-xing-shuo-ming/huo-bi-dan-wei)一节                           |
| orderInfo<mark style="color:red;">\*</mark>                 | string    | json string, 订单信息, 请参考[orderInfo](../../parameter-description#orderinfo)                   |
| amount<mark style="color:red;">\*</mark>                    | string    |  订单金额, 必须大于0，单位为对应货币的最小货币单位参考[货币单位一](../../../gui-fan-xing-shuo-ming/huo-bi-dan-wei)节 (12) |
| appId<mark style="color:red;">\*</mark>                     | string    |  提交审核的网站, 需与商户后台网站审核值一致 (128)                                                              |
| transactionExpirationTime<mark style="color:red;">\*</mark> | integer   | 交易过期时间(单位为分钟) (6)                                                                          |
| transactionType<mark style="color:red;">\*</mark>           | string    | 传 **pay** / **authorization** (18)                                                         |
| transactionId<mark style="color:red;">\*</mark>             | string    | 订单号, 需要唯一 (64)                                                                             |
| merchantNo<mark style="color:red;">\*</mark>                | string    | 商户号 (16)                                                                                   |
| autoRedirect                                                | boolean   | true/ false 默认 true                                                                        |
| version<mark style="color:red;">\*</mark>                   | string(5) | 目前固定为 1.0 (5)                                                                              |
| redirectUrl                                                 | String    | 重定向请求的跳转地址 max=512                                                                         |
| terminalType<mark style="color:red;">\*</mark>              | String(8) | 终端类型 WEB/H5                                                                                |

{% tabs %}
{% tab title="200 请求参数 autoRedirect = false" %}
```
{
    "amount": "123",
    "redirectUrl": "https://checkout1.uat.useepay.com/?accessToken=eAF1VW1r20Yc_yrj-tZOJNlxJb9L03orJK1Z0pVRl3HWne1bJZ16OsUVnqF907UsIR1bxmAMSt90MOgeYGxsHf0uo46zV_sK-_9POlfpg0Ns3e93_-cHzYjiWR5p0p2RkVCZvkJjTrpkKKJIJOPeCmqQiL7OblukQUKq2F6R8ox0b5BPwyFpkBhYrpCAA03TiKe0wEcOX_CY0gge9kVGyc0GGVPNp7TYlbkK0YFru5cu9Tc_Lq_GPNE7XE8kQ_2zM9ZmRINdkAC988bqhD7UjjVnaqgxPgfrSRl1qDgT-hPjM16rR7XSXLleE7PIuyRWwddkzmBSMa4uJyOJZahSf5FnoRKplgpiuw21mOT0vRFNICPglhIgwICZTqdrYH8tlDEyuVI8CQuTwIsAjCXkrNRMbswG5HZOEy10MSBdtzEgqRIhh-cBcb21VntAAMNcGGhxfH_x1b3Fo8Pl058NI1gNXz7_ZnH0u8FDqN1YqmJP8brk8pe_lt89O3n85X_PD17-cbh4dLD88-niwY8l_vLvF8uvf_jn7vefwf_iwf3Fw1-NsqFk6N2AlOZPjo5OX5TmrZkaW6oyctmtvEaYEwQzVDSpew0BLR8eGIFcRTUBc5rftCmrxuD02ZPF4fHJ48__ffItUDH08wQSeNXUC9PvOZ7rOu6G0_ZaTrsFd8paIgd4Sbodr9XZcPygA7wGj7LNGCYOct6CHiU0irZkMhJj2wGU0RRGB244bZAYSq1lfB0UA7JZ-wAX0iTk0Ydc5yq5piK4gA0xpILltiXA4THfhq-cjnFOXBRTnJadRVkskk2AeDzkjHHWi8ZoGJGE7YmYb8nI9OC5Xq_ddpAYx3oLFXCkoZE6nue4jtdun_cDw-5IJkaFZVuuvxG4QQd-GkRAEIHTgodsdyKnWzJPNJPTpLIZvfKTY6vHVCR7MkG_zznw6fUQRF_L9ncRdBy33cHc2_qYydgoKfw-3_IxaktXxe2d_PbF6U_HSKC_MFFgZZUPGKoL-k3bCOdQj6Qv7nDItwe7DBIF89mXUYQhw4qCOGGy9mlYACjC4u2VwWWjeKghW7YuGaTkAqzeKhv2CNrPrAMMxnD1zrDgFmzciYxYtdNW8P4-aLWnnpRlh1ngfVwUDHZO7ZLBXlOzLcewpUx_oAdmErCmK83X-TATehWQpkqf6aL2Jv5hAEVyRWrIO8y1kEm53yvVmsdpBA2GhfSgWey5qtwHEl4trE8LfDH0sa1fXSlzvW4QFWdXRzBbsNTBwturYOYRPZQ5zqTn-9jiWhXbMoQ3VBlqnvGdavZ3y-AcMofRtSUsVU-0TrPu-nr1LtM802sgie89HEaLN5FYt6IfeTkatL35jtY1rwsI2HpxmUHktmetLBpZy2DhDeUdaxhjkbdglrrQ5Wk3pqnooums6_mBM_I7TtNjgdt0XR42Ay9gTdrxNjqB4_mtwCfz_wEXGNID",
    "resultCode": "received",
    "sign": "c60982754906a3f326ff672108e55ca1",
    "errorCode": "0000",
    "transactionId": "202110150423043",
    "errorMsg": "Approved or completed successfully",
    "token": "mop:mapi:redis:2890f860-2d91-11ec-929d-a62569028398",
    "transactionType": "pay",
    "reference": "1012110151623650896",
    "echoParam": "echoParam",
    "reserved": "reserved",
    "signType": "MD5",
    "currency": "USD",
    "merchantNo": "500000000007381"
}
```
{% endtab %}

{% tab title="302: Found 请求参数 autoRedirect = true " %}
会自动重定向，也可以在response header中的location获取

Response Header

```javascript
Location: https://checkout1.uat.useepay.com/?accessToken=eAF1VV1v21QY_ivo7DZtbSdNk9x13QKT2q2iHRNaJnTic5KY2T7e8XEzq1SCm7GJVh2CIiSENO1mSEjjQ0IgGNp_QUtTrvgLPO-xnbn7SNXE53nO-_3hfaZlmoWG9fbZKNCpucojyXpsGIR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RLdS4r957Cq0Vs85xeDNvU1i-vFLlesYiO0msjzBaWOiy8uQp2HslDldFMep0OtbjR-aby8YYqQs1SuVXO_k4RnMMOMLpVCQvVE2OStLeyUr7LjEzNMiTpvUfDWOFLRKxUoh94GRmsevMtrWtfFwi48uKKQORVz1ayZGQ5xcIbqruVYYpF3cYs9dDlSS_iSdAj02nPX21jKofOkie67pLrSn-p63XFEm97YByv08S-OvgfVqTSOw%3D%3D
```
{% endtab %}
{% endtabs %}



## Pay Result

{% tabs %}
{% tab title="支付" %}
```
{
    "amount": "1234",
    "currency": "USD",
    "echoParam": "echoParam",
    "errorCode": "0000",
    "errorMsg": "Approved or completed successfully",
    "merchantNo": "500000000007381",
    "reference": "1012112011024652513",
    "referer": "https://gatewaytest.useepay.com/",
    "resultCode": "succeed",
    "sign": "1aab1771d7846efb74edb801a0fd772d",
    "signType": "MD5",
    "transactionId": "202112011024047",
    "transactionType": "pay",
    "version": "1.0"
}
```
{% endtab %}

{% tab title="预授权" %}
```
{
    "amount": "1234",
    "currency": "USD",
    "echoParam": "echoParam",
    "errorCode": "0000",
    "errorMsg": "Approved or completed successfully",
    "merchantNo": "500000000007381",
    "reference": "1102112011016652511",
    "referer": "https://gatewaytest.useepay.com/",
    "resultCode": "succeed",
    "sign": "37fd3957f5f96cfe91550128d716038c",
    "signType": "MD5",
    "transactionId": "202112011016327",
    "transactionType": "authorization",
    "version": "1.0"
}
```
{% endtab %}
{% endtabs %}

| 字段              | 长度      | 描述                                                                                 | 是否必要 |
| --------------- | ------- | ---------------------------------------------------------------------------------- | ---- |
| merchantNo      | max=16  | max=16 商户编号，由 USEEPAY 分配                                                           | yes  |
| transactionId   | max=64  | 商户订单号，需保证在商户端不重复                                                                   | yes  |
| transactionType | max=18  | 交易类型：pay/authorization                                                             | yes  |
| reference       | max=32  | USEEPAY 订单号                                                                        |      |
| amount          | max=12  | 支付金额，单位为对应币种的最小货币单位[(详见 ISO 4217)](../../../gui-fan-xing-shuo-ming/huo-bi-dan-wei) | yes  |
| currency        | max=3   | 3 位 ISO 大写字母货币代码[(详见 ISO 4217)](../../../gui-fan-xing-shuo-ming/huo-bi-dan-wei)    | yes  |
| resultCode      | max=32  | 业务结果（详见 [业务结果码](../../resultcode)）**判断交易是否成功的依据**                                  | yes  |
| errorCode       | max=4   | 错误码（详见 错误码 errorCode）                                                              |      |
| errorMsg        | max=256 | 错误码消息描述                                                                            |      |
| echoParam       | max=256 | 回声参数，响应报文会原样返回                                                                     |      |
| sign            | max=256 | 签名                                                                                 | yes  |
