get transaction report
for automated reconciliation and accounting, divit compiles daily transaction reports in standard Excel format (.xlsx). you can retrieve these reports programmatically via our reporting API.
endpoint details
- HTTP method:
GET - production URL:
https://api.divit.com.hk/reporting/paynow/daily/report/{filename} - sandbox URL:
https://sandbox-api.divit.dev/reporting/paynow/daily/report/{filename}
request headers
api-key: your_api_key_here
Content-Type: application/json
path parameters
{filename} format
the target filename must follow a specific pattern:
{MERCHANT_SHORTCODE}-{yyyy-mm-dd}-divit-daily-transaction.xlsx
MERCHANT_SHORTCODE: the unique abbreviation representing your organization. you can retrieve this code under your profile in the divit merchant portal.yyyy-mm-dd: the target calendar date for the report.
example filename: MERCHANTX-2024-02-26-divit-daily-transaction.xlsx
implementation example (download & file save)
below is an implementation example using Node's modern fetch API to download the spreadsheet file and save it securely on the filesystem:
const fs = require('fs');
/**
* downloads a daily transaction report from divit
* @param {string} filename - target report filename
* @param {string} apiKey - your secret merchant API key
* @param {string} savePath - path where the file should be saved
*/
async function downloadTransactionReport(filename, apiKey, savePath) {
const url = `https://sandbox-api.divit.dev/reporting/paynow/daily/report/${filename}`;
try {
const response = await fetch(url, {
method: "GET",
headers: {
"api-key": apiKey,
"Content-Type": "application/json"
}
});
if (!response.ok) {
// handle JSON error response (e.g. file not found)
const errorData = await response.json();
throw new Error(`API Error [${errorData.code}]: ${errorData.message}`);
}
// retrieve file binary buffer and write to file system
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
fs.writeFileSync(savePath, buffer);
console.log(`report successfully downloaded and saved to: ${savePath}`);
} catch (error) {
console.error("failed to download transaction report:", error.message);
throw error;
}
}
response formats
successful retrieval (spreadsheet binary)
if the report file is found, our server returns an HTTP 200 OK status with raw binary buffer data and the following content headers:
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content-Disposition: attachment; filename=MERCHANTX-2024-02-26-divit-daily-transaction.xlsx
report not found (JSON error)
reports are automatically generated by the gateway at 02:00 HKT each morning for the previous calendar day. if there were no transactions processed on the requested day, or if you request a report before its scheduled generation time, our server will return a JSON error structure with code 8100:
{
"code": 8100,
"message": "failed to find file MERCHANTX-2024-02-26-divit-daily-transaction.xlsx"
}