mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
550 stars 189 forks source link

Add update multiple order lines #654

Closed sandervanhooft closed 1 year ago

sandervanhooft commented 1 year ago
$mollie = new Mollie\Api\MollieApiClient;
$mollie->setApiKey('...');

$operations = [
                  [
                      "operation" => "update",
                      "data" => [
                          "id" => "odl_1.1l9vx0",
                          "name" => "New order line name",
                      ],
                  ],
                  [
                      "operation" => "cancel",
                      "data" => [
                          "id" => "odl_1.4hqjw6",
                      ],
                  ],
                  [
                      "operation" => "add",
                      "data" => [
                          "name" => "Adding new orderline",
                          "quantity" => 2,
                          "sku" => "12345679",
                          "totalAmount" => [
                              "currency" => "EUR",
                              "value" => "30.00",
                          ],
                          "type" => "digital",
                          "unitPrice" => [
                              "currency" => "EUR",
                              "value" => "15.00",
                          ],
                          "vatAmount" => [
                              "currency" => "EUR",
                              "value" => "0.00",
                          ],
                          "vatRate" => "0.00",
                      ],
                  ],
              ];

$order = $mollie->orderLines->updateMultiple($orderId, $operations);
sandervanhooft commented 1 year ago

@fjbender what do you think?

Note the updateMultiple signature and that the operations array is accepted directly instead of the full payload.