Cancel order lines¶
DELETE
https://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 Klarna payment method. Use the Cancel order endpoint 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 do not 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 endpoint instead.
For more information about the status transitions, check our order status changes guide.
Parameters¶
Replace orderId
in the endpoint URL by the order’s ID, for example ord_8wmqcHMN4U
.
lines
arrayrequiredAn array of objects containing the order line details you want to cancel.
id
stringrequiredodl_jp31jz
.quantity
intoptionalThe 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 objectoptionalThe 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.
Access token parameters¶
If you are using organization access tokens or are creating an
OAuth app, you can enable test mode through the testmode
parameter.
true
to cancel test mode order lines.Response¶
204 No Content
Example¶
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 17 18 19 20 21 22 | mollie_client = Client() mollie_client.set_api_key("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM") order = mollie_client.orders.get("ord_8wmqcHMN4U") # To cancel a single line, simply delete it by id: order.lines.delete("odl_dgtxyl") # To partially cancel a line, change its quantity: order.lines.delete_lines({ "lines": [ { "id": "odl_dgtxyl", "quantity": 1, } ] }) # If you want to cancel all eligible lines, you can use this shorthand: order.lines.delete_lines() updated_order = mollie_client.orders.get("ord_8wmqcHMN4U") |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | require 'mollie-api-ruby' Mollie::Client.configure do |config| config.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' end order = Mollie::Order.get('ord_8wmqcHMN4U') # you can partially cancel the line. order.lines.first.cancel(qty: 1) # or cancel the line completely order.lines.first.cancel updated_order = Mollie::Order.get('ord_8wmqcHMN4U') |
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 share suggestions on our Discord: https://discord.gg/VaTVkXB4aQ |
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/overview/handling-errors", "type": "text/html" } } } |