接入指引
请求与响应
商户系统的 API 请求通过 HTTPS POST 方法提交给 OTT Pay API 服务器。
商户系统向 OTT Pay API 服务器发送 请求消息,OTT Pay API 服务器处理请求消息后返回 响应结果。请求消息和响应结果均为 JSON 格式,编码格式为 UTF-8。
响应结果采用通用格式的 JSON 对象表示,响应结果中的 status 属性表示是否是成功结果,而 result 属性表示实际返回数据。比如:
{
"status": "SUCCESS",
"result": {
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJPTjAwMDAwMTgyMTQiLCJhdWRpZW5jZSI6bnVsbCwicm9sZSI6bnVsbCwiY3JlYXRlZCI6MTY3NzU5NDY2MzM5NywidXNlcnR5cGUiOiJDVVNUT01FUiIsImV4cCI6MTY3NzU5NTU2MywidXNlcmlkIjoxNH0.YHOw2N8oUP3vn_L-euzuUiShDfQbowAjrWjeVef0wn4jgHA4k5zsgcZ6euRUk-R-Xtn2OkYB7R8geGBjQQYnMw",
"expired": 1677595563672
}
}
不成功的响应会在 result 中包含 error 和 message,比如:
{
"status": "ERROR",
"result": {
"code": 10003,
"message": "User does not exist"
}
}
错误代码和相应的消息请参见:API 响应错误编码
授权方式
OTT Pay API 服务器采用 JWT token 授权的方式进行访问。商户系统需要先调用 授权 API 获得 token, 并在以后的每次API调用时在请求头中包含授权信息:
Authorization: Bearer <token>
例如:
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJPTjAwMDAwMTgyMTQiLCJhdWRpZW5jZSI6bnVsbCwicm9sZSI6bnVsbCwiY3JlYXRlZCI6MTY3NzU5NDY2MzM5NywidXNlcnR5cGUiOiJDVVNUT01FUiIsImV4cCI6MTY3NzU5NTU2MywidXNlcmlkIjoxNH0.YHOw2N8oUP3vn_L-euzuUiShDfQbowAjrWjeVef0wn4jgHA4k5zsgcZ6euRUk-R-Xtn2OkYB7R8geGBjQQYnMw
@
token 会在15分钟后过期,商户系统应该在token过期后重新调用 授权 API 进行后续的 API 访问。
API 服务器 URL
https://ecom-api.ottpay.com/
微信支付和支付宝无法提供官方沙盒测试环境,因此我们提供 API 生产环境进行集成。 所有的测试都将是真实的交易。 您可以通过 OTT Pay Merchant Center 查看支付记录和支付状态
获得支付结果
当商户系统调用了 支付 API 后,需要根据返回的响应结果和支付场景进行后续的支付动作,有些支付场景不能立即得到支付结果。OTT Pay API 服务器从支付通道获到支付结果后会将支付结果发送到指定的回调 URL(回调 URL 需要在 支付 API 的请求参数中指定,请参见特定 API 说明)。当然商户系统也能通过 支付状态查询 API 进行主动查询。
对回调信息的处理请参见 API 回调
API 响应错误编码
code | message |
---|---|
10001 | Transaction processing |
10002 | Password is incorrect |
10003 | User does not exist |
10004 | User not match |
10005 | Invalid parameter |
10006 | Parameter error |
20001 | Payment paid |
20002 | Payment number duplicated |
20003 | This is not a pre-authorized payment |
20004 | Database error |
20005 | No permission for the merchant |
20006 | QR code expired, please refresh, and try again |
20007 | Insufficient balance |
20008 | Unsupported card |
20008 | Payment closed |
20009 | Payment cancelled |
20010 | Banking system anomaly |
20011 | Authorization code parameter error |
20012 | Authorization code validation fails |
20013 | Please restart a transaction |
20014 | Refund amount greater than the amount paid |
20015 | Merchant information does not match |
20016 | Refund amount check fail |
20017 | Refund payment not exist |
20018 | Insufficient message header |
20019 | Original payment not exist |
20020 | Original payment has been finished |
20021 | Original payment does not support revocation |
20022 | Accepting institution abnormal state |
20023 | Verification signature fails |
20024 | Transfer to refund |
20028 | Refund success, user card frozen, need human intervention |
20029 | PaymentStatus: not pay, unpaid |
20030 | Payment failed |
20031 | No channel supported |
20032 | Failed to get merchant information |
20033 | Merchant account balance is insufficient. Do not allow to refund |
20034 | Other case |
20035 | The account request serial number already exists, cannot be submitted again |
20036 | Corresponding trade is being frozen due to security issues. Please contact Alipay technical support |
20037 | Has no privilege. Please contact Alipay technical support |
20038 | The buyer does not exist |
20039 | Buyer account status prohibits the refund |
20040 | The seller does not exist |
20041 | The trade status is illegal |
20042 | The trade has been finished |
20043 | Merchant balance is not enough for refund |
20044 | The cancellation request is beyond the opening hours |
20045 | Indicates payment result is unknown |
20046 | Indicates payment result is unknown |
20047 | This merchant is not yet available WeChat Pay |
20048 | This merchant is not yet available Alipay |
50001 | Failure |
50002 | Timeout |
50003 | System error |
90000 | Unauthorized |