Query account balance

POST: /amsin/api/v1/business/account/inquiryBalance Signature required

Use the inquiryBalance interface to query your account balance.

For example:

  • Before creating a transfer request, it is the best practice for the Partner to call this interface on two different conditions:
    • The Partner can call this API to check the account balance after prefunding. The result indicates whether Zyla has received the prefunding deposits or not. For more details about the prefund step, refer to the related section in the Transfer funds chapter.
    • Before calling the createTransfer API cand create a transfer request, the Partner should call the inquiryBalance API first and ensure the account balance is sufficient.

Structure

A message consists of a header and body. For details, see the following sections.

Request header

Field

Required

Sample

Description

Client-Id

Yes

Client-Id: *****

For more information about these request header fields, see Request header.

Signature

Yes

Signature: algorithm=RSA256, keyVersion=2, signature=*****

Content-Type

Yes

Content-Type: application/json; charset=UTF-8

Request-Time

Yes

Request-Time: 2019-04-04T12:08:56+08:00

Connected-CustomerId

Conditional

Connected-CustomerId: *****

Attention to this field

Required when a partner manages a customer's account. 

Access-Token

Conditional

Access-Token: ******

Attention to this field

Required for OAUTH authorization.

Request parameters

Field

Data type

Required

Description

currencyList

Array<String>

No

A list containing 3-character ISO-4217 currency codes representing the currency that the Partner queries.

Note:

  • If this field is empty, this API returns balance information for all currencies.

balanceTypes

Array<String>

Conditional

This field represents the various balance types. Valid values for this field vary from different clients as follows:

  • For the only CN HK EC (E-commerce) clients from the point of risk control, valid values are:
    • NORMAL_BALANCE: manages the balance of funds that come from the e-commerce platform.
    • SAME_NAME_TOP_UP_BALANCE: manages the balance of funds that top-up by CN HK EC clients themselves.
  • For other clients, this field value is NORMAL_BALANCE, which manages normal balance of funds.

Response parameters

Field

Data type

Required

Description

result

Result object

Yes

Indicates whether this API is called successfully.

Note: The following fields are returned only if the value of result.resultStatus is S.

responseId

String

Yes

The unique ID that is assigned by Zyla to identify a response.

More information:

  • Maximum length: 32 characters

accountBalances

List<AccountBalance object>

Yes

A list of information about the Customer's account, which includes account number, account currency, account balances, etc.

Result processing logic

After calling the API, a response is returned. The possible responses for result.resultStatus are:

Result status

Description

S

This indicates the API call succeeded.

F

This indicates the API call failed. For more information on why the call failed, see result.resultCode.

U

This indicates the API call result is unknown. Partner can make a query when the returned status is UNKNOWN. Use the following query strategy:

  • A Partner can make 7 queries at maximum.
  • Intervals between queries: 5m, 10m, 20m, 40m, 80m, 160m, and 320m.

If none of the queries is successful, contact our Technical Support Team.

Result codes

result.resultCode

System-related result codes

resultCode

resultStatus

resultMessage

Further action

SUCCESS

S

Success

PARAM_ILLEGAL

F

Illegal parameters exist. For example, a non-numeric input, or an invalid date.

Check and verify whether the request fields, including the header fields and body fields, are correct and valid.

For details on the fields of each API, see the specific API Structure section.

PROCESS_FAIL

F

A general business failure occurred. Do not retry.

Human intervention is usually needed. It is recommended that you contact our Technical Support Team to resolve the issue.

UNKNOWN_EXCEPTION

U

API failed due to unknown reason.

The service might be down, retry later. If the issue persists, contact our Technical Support Team.

REQUEST_TRAFFIC_EXCEED_LIMIT

U

The request traffic exceeds the limit.

Call the interface again to resolve the issue. If the issue persists, contact our Technical Support Team.

OAUTH_FAIL

F

OAuth process failed.

Contact our Technical Support Team for detailed reasons.

INVALID_API

F

The called API is invalid or not active.

Check whether the correct API is being called.

INVALID_CLIENT

F

The client is invalid.

The Client ID does not exist or is invalid.

INVALID_SIGNATURE

F

The signature is invalid.

Make sure the request is properly signed with a valid signature.

METHOD_NOT_SUPPORTED

F

The server does not implement the requested HTTP method.

Ensure the HTTP method is POST.

Business-related result codes

resultCode

resultStatus

resultMessage

Further action

USER_NOT_EXIST 

F

The user does not exist.

Retry with the correct user information.

ACCOUNT_NOT_EXIST

F

Balance accounts does not exist.

Retry with the correct account information.

SYSTEM_ERROR

F

System error.

Do not retry, and contact our Technical Support Team for more details.

SERVICE_NOT_ALLOWED

F

Service not allowed

Retry with the correct information. If the issue persists, contact our Technical Support Team.

CURRENCY_NOT_SUPPORT

F

The currency is not supported.

Make sure the currency input is correct and try again.

CONTRACT_NOT_EXIST

F

Contract does not exist.

Ensure the Partner has already signed a contract with Zyla, and the input is correct.

INVALID_ACCESS_TOKEN

F

Invalid access token

Use the correct access token.

ACCESS_TOKEN_EXPIRED

F

The access token expired.

Refresh token to get a new access token or contact out Technical Support Team to address it.

Samples

Request

Request body sample

copy
{
  "currencyList": ["CNH", "USD"]
}

Request calling samples

copy
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);
copy
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)
copy
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);
copy
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"]"}");  

Response

Response body sample

copy
{
    "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."
    }
}