7. Order Cancellation API
API for canceling an order already pushed to GHTK system
Endpoint
In case you want to cancel using GHTK's tracking order.
POST /services/shipment/cancel/{TRACKING_ORDER}
warning
When using the partner code (the order.id code passed during order submission), please adhere to the following format:
TRACKING_ORDER
= partner_id:PARTNER_CODE
POST /services/shipment/cancel/partner_id:{PARTNER_CODE}
Headers
- Token:
{API_TOKEN}
- X-Client-Source:
{PARTNER_CODE}
- Content-Type:
application/json
Parameters
Parameter | Mandatory | Desc |
---|---|---|
TRACKING_ORDER | Yes | GHTK's reference ID or the Partner's reference ID (submitted with the order.id field in the "Submit an Order" API). |
Code
- HTTP
- CURL
- PHP
GET /services/shipment/cancel/{TRACKING_ORDER} HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
curl -X GET -H "Token: {API_TOKEN}" \
-H "Token: {API_TOKEN}" \
-H "X-Client-Source: {PARTNER_CODE}" \
"https://services.giaohangtietkiem.vn/services/shipment/cancel/{TRACKING_ORDER}"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://services.giaohangtietkiem.vn/services/shipment/cancel/{TRACKING_ORDER}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
"Token: {API_TOKEN}",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo 'Response: ' . $response;
?>
Response
Cancel successfully
{
"success": true,
"message": "",
"log_id": "..."
}
Cancelled order
{
"success": false,
"message": "Đơn hàng đã đã ở tr ạng thái hủy",
"log_id": "..."
}
Cases Where Order Cancellation Is Not Possible
danger
Orders cannot be canceled after they have been successfully picked up. The API can only cancel orders in the following states:
- Created (1 & 2)
- Picking (12)
{
"success": false,
"message": "Đơn đã lấy hàng, không thể hủy đơn.",
"log_id": "..."
}