Mollie.Orders (mollie v0.7.2)
Using the Orders API is the preferred approach when integrating the Mollie API into e-commerce applications such as webshops. If you want to use 'pay after delivery' methods such as Klarna Pay later, using the Orders API is mandatory.
Link to this section Summary
Functions
Cancels the order if the order’s status
field is either created
, authorized
or shipping
.
Creates an order.
Creating an order will automatically create the required payment
to allow your customer to pay for the order.
Once you have created an order, you should redirect your customer to
the URL in the _links.checkout
property from the response.
Retrieve a single order by its ID.
Retrieve all orders. Results are paginated
Update the billing and/or shipping address of an order.
Link to this section Functions
cancel(client, id, params \\ %{})
Specs
cancel(Mollie.Client.t(), binary(), map()) :: Mollie.response()
Cancels the order if the order’s status
field is either created
, authorized
or shipping
.
example
Example
Mollie.Orders.cancel client, "ord_8wmqcHMN4U"
More info at: https://docs.mollie.com/reference/v2/orders-api/cancel-order
create(client, body)
Specs
create(Mollie.Client.t(), map()) :: Mollie.response()
Creates an order.
Creating an order will automatically create the required payment
to allow your customer to pay for the order.
Once you have created an order, you should redirect your customer to
the URL in the _links.checkout
property from the response.
Order body example
%{
"amount" => %{
"currency" => "EUR",
"value" => "100.00"
},
"orderNumber" => "23302",
"lines" => [
%{
"name" => "LEGO 4440 Forest Police Station",
"quantity" => 1,
"unitPrice" => %{
"currency" => "EUR",
"value" => "79.00"
},
"totalAmount" => %{
"currency" => "EUR",
"value" => "100.00"
},
"vatRate" => "21.00",
"vatAmount" => %{
"currency" => "EUR",
"value" => "21.00"
}
}
],
"billingAddress" => %{
"givenName" => "Piet",
"familyName" => "Mondriaan",
"email" => "pm@example.com",
"streetAndNumber" => "Keizersgracht 313",
"city" => "Amsterdam",
"region" => "Noord-Holland",
"postalCode" => "1234AB",
"country" => "NL",
},
"redirectUrl" => "https://example.com/redirect",
"locale" => "nl_NL"
}
example
Example
Mollie.Orders.create client, order_body
More info at: https://docs.mollie.com/reference/v2/orders-api/create-order
find(client, id, params \\ %{})
Specs
find(Mollie.Client.t(), binary(), map()) :: Mollie.response()
Retrieve a single order by its ID.
example
Example
Mollie.Orders.find client, "ord_8wmqcHMN4U"
More info at: https://docs.mollie.com/reference/v2/orders-api/get-order
list(client, params \\ %{})
Specs
list(Mollie.Client.t(), map()) :: Mollie.response()
Retrieve all orders. Results are paginated
example
Example
Mollie.Orders.list client
More info at: https://docs.mollie.com/reference/v2/orders-api/list-orders
update(client, id, body)
Specs
update(Mollie.Client.t(), binary(), map()) :: Mollie.response()
Update the billing and/or shipping address of an order.
Update body example
%{
"shippingAddress" => %{
"givenName" => "Piet",
"familyName" => "Mondriaan",
"email" => "pm@example.com",
"streetAndNumber" => "Keizersgracht 313",
"city" => "Amsterdam",
"region" => "Noord-Holland",
"postalCode" => "1234AB",
"country" => "NL"
}
}
example
Example
Mollie.Orders.update client, "ord_8wmqcHMN4U", update_body
More info at: https://docs.mollie.com/reference/v2/orders-api/update-order