Update order line

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

This endpoint can be used to update an order line. Only the lines that belong to an order with status created, pending or authorized can be updated.

Use cases for this endpoint could be updating the name, productUrl, imageUrl, and metadata for a certain order line because your customer wants to swap the item for a different variant, for example exchanging a blue skirt for the same skirt in red.

Or update the quantity, unitPrice, discountAmount, totalAmount, vatAmount and vatRate if you want to substitute a product for an entirely different one.

Alternatively, you can also (partially) cancel order lines instead of updating the quantity.

When updating an order line that uses a pay after delivery method such as Klarna Pay later, Klarna may decline the requested changes, resulting in an error response from the Mollie API. The order remains intact, though the requested changes are not persisted.

Parameters

Replace orderId in the endpoint URL by the order’s ID, for example ord_pbjz8x. And replace the orderLineId in the URL by the order line ID, for example odl_dgtxyl

Please note that even though all parameters are optional, at least one of them needs to be provided in the request.

namestringoptional
A description of the order line, for example LEGO 4440 Forest Police Station.
imageUrlstringoptional
A link pointing to an image of the product sold.
productUrlstringoptional
A link pointing to the product page in your web shop of the product sold.
skustringoptional
The SKU, EAN, ISBN or UPC of the product sold. The maximum character length is 64.
metadatamixedoptional
Provide any data you like, for example a string or a JSON object. We will save the data alongside the order line. Whenever you fetch the order with our API, we will also include the metadata. You can use up to approximately 1kB.
quantityintconditional

The number of items in the order line.

This field is required when unitPrice, discountAmount, totalAmount, vatAmount or vatRate is also provided in the request.

unitPriceamount objectconditional

The price of a single item including VAT in the order line.

For example: {"currency":"EUR", "value":"89.00"} if the box of LEGO costs €89.00 each.

Can be negative in case of discounts, or zero in case of a free item.

This field is required when quantity, discountAmount, totalAmount, vatAmount or vatRate is also provided in the request.

discountAmountamount objectoptional

Any discounts applied to the order line. For example, if you have a two-for-one sale, you should pass the amount discounted as a positive amount.

For example: {"currency":"EUR", "value":"10.00"} if you want to give a €10.00 discount on this order line.

totalAmountamount objectconditional

The total amount of the line, including VAT and discounts. Adding all totalAmount values together should result in the same amount as the amount top level property.

For example: {"currency":"EUR", "value":"168.00"} if the total amount of this order line is €168.00.

The total amount should match the following formula: (unitPrice × quantity) - discountAmount

This field is required when quantity, unitPrice, discountAmount, vatAmount or vatRate is also provided in the request.

vatAmountamount objectconditional

The amount of value-added tax on the line. The totalAmount field includes VAT, so the vatAmount can be calculated with the formula totalAmount × (vatRate / (100 + vatRate)).

Any deviations from this will result in an error.

For example, for a totalAmount of SEK100.00 with a 25.00% VAT rate you would get a VAT amount of 100.00 × (25 / 125) = SEK20.00. The amount should be passed as an amount object, so: {"currency":"SEK", "value":"20.00"}.

This field is required when quantity, unitPrice, discountAmount, totalAmount or vatRate is also provided in the request.

vatRatestringconditional

The VAT rate applied to the order line, for example "21.00" for 21%. The vatRate should be passed as a string and not as a float to ensure the correct number of decimals are passed.

This field is required when quantity, unitPrice, discountAmount, totalAmount or vatAmount is also provided in the request.

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.

testmodebooleanoptional

Response

200 application/hal+json

An order object is returned, as described in Get order.

Example

cURLPHPPythonRubyNode.js
 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
curl -X PATCH https://api.mollie.com/v2/orders/ord_pbjz8x/lines/odl_dgtxyl \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" \
   -d '{
         "name": "LEGO 71043 Hogwarts™ Castle",
         "productUrl": "https://shop.lego.com/en-GB/product/Hogwarts-Castle-71043",
         "imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/71043_alt1?$main$",
         "quantity": 2,
         "vatRate": "21.00",
         "unitPrice": {
            "currency": "EUR",
            "value": "349.00"
         },
         "totalAmount": {
            "currency": "EUR",
            "value": "598.00"
         },
         "discountAmount": {
            "currency": "EUR",
            "value": "100.00"
         },
         "vatAmount": {
            "currency": "EUR",
            "value": "103.79"
         }
   }'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
from mollie.api.client import Client

mollie_client = Client()
mollie_client.set_api_key('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')

order = mollie_client.orders.get('ord_pbjz8x')
order = order.update_line(
    'odl_dgtxyl',
    data={
'name': 'LEGO 71043 Hogwarts™ Castle',
        'productUrl': 'https://shop.lego.com/en-GB/product/Hogwarts-Castle-71043',
        'imageUrl': 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/71043_alt1?$main$',
        'quantity': 2,
        'vatRate': '21.00',
        'unitPrice': {'currency': 'EUR', 'value': '349.00'},
        'totalAmount': {'currency': 'EUR', 'value': '598.00'},
        'discountAmount': {'currency': 'EUR', 'value': '100.00'},
        'vatAmount': {'currency': 'EUR', 'value': '103.79'},
    },
)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
const { createMollieClient } = require('@mollie/api-client');
const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  const order = await mollieClient.orders_lines.update('odl_dgtxyl', {
    orderId: 'ord_pbjz8x',
    name: 'LEGO 71043 Hogwarts™ Castle',
    productUrl: 'https://shop.lego.com/en-GB/product/Hogwarts-Castle-71043',
    imageUrl: 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/71043_alt1?$main$',
  });
})();
1
2
3
4
We don't have a PHP 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 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

