Skip to main content

get settlement report file

step 1​

you can call this API to fetch the settlement report list

endpoint: GET {{API_BASE_URL}}/reporting/settlement/report?fromDate=yyyy-mm-dd

the parameter {{yyyy-mm-dd}} is the settlement date.

get transaction report

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("GET", "{{API_BASE_URL}}/reporting/settlement/report?fromDate=2024-02-26");
xhr.setRequestHeader("api-key", "{{API_KEY}}");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);

the endpoint will return list of report from the date specified:

{
"code": 0,
"message": "OK",
"data": [
{
"reportDate": "2024-02-26T00:00:00Z",
"platform": "production",
"type": "settlement/orders",
"title": "settlement report for YOUMALL-20240226-E364",
"merchantID": "4303c954-afbf-463c-ae37-bdcff2ac106a",
"abbreviation": "YOUMALL",
"currency": "HKD",
"bucket": "divit_reporting",
"path": "settlements/production",
"filename": "4303c954-afbf-463c-ae37-bdcff2ac106a-settlement-report.xlsx",
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"numOfRecords": 99,
"createdAt": "2024-02-26T02:35:33.041243Z",
"updatedAt": "2024-02-26T02:35:33.041243Z"
}
]
}

step 2​

call this endpoint to download the specific report file

endpoint: GET {{API_BASE_URL}}/reporting/settlement/report/{{filename}}

the parameter {{filename}} is the filename found in the above json reply.

get transaction report

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("GET", "{{API_BASE_URL}}/reporting/settlement/report/4303c954-afbf-463c-ae37-bdcff2ac106a-settlement-report.xlsx");
xhr.setRequestHeader("api-key", "{{API_KEY}}");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);

the endpoint will return the blob content with following headers:

content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
content-disposition: attachment; filename={{filename}}

response when report is not found​

important

system generates the report right after the bank transfer is complete. there won't be any bank transaction on weekend and public holidays/ you won't be able to download the report if there no transaction of the previous day or before the time it is being generated.

system returns a JSON response with the error code 8100 if the file is not found:

{
"code": 8100,
"message": "failed to find file 4303c954-afbf-463c-ae37-bdcff2ac106a-settlement-report.xlsx, ...."
}