Cancel order lines

Orders API v2
DELETEhttps://api.mollie.com/v2/orders/*orderId*/lines

This endpoint can be used to cancel one or more order lines that were previously authorized using a pay after delivery payment method. Use the Cancel Order API if you want to cancel the entire order or the remainder of the order.

Canceling or partially canceling an order line will immediately release the authorization held for that amount. Your customer will be able to see the updated order in his portal / app. Any canceled lines will be removed from the customer’s point of view, but will remain visible in the Mollie Dashboard.

You should cancel an order line if you don’t intend to (fully) ship it.

An order line can only be canceled while its status field is either authorized or shipping. If you cancel an authorized order line, the new order line status will be canceled. Canceling a shipping order line will result in a completed order line status.

If the order line is paid or already completed, you should create a refund using the Create Order Refund API instead.

For more information about the status transitions please check our order status changes guide.

Parameters

Replace orderId in the endpoint URL by the order’s ID, for example ord_8wmqcHMN4U.

lines

array
required

An array of objects containing the order line details you want to cancel.

id

string
required
The API resource token of the order line, for example: odl_jp31jz.

quantity

int
optional

The number of items that should be canceled for this order line. When this parameter is omitted, the whole order line will be canceled. When part of the line has been shipped, it will cancel the remainder and the order line will be completed.

Must be less than the number of items already shipped or canceled for this order line.

amount

amount object
optional

The amount that you want to cancel. In almost all cases, Mollie can determine the amount automatically.

The amount is required only if you are partially canceling an order line which has a non-zero discountAmount.

The amount you can cancel depends on various properties of the order line and the cancel order lines request. The maximum that can be canceled is unit price x quantity to cancel.

The minimum amount depends on the discount applied to the line, the quantity already shipped or canceled, the amounts already shipped or canceled and the quantity you want to cancel.

If you do not send an amount, Mollie will determine the amount automatically or respond with an error if the amount cannot be determined automatically. The error will contain the extra.minimumAmount and extra.maximumAmount properties that allow you pick the right amount.

Mollie Connect/OAuth parameters

If you’re creating an app with Mollie Connect/OAuth, the testmode parameter is also available.

testmode

boolean
optional
Set this to true to cancel test mode order lines.

Response

204 No Content

Example

cURLPHPPythonRubyNode.js
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
curl -X DELETE https://api.mollie.com/v2/orders/ord_8wmqcHMN4U/lines \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" \
   -d '{
         "lines": [
            {
               "id": "odl_dgtxyl",
               "quantity": 1
            },
            {
               "id": "odl_jp31jz"
            }
         ]
   }'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");

$order = $mollie->orders->get("ord_8wmqcHMN4U");
$order->cancelLines([
   'lines' => [
         [
            'id' => 'odl_dgtxyl',
            'quantity' => 1, // you can partially cancel the line.
         ],
         [
            'id' => 'odl_jp31jz', // or cancel the line completely
         ],
   ],
]);

// if you want to cancel all eligible lines, you can use this shorthand:
// $order->cancelAllLines();

$updatedOrder = $mollie->orders->get($order->id);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
mollie_client = Client()
mollie_client.set_api_key('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
order = mollie_client.orders.get('ord_8wmqcHMN4U')
order.cancel_lines({
  'lines': [
    {
      'id': 'odl_dgtxyl',
      'quantity': 1,  # you can partially cancel the line.
    }
  ]
})

# if you want to cancel all eligible lines, you can use this shorthand:
# order.cancel_lines()

updated_order = mollie_client.orders.get('ord_8wmqcHMN4U')
1
2
3
4
We don't have a Ruby code example for this API call yet.

If you have some time to spare, feel free to open a pull request at:
https://github.com/mollie/api-documentation
1
2
3
4
We don't have a Node.js code example for this API call yet.

If you have some time to spare, feel free to open a pull request at:
https://github.com/mollie/api-documentation

Response

1
HTTP/1.1 204 No Content

Response (amount required)

 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
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/hal+json

{
     "status": 422,
     "title": "Unprocessable Entity",
     "detail": "Line 0 contains invalid data. An amount is required for this API call. The amount must be between €0.00 and €50.00.",
     "field": "lines.0.amount",
     "extra": {
         "minimumAmount": {
             "value": "0.00",
             "currency": "EUR"
         },
         "maximumAmount": {
             "value": "50.00",
             "currency": "EUR"
         }
     },
     "_links": {
         "documentation": {
             "href": "https://docs.mollie.com/reference/v2/orders-api/cancel-order-lines",
             "type": "text/html"
         }
     }
 }

Response (cancellation rejected)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/hal+json

{
    "status": 422,
    "title": "Unprocessable Entity",
    "detail": "Update authorization not allowed. Decision is based on order state and outcome of risk assessment.",
    "_links": {
        "documentation": {
            "href": "https://docs.mollie.com/guides/handling-errors",
            "type": "text/html"
        }
    }
}