Mollie API: simple & powerful

Use the Mollie API to integrate online payments by Mollie directly into your website or app. Mollie and your website will communicate by sending HTTP requests back and forth.

This page provides an overview of the Mollie API. The topics in the chapter deal with a number of specific aspects of the API. We recommend to read these topics entirely.

If possible it would be wise to leave communication at this level to our ready-made Clients. This allows you to still be in control without reinventing the wheel.

If you have any questions about integrating our API, please contact us. We’re happy to help!

Clients, modules and plugins

Well begun is half done. Save time and build on solid foundations. Mollie API clients are available for PHP, Ruby, Node.js and Python.

Of course we also provide modules and plugins for about every webshop software out there.

Payment methods

Mollie is always adding new payment methods. The Mollie API currently supports these payments methods:

All of the payment methods you have enabled are – where relevant – shown to the consumer. You can enable payment methods using the Dashboard.

How does the Mollie API work?

_images/api-overview-flow@2x.png
  1. A customer on your website decides to checkout.

  2. Your website creates a payment on the Mollie platform by calling the Mollie API with the amount, a payment description, a webhook URL, and a URL we should redirect the customer to after the payment is made.

    The API responds with the unique id and the _links.checkout URL for the newly created payment. Your website stores the id, links it to the customer’s order and redirects the customer to the URL in the _links.checkout property from the Mollie API response. This is the URL to the hosted payment page for this specific payment.

    Note

    You should use HTTP GET for the redirect to the _links.checkout URL. Using HTTP POST for redirection will cause issues with some payment methods or iDEAL issuers. Use HTTP status code 303 See Other to force an HTTP GET redirect.

  3. The customer reaches the checkout, chooses a payment method and makes the payment. This process is entirely taken care of by Mollie. You don’t need to do anything here.

  4. When the payment is made Mollie will call your webhook informing your website about the payment’s status change. You should define a webhook when creating the payment.

    In response to your webhook being called your application just needs to issue a 200 OK status. From that response Mollie can tell that your processing of the new status was successful – for any other response we keep trying.

  5. Processing the webhook request your website fetches the payment status using the Mollie API. This fetched status serves to mark the order as paid, trigger fulfilment and send out an email confirmation to the customer.

  6. At this point Mollie returns the visitor to your website using the redirectUrl specified when the payment was created. Your website already knows the payment was successful and thanks the customer.

Connecting orders and payments

In the example above we suppose you will store the id that’s unique to the payment in your order table. This way your website is able to look-up the order for this payment when the webhook is triggered by Mollie. Your website is keeping track of the payment, effectively bringing about the connection between order and payment. This approach is easiest to grasp, which is why we use it in our example.

Alternatively you could ask Mollie to remember the unique identifier of your order by instructing the Mollie API to store it in the payment’s metadata. You would provide it while creating the payment. In our example order_id would be a good candidate. Mollie stores the metadata for you, when you fetch the payment during processing the webhook the metadata is included in the response. This is another way to connect orders and payments. We advise to use the metadata approach. This is the most popular approach and it’s easiest to implement.