> 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/alipay.md).

# Alipay

## **Direct**

## alipay

<mark style="color:green;">`POST`</mark> `BASE_URL/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       | 交易类型 : **pay**                                                                                                              |
| 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)    | 分钟，不能超过10分钟                                                                                                                 |
| 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)                                        |
| 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<mark style="color:red;">\*</mark>        | String       | json string, 消费者信息, 请参考[消费者信息](https://useepay.gitbook.io/developer/reference/api-reference/parameter-description#userinfo) |
| redirectUrl                                       | String(512)  | 跳转商户地址                                                                                                                      |

{% 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 %}

{% tabs %}
{% tab title="Request" %}
POST /api

Content-Type: application/x-www-form-urlencoded&#x20;

```
amount=100&appId=www.pay.com&currency=EUR&echoParam=echoParam&gatewaySource=useepay&merchantNo=500000000007264&notifyUrl=https://gatewaytest.useepay.com/notifyV2u0&orderInfo={"subject":"description","goodsInfo":[{"name":"商品名称","body":"商品描述","category":"商品类目","categoryTree":"商品类目树，不同级别类目使用”|”分割","brand":"商品品牌","quantity":1,"price":1234,"url":"商品url","sku":"商品sku","image":"商品图片url"}],"shippingAddress":{"email":"amber.lei@useepay.com","phoneNo":"123123","firstName":"Victor","lastName":"Yang","street":"Heathcoat+House,+20+Savile+Row","postalCode":"W1S+3PR","city":"London","state":"LND","country":"GB"}}&payerInfo={"paymentMethod":"klarna","countryCode":"AT","billingAddress":{"houseNo":"El+Gallo+Giro(https://gallogiro.com/)","email":"amber.lei@useepay.com","phoneNo":"1235854433","firstName":"amber","lastName":"Yang","stlogreet":"7148+Pacific+Blvd,+Huntington+Park,+CA","postalCode":"90225","city":"Huntington+Park","state":"CA","country":"MX","street":"street"}}&redirectUrl=https://gatewaytest.useepay.com/redirectV2u0&reserved=&sign=3a7005390f87ba32ee8abb09d08819d2&signType=MD5&transactionExpirationTime=20&transactionId=202210271113127&transactionType=pay&userInfo={"ip":"103.25.65.178","email":"amber.lei@useepay.com"}&version=1.0
```

{% endtab %}

{% tab title="Response" %}

```
{
    "amount": "100",
    "redirectUrl": "https://r2.girogate.de/klarna/T971/I?tx=140000594938&rs=GfWlb2Pxy6memHcgam7M3iqEzKSNgcn6&cs=19cbc7e094749c384d454597d3b9b66f1f2cf903a06ac68966fded4d65b85307",
    "resultCode": "challenge",
    "sign": "e5f081b0bb840b847137933055f6fc5f",
    "errorCode": "3200",
    "transactionId": "202210271113127",
    "errorMsg": "Transaction is pending",
    "transactionType": "pay",
    "reference": "1012210271113012018",
    "redirectMethod": "POST",
    "echoParam": "echoParam",
    "redirectParam": "{}",
    "reserved": "",
    "signType": "MD5",
    "currency": "EUR",
    "merchantNo": "500000000007264"
}
```

{% endtab %}
{% endtabs %}

## Params

### PayerInfo Object

| 参数            | 必选 | 类型     | 说明                                                          |
| ------------- | -- | ------ | ----------------------------------------------------------- |
| paymentMethod | Y  | String | alipay                                                      |
| osType        | Y  | String | <p>terminalType</p><p>为WAP的时候必传<code>IOS/ANDROID</code></p> |
| terminalType  | Y  | String | WEB/WAP                                                     |

### UserInfo Object

| 参数      | 必选 | 类型     | 说明                |
| ------- | -- | ------ | ----------------- |
| userId  | N  | string | max=128 用户id      |
| **ip**  | Y  | string | max=128 IPv4或IPv6 |
| email   | N  | string | max=128用户邮箱       |
| phoneNo | N  | string | max=32 用户手机号      |

### OrderInfo Object

| 参数          | 必选 | 类型                       | 说明                                                                   |
| ----------- | -- | ------------------------ | -------------------------------------------------------------------- |
| **subject** | Y  | String（128）              | 订单标题，可以是商品名称                                                         |
| goodsInfo   | N  | Array Json String (4096) | 商品信息, 请参考 [goodsInfo](broken://pages/-MVKobi5BxjIFLiFPvkG#goodsinfo) |

#### goodsInfo

<table data-header-hidden><thead><tr><th>参数</th><th width="75">必选</th><th width="175"></th><th>说明</th></tr></thead><tbody><tr><td>参数</td><td>必选</td><td>类型</td><td>说明</td></tr><tr><td>name</td><td>Y</td><td>String</td><td>商品名</td></tr><tr><td>body</td><td>Y</td><td>String</td><td>商品描述</td></tr><tr><td>quantity</td><td>Y</td><td>number</td><td>商品数量</td></tr><tr><td>price</td><td>Y</td><td>String</td><td><p>商品价格,必须大于0，单位为对应货币的最小</p><p>货币单位参考货币单位一节</p></td></tr><tr><td>url</td><td>N</td><td>String</td><td>商品链接</td></tr><tr><td>image</td><td>N</td><td>String</td><td>商品图片</td></tr></tbody></table>
