check order status
you can call this API to get the latest status of the order, including the payment status and refund amount. if you are using method 2 or 3 to create the payment, the order will not be available until there is a payment event happened at divit.
endpoint: GET {{API_BASE_URL}}/paynow/orders/{{DIVIT_ORDER_ID}}/status
get order status
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}}/paynow/orders/{{DIVIT_ORDER_ID}}/status");
xhr.setRequestHeader("api-key", "{{API_KEY}}"); // e.g. dvt_rREeGJ4FXp69nQEJ7Arq08stvtacFyPrTzKr>
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
sample response
{
"value": {
"code": 0,
"message": "OK",
"data": {
"orderID": "c3222a2f-2908-468d-b0a8-7c64f3a21b4c", // DIVIT_ORDER_ID
"merchantRef": "1702905618115",
"orderAmount": { "amount": 40000, "currency": "HKD" },
"status": "completed", // order status
"instalments": [{
"instalmentSeriesID": 1,
"status": "paid",
"instalmentAmount": { "amount": 40000, "currency": "HKD" }
}],
"merchantFee": { "amount": 400, "currency": "HKD" },
"customerFee": { "amount": 0, "currency": "HKD" },
"totalRefundRequested": { "amount": 15000, "currency": "HKD" }, // refund requested
"totalRefundCompleted": { "amount": 0, "currency": "HKD" } // refund completed
}
}
}