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:

1
2
3
 {
   "reason" : "Insert reason here"
 }

The response, if successfully will be a JSON object with the following data:

1
2
3
 {
   "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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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",
        "Accept: application/vnd.printdeal-api.v2"
    )
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}