处理付款请求
当买家在结算流程中选中支付应用进行付款时,SHOPLINE 将使用预定的参数协议,对您的支付应用设置的最新的付款URL发起HTTP调用时,并将买家重定向到您返回的PaymentUrl;付款完成后,你需要将买家重定向回接口传递的RedirectUrl,买家将会在RedirectUrl等待最终的支付结果; 您可以用以下两种方式,将支付结果同步到 SHOPLINE:
- 提供一个付款查询URL,那么 SHOPLINE 将会在调用付款URL后,已一定的频率通过付款查询URL发起HTTP调用,尝试获取该笔支付的结果,直到获取到终态或者最终超时(一般是24小时);
- 主动调用我们的付款通知Webhook接口,直到返回正确的响应;
支付应用流程的工作原理
下图说明了支付应用程序和 SHOPLINE 之间的支付流程如何工作:
跳转模式

- 客户完成结帐,触发付款请求。
- SHOPLINE 向支付应用程序发送后端请求,指定要收取的金额和币种。
- 该支付应用程序使用合作伙伴应用程序托管的支付页面的重定向 URL 进行响应。
- SHOPLINE 将客户重定向到重定向 URL。
- 支付应用程序收集客户的支付凭证并按照后端请求中的描述处理支付。
- 支付 应用程序将支付结果发送到 SHOPLINE,SHOPLINE 将根据需要实施重试策略。
- SHOPLINE 使用重定向 URL 进行响应,并发送成功HTTP 状态。
- 支付应用程序将客户重定向到 SHOPLINE。
- 客户继续结账。
需要注意,支付应用应当使用我们传递的支付单号做幂等处理。
内嵌模式

支付状态流转
对于通过支付应用发起的支付请求,我们期望它的支付状态流转如下:

