Create order payment

Orders API v2
POSThttps://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 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|array
optional

Normally, 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", "inghomepay"].

Possible values: bancontact banktransfer belfius bitcoin creditcard directdebit eps giftcard giropay ideal inghomepay kbc klarnapaylater klarnasliceit paypal paysafecard przelewy24 sofort

customerId

string
optional
The ID of the Customer for whom the payment is being created. This is used for recurring payments and single click payments.

mandateId

string
optional
When creating recurring payments, the ID of a specific Mandate may be supplied to indicate which of the consumer’s accounts should be credited.

You 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"
}

Access token parameters

If you are using organization access tokens or are creating an OAuth app, the only mandatory extra parameter is the testmode parameter. This is only the case for test orders. For live orders the testmode parameter can be omitted.

testmode

boolean
optional
If the new payment is for a test order this parameter is required and you have to set this to true.

applicationFee

object
optional
Adding an application fee allows you to charge the merchant a small sum for the payment and transfer this to your own account.

Response

201 application/hal+json

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

Example

cURLPHPPythonRubyNode.js
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
We don't have a Python 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
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 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
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"
        },
        "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"
         }
     }
 }