Cancelling an order¶
To cancel an order, send a DELETE
request to /api/orders/{orderid}
.
The body needs to contain JSON data with the corresponding reason. For example:
{ "reason" : "Insert reason here" }
The response, if successfully will be a JSON object with the following data:
{ "success": true }
Your order can be cancelled as long as the order is not yet in production.
If you can no longer cancel your order, you will receive a 500 Internal Server Error
that contains the message Cancel order failed
.
Example request¶
The following PHP code can be used to cancel an order.
Make sure you replace the values YOUR_USER_ID_HERE
and YOUR_SECRET_HERE
with the User-ID and secret you received on the API-credentials page.
Make sure to replace ORDERID
with the id of the order you would like to cancel,
and REASON
with the reason of the cancellation.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.printdeal.com/api/orders/ORDERID",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => "{'reason': 'REASON'}",
CURLOPT_HTTPHEADER => array(
"User-ID: YOUR_USER_ID_HERE",
"API-Secret: YOUR_SECRET_HERE"
)
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}