Response

  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
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
HTTP/1.1 200 OK
Content-Type: application/hal+json

{
   "resource":"order",
   "id":"ord_pbjz8x",
   "profileId":"pfl_URR55HPMGx",
   "method":"ideal",
   "amount":{
      "value":"927.99",
      "currency":"EUR"
   },
   "status":"created",
   "isCancelable":true,
   "metadata":null,
   "createdAt":"2018-08-02T09:29:56+00:00",
   "expiresAt":"2018-08-30T09:29:56+00:00",
   "mode":"live",
   "locale":"nl_NL",
   "billingAddress":{
      "organizationName":"Mollie B.V.",
      "streetAndNumber":"Keizersgracht 126",
      "city":"Amsterdam",
      "region":"Noord-Holland",
      "postalCode":"1234AB",
      "country":"NL",
      "title":"Dhr",
      "givenName":"Piet",
      "familyName":"Mondriaan",
      "email":"piet@mondriaan.com",
      "phone":"+31208202070"
   },
   "orderNumber":"18475",
   "shippingAddress":{
      "organizationName":"Mollie B.V.",
      "streetAndNumber":"Keizersgracht 126",
      "postalCode":"1015 CW",
      "city":"Amsterdam",
      "country":"nl",
      "givenName":"Luke",
      "familyName":"Skywalker",
      "email":"luke@skywalker.com"
   },
   "redirectUrl":"https://example.org/redirect",
   "lines":[
      {
         "resource":"orderline",
         "id":"odl_dgtxyl",
         "orderId":"ord_pbjz8x",
         "name":"LEGO 71043 Hogwarts™ Castle",
         "sku":"5702016116977",
         "type":"physical",
         "status":"created",
         "metadata":null,
         "isCancelable":false,
         "quantity":2,
         "quantityShipped":0,
         "amountShipped":{
            "value":"0.00",
            "currency":"EUR"
         },
         "quantityRefunded":0,
         "amountRefunded":{
            "value":"0.00",
            "currency":"EUR"
         },
         "quantityCanceled":0,
         "amountCanceled":{
            "value":"0.00",
            "currency":"EUR"
         },
         "shippableQuantity":0,
         "refundableQuantity":0,
         "cancelableQuantity":0,
         "unitPrice":{
            "currency":"EUR",
            "value":"349.00"
         },
         "totalAmount":{
            "currency":"EUR",
            "value":"598.00"
         },
         "discountAmount":{
            "currency":"EUR",
            "value":"100.00"
         },
         "vatAmount":{
            "currency":"EUR",
            "value":"103.79"
         },
         "createdAt":"2018-08-02T09:29:56+00:00",
         "_links":{
            "productUrl":{
               "href":"https://shop.lego.com/en-GB/product/Hogwarts-Castle-71043",
               "type":"text/html"
            },
            "imageUrl":{
               "href":"https://sh-s7-live-s.legocdn.com/is/image//LEGO/71043_alt1?$main$",
               "type":"text/html"
            }
         }
      },
      {
         "resource":"orderline",
         "id":"odl_jp31jz",
         "orderId":"ord_pbjz8x",
         "name":"LEGO 42056 Porsche 911 GT3 RS",
         "sku":"5702015594028",
         "type":"physical",
         "status":"created",
         "metadata":null,
         "isCancelable":false,
         "quantity":1,
         "quantityShipped":0,
         "amountShipped":{
            "value":"0.00",
            "currency":"EUR"
         },
         "quantityRefunded":0,
         "amountRefunded":{
            "value":"0.00",
            "currency":"EUR"
         },
         "quantityCanceled":0,
         "amountCanceled":{
            "value":"0.00",
            "currency":"EUR"
         },
         "shippableQuantity":0,
         "refundableQuantity":0,
         "cancelableQuantity":0,
         "unitPrice":{
            "value":"329.99",
            "currency":"EUR"
         },
         "vatRate":"21.00",
         "vatAmount":{
            "value":"57.27",
            "currency":"EUR"
         },
         "totalAmount":{
            "value":"329.99",
            "currency":"EUR"
         },
         "createdAt":"2018-08-02T09:29:56+00:00",
         "_links":{
            "productUrl":{
               "href":"https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
               "type":"text/html"
            },
            "imageUrl":{
               "href":"https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
               "type":"text/html"
            }
         }
      }
   ],
   "_links":{
      "self":{
         "href":"https://api.mollie.com/v2/orders/ord_pbjz8x",
         "type":"application/hal+json"
      },
      "checkout":{
         "href":"https://www.mollie.com/payscreen/order/checkout/pbjz8x",
         "type":"text/html"
      },
      "dashboard": {
          "href": "https://www.mollie.com/dashboard/org_123456789/orders/ord_pbjz8x",
          "type": "text/html"
      },
      "documentation":{
         "href":"https://docs.mollie.com/reference/v2/orders-api/get-order",
         "type":"text/html"
      }
   }
}