inquiryBalance
POST
: /amsin/api/v1/business/account/inquiryBalance
集成商完成垫付后,可调用inquiryBalance接口查询账户余额。
最佳实践建议为,集成商在转账前调用此接口两次:
- 垫付完成后,集成商需调用inquiryBalance接口,以确认垫资足额到账。
- 用户向集成商提交转账请求时,集成商需要再次调用inquiryBalance接口查询账户余额,以确保金额充足。
接口结构
万里汇接口报文结构包括:请求头,请求体。
请求头
字段名 | 是否必传 | 范例 | 说明 |
Client-Id | 是 |
| 关于这些参数的解释说明,详见:请求头。 |
Signature | 是 |
| |
Content-Type | 是 |
| |
Request-Time | 是 |
| |
Connected-CustomerId | 有条件要求 |
| 当平台客户操作商户账户时需要传递 |
Access-Token | 有条件要求 |
| 当用 OAUTH 授权时需要传递 |
请求参数
字段名 | 数据类型 | 是否必填 | 描述 |
currencyList | 数组<字符串> | 否 | 集成商查询的币种列表,为 ISO 4217 标准规定的三位字母货币代码。 更多信息:
|
balanceTypes | 数组<字符串> | 否 | 该字段表示客户拥有的不同余额类型。 说明:客户在不同业务场景下,可使用不同的余额类型对资金余额做分隔管理,作用是为了风险管控。 可取值:
注:
|
响应参数
字段名 | 数据类型 | 是否必填 | 描述 |
result | Result 对象 | 是 | 代表接口调用结果 |
说明:以下字段,只有当 | |||
responseId | 字符串 | 是 | 由万里汇定义,用于唯一标识某次响应的ID。 更多信息:
|
accountBalances | 数组<AccountBalance>对象 | 是 | 用户的账户信息列表,包括账号、账户币种、账户余额等信息。 |
响应处理
集成商调用接口后,万里汇返回集成商API调用结果。result.resultStatus
字段取值范围为:
result.resultStatus | 描述 |
S | API请求成功。 |
F | API请求失败。 失败原因参见结果码(即 |
U | API响应结果为 重试策略:
如果问题依旧,请联系万里汇技术支持。 |
结果码
result.resultCode
系统错误码
resultCode | resultStatus | resultMessage | 处理建议 |
SUCCESS | S | Success | |
PARAM_ILLEGAL | F | Illegal parameters exist. For example, a non-numeric input, or an invalid date. | 参考API文档页面,确认请求头和传参是否正确 |
PROCESS_FAIL | F | A general business failure occurred. Do not retry. | 需要人工介入,联系万里汇技术支持以解决此问题 |
UNKNOWN_EXCEPTION | U | API failed due to unknown reason. | 服务器错误,若稍后重试问题依旧,联系万里汇技术支持以解决问题 |
REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. | 重试,若问题依旧,联系万里汇技术支持 |
OAUTH_FAIL | F | OAuth process failed. | 联系万里汇技术支持了解详情 |
INVALID_API | F | The called API is invalid or not active. | 确认是否调用正确的API |
INVALID_CLIENT | F | The client is invalid. | Client ID不存在或无效 |
INVALID_SIGNATURE | F | The signature is invalid. | 确认请求正确加签,具体参见: |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. | 确认HTTP请求方法为 |
业务错误码
resultCode | resultStatus | resultMessage | 处理建议 |
USER_NOT_EXIST | F | The user does not exist. | 使用正确的用户信息重试 |
ACCOUNT_NOT_EXIST | F | Account does not exist. | 账户不存在,使用其他账户重试 |
SYSTEM_ERROR | F | System error. | 请勿重试,联系万里汇技术支持了解详情 |
SERVICE_NOT_ALLOWED | F | Service not allowed | 使用正确的信息重试,若问题依旧,联系万里汇技术支持以解决问题 |
CURRENCY_NOT_SUPPORT | F | The currency is not supported. | 暂不支持该币种 |
CONTRACT_CHECK_FAIL | F | The contract check has failed. | 联系万里汇技术支持检查合约状态,确保合约有效后重试。 |
AUTHORIZATION_NOT_EXIST | F | The authorization does not exist. | 当前授权关系不存在,请联系万里汇技术支持检查授权关系 |
ACCESS_TOKEN_EXPIRED | F | The access token expired. | 刷新token接口以重新获取访问令牌(access token),或联系万里汇技术支持以解决问题 |
范例
请求
请求体范例
{
"currencyList": ["CNH", "USD"]
}
请求代码范例
var client = new RestClient("http://{domain_name}.com/amsin/api/v1/business/account/inquiryBalance");
var request = new RestRequest(Method.POST);
request.AddHeader("client-id","******");
request.AddHeader("request-time","2022-05-17T11:19:20+08:00");
request.AddHeader("Content-Type","application/json");
request.AddHeader("signature","algorithm=RSA256,keyVersion=1,signature=Rck*****");
request.AddParameter("application/json; charset=utf-8", jsonStr, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
url = "http://{domain_name}.com/amsin/api/v1/business/account/inquiryBalance"
headers = {
"client-id": "*****",
"request-time": "2022-05-17T11:19:20+08:00",
"Content-Type": "application/json",
"signature": "algorithm=RSA256,keyVersion=1,signature=Rck%*****"
}
datas = {"currencyList": ["CNH", "USD"]}
res = requests.post(url=url, data=json.dumps(datas), headers=headers)
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("http://{domain_name}.com/amsin/api/v1/business/account/inquiryBalance");
httpPost.addHeader("client-id", "*****");
httpPost.addHeader("request-time", "2022-05-17T11:19:20+08:00");
httpPost.addHeader("signature","algorithm=RSA256,keyVersion=1,signature=RckS*****" );
httpPost.addHeader("Content-Type","application/json");
StringEntity entity = new StringEntity("{\"currencyList\": ["CNH", "USD"]}");
httpPost.setEntity(entity);
CloseableHttpResponse response = client.execute(httpPost);
var xhr = new XMLHttpRequest;
xhr.open("POST","http://{domain_name}.com/amsin/api/v1/business/account/inquiryBalance",true)
xhr.setRequestHeader("client-id","*****");
xhr.setRequestHeader("request-time","2022-05-17T11:19:20+08:00");
xhr.setRequestHeader("Content-Type","application/json");
xhr.setRequestHeader("signature","algorithm=RSA256,keyVersion=1,signature=RckSO*****");
xhr.send("{\"currencyList\": ["CNH", "USD"]"}");
响应
响应体范例
{
"accountBalances": [
{
"accountNo": "*****",
"availableBalance": {
"currency": "CNH",
"value": 329899311
},
"currency": "CNH",
"frozenBalance": {
"currency": "CNH",
"value": 0
},
"totalBalance": {
"currency": "CNH",
"value": 329899311
}
},
{
"accountNo": "*****",
"availableBalance": {
"currency": "USD",
"value": 289633970
},
"currency": "USD",
"frozenBalance": {
"currency": "USD",
"value": 0
},
"totalBalance": {
"currency": "USD",
"value": 289633970
}
}
],
"responseId": "*****",
"result": {
"resultStatus": "S",
"resultCode": "SUCCESS",
"resultMessage": "success."
}
}