请求付款接口
在请求付款时,Shopline将通过Http-Post请求您提供的付款Url;
请求头示例
对应 Http Request Header
pay-api-version: 1.0.0
pay-api-idempotency-key: TESTKEYKEYKEY
pay-api-signature: SIGNSIGNSIGN
pay-api-timestamp: 1665632758606000
pay-api-store-handle: xxx
| 字段 | 是否必填 | 含义 |
|---|---|---|
| pay-api-version | 是 | 您在配置支付应用拓展时,填入的API VERSION |
| pay-api-idempotency-key | 是 | 幂等key |
| pay-api-signature | 是 | 签名值 |
| pay-api-timestamp | 是 | 请求发起时的时间戳 |
| pay-api-store-handle | 是 | 店铺唯一标识,例如:store1 |
请求正文示例
对应 Http Request Body
{
"orderTransactionId": "test_4ea758952734",
"referenceOrderId": "test_ff13c864b7fc",
"amount": 47,
"currency": "test_6ecc3b427a9f",
"redirectUrl": "test_a273b5c641b4",
"cancelUrl": "test_a273b5c6sas",
"notifyUrl": "test_188f3fe29ae2",
"billing": {
"personalInfo": {
"firstName": "test_fe18d6fc2798",
"lastName": "test_53fb73557da0",
"email": "test_e5e3dbd08790",
"identityType": "test_cac8c5abdbc7",
"identityNumber": "test_ebc761bb42ac",
"gender": "test_0704156bc002",
"phoneNumber": "test_e387bba596a8",
"homeTelephone": "test_a904ea96f89f",
"birthDay": "test_dccbf5b55cb6"
},
"address": {
"countryCode": "test_58ee6b67432f",
"state": "test_c86268fac927",
"stateCode": "test_bd232ee9b52a",
"city": "test_a8e72a4b7660",
"district": "test_60580c478afe",
"street": "test_f6ca14b11e07",
"street2": "test_9d168406be68",
"street3": "test_c9c85ef7c4b6",
"postcode": "test_7250544bd97d"
}
},
"shipping": {
"personalInfo": {
"firstName": "test_4db57f98c782",
"lastName": "test_d25c9b6d4a07",
"email": "test_089851321917",
"identityType": "test_2f2fcc09f376",
"identityNumber": "test_9b940715498a",
"gender": "test_5650bb1861d2",
"phoneNumber": "test_67507bac86dd",
"homeTelephone": "test_a09b85892bc2",
"birthDay": "test_9f05f7e481bb"
},
"address": {
"countryCode": "test_096475ce74d7",
"state": "test_c2113a8b18c9",
"stateCode": "test_2b8d522f55fa",
"city": "test_d0a6b9b780ca",
"district": "test_95a9222ca449",
"street": "test_a423b3d71c5e",
"street2": "test_9fb2013867b3",
"street3": "test_86d526908645",
"postcode": "test_09ffe0b8cf1b"
},
"shippingMethod": "test_7796822bf919",
"carrier": "test_17327dbfb7ce"
},
"products": [
{
"id": "test_fb4ef47a1a0f",
"name": "test_260a61ca16a8",
"sku": "test_5f883d1deab3",
"desc": "test_d0cbf7004770",
"quantity": 38,
"unitPrice": {
"value": 54,
"currency": "test_17c30bdc32b3"
}
}
],
"amountBreakdown": {
"productAmount": 67,
"discount": 99,
"productTax": 49,
"shippingAmount": 10,
"shippingTax": 5,
"other": 94
},
"merchant": {
"storeWebsite": "test_b085e7df3518",
"configData": {}
},
"card": {
"cardNo": "4444444444444444",
"expirationMonth": "11",
"expirationYear": "24",
"cvv": "123",
"holderName": "test"
},
"client": {
"ip": "test_b556bd9ff25a",
"deviceType": "test_8baf6c506ef8",
"deviceId": "test_5a6951dcc93c",
"javaScriptEnabled": true,
"javaEnabled": false,
"colorDepth": "test_8f35331e86f5",
"screenHeight": "test_e2c2f73f00bf",
"screenWidth": "test_a0b636ab9ef2",
"timeZoneOffset": "test_f65b530dfe9c",
"userAgent": "test_743313c383b4",
"language": "test_0231f84d3825",
"transactionWebSite": "test_c991d72e506c",
"accept": "test_7b30ef6c583c"
}
}
| 字段 | 类型 | 是否必填 | 含义 |
|---|---|---|---|
| orderTransactionId | string | 是 | 支付交易流水号,付款请求唯一标识,系统层面用来交互的单号 |
| referenceOrderId | string | 是 | 业务订单号,建议将这个单号展示在您后台的业务单号字段;用户能通过这个单号,在Shopline后台关联到一笔订单,但这个单号不是Shopline订单号,不能用来查询订单详情; |
| amount | integer | 是 | 交易金额 |
| currency | string | 是 | 交易金额币种 |
| redirectUrl | string | 是 | 支付完成重定向URL |
| cancelUrl | string | 是 | 用户取消支付时的重定向URL |
| notifyUrl | string | 是 | 异步结果的通知URL,针对这一笔支付的webhook通知,可以直接请求该链接(路径参数已经包含在链接上了); |
| billing | object | 否 | 账单 |
| |─personalInfo | object | 是 | 个人信息 |
| |─firstName | string | 否 | 名字 |
| |─lastName | string | 是 | 姓氏 |
| string | 否 | 邮箱地址 | |
| |─identityType | string | 否 | 身份证件类型 |
| |─identityNumber | string | 否 | 身份证件号码 |
| |─gender | string | 否 | 性别 |
| |─phoneNumber | string | 否 | 电话号码 |
| |─homeTelephone | string | 否 | 家庭电话号码 |
| |─birthDay | string | 否 | 生日,格式为 YYYY-MM-DD |
| |─address | object | 是 | 地址信息 |
| |─countryCode | string | 是 | 国家编码 |
| |─state | string | 否 | 州/省 |
| |─stateCode | string | 否 | 州/省编码 |
| |─city | string | 否 | 城市 |
| |─district | string | 否 | 区域 |
| |─street | string | 否 | 街道 |
| |─street2 | string | 否 | 街道2 |
| |─street3 | string | 否 | 街道3 |
| |─postcode | string | 否 | 邮政编码 |
| shipping | object | 否 | 物流 |
| |─personalInfo | object | 是 | 个人信息 |
| |─firstName | string | 否 | 名字 |
| |─lastName | string |