Create order payment¶
POST
https://api.mollie.com/v2/orders/*orderId*/payments
An order has an automatically created payment that your customer can use to pay for the order. When the payment expires you can create a new payment for the order using this endpoint. A maximum of 25 payments can be created for an order.
A new payment can only be created while the status of the order is created
, and when the status
of the existing payment is either expired
, canceled
or failed
.
Note that order details (for example amount
or webhookUrl
) can not be changed using this endpoint.
Parameters¶
Replace orderId
in the endpoint URL by the order’s ID, for example ord_8wmqcHMN4U
.
method
string|arrayoptionalNormally, a payment method screen is shown. However, when using this parameter, you can choose a specific payment method and your customer will skip the selection screen and is sent directly to the chosen payment method. The parameter enables you to fully integrate the payment method selection into your website.
You can also specify the methods in an array. By doing so we will still show the payment method selection screen but
will only show the methods specified in the array. For example, you can use this functionality to only show payment
methods from a specific country to your customer ["bancontact", "belfius"]
.
Possible values: applepay
bancontact
banktransfer
belfius
billie
creditcard
directdebit
eps
giftcard
giropay
ideal
in3
kbc
klarnapaylater
klarnapaynow
klarnasliceit
paypal
paysafecard
przelewy24
sofort
customerId
stringoptionalmandateId
stringoptionalYou can specify the same payment parameters as in the
Create order endpoint. Note that the parameters should not be
specified in a payment
object, but at the same level as the method
parameter.
For example:
1 2 3 4 | { "method": "ideal", "issuer": "ideal_INGBNL2A" } |
Note
When the payment webhook
parameter is not specified it is copied from the previous order
payment (if it was set).
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
.Example¶
1 2 3 4 5 6 | curl -X POST https://api.mollie.com/v2/orders/ord_stTC2WHAuS/payments \ -H "Content-Type: application/json" \ -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" \ -d '{ "method": "banktransfer" }' |
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php $mollie = new \Mollie\Api\MollieApiClient(); $mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"); $order = $mollie->orders->get("ord_stTC2WHAuS"); $payment = $order->createPayment([ "method" => "banktransfer", ]); $checkoutUrl = $payment->getCheckoutUrl(); if(! is_null($checkoutUrl)) { // ... redirect the customer to the checkout url } |
1 2 3 4 5 6 7 8 9 | from mollie.api.client import Client mollie_client = Client() mollie_client.set_api_key("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM") order = mollie_client.orders.get("ord_stTC2WHAuS") payment = order.payments.create({ "method": "banktransfer", }) |
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 share suggestions on our Discord: https://discord.gg/VaTVkXB4aQ |
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 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 | HTTP/1.1 201 Created Content-Type: application/hal+json { "resource": "payment", "id": "tr_WDqYK6vllg", "mode": "test", "amount": { "currency": "EUR", "value": "698.00" }, "status": "open", "description": "Order #1337 (Lego cars)", "createdAt": "2018-12-01T17:09:02+00:00", "method": "banktransfer", "metadata": null, "orderId": "ord_stTC2WHAuS", "isCancelable": true, "locale": "nl_NL", "profileId": "pfl_URR55HPMGx", "sequenceType": "oneoff", "settlementAmount": { "value": "698.00", "currency": "EUR" }, "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg", "type": "application/hal+json" }, "order": { "href": "https://api.mollie.com/v2/orders/ord_stTC2WHAuS", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/paymentscreen/testmode/?method=banktransfer&token=fgnwdh", "type": "text/html" }, "dashboard": { "href": "https://www.mollie.com/dashboard/org_123456789/payments/tr_WDqYK6vllg", "type": "text/html" }, "status": { "href": "https://www.mollie.com/paymentscreen/banktransfer/status/fgnwdh", "type": "text/html" }, "payOnline": { "href": "https://www.mollie.com/paymentscreen/banktransfer/pay-online/fgnwdh", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/orders-api/create-order-payment", "type": "text/html" } } } |
Response (order is already completed)¶
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": "Cannot create a new payment for order ord_stTC2WHAuS when the order status is \"completed\".", "_links": { "documentation": { "href": "https://docs.mollie.com/reference/v2/orders-api/create-order-payment", "type": "text/html" } } } |