Mollie API client for Python
Python Makefile Shell
Clone or download


Mollie API client for Python

Accepting iDEAL, Bancontact/Mister Cash, SOFORT Banking, Creditcard, SEPA Bank transfer, SEPA Direct debit, Bitcoin, PayPal, Belfius Direct Net, paysafecard and ING Home’Pay online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.

PyPI version Build Status


To use the Mollie API client, the following things are required:

  • Get yourself a free Mollie account. No sign up costs.
  • Create a new Website profile to generate API keys and setup your webhook.
  • Now you're ready to use the Mollie API client in test mode.
  • In order to accept payments in live mode, payment methods must be activated in your account. Follow a few steps, and let us handle the rest.
  • Mollie API client for Python has a dependency on Requests.


By far the easiest way to install the Mollie API client is to install it with pip.

$ pip install mollie-api-python

You may also git checkout or download all the files, and include the Mollie API client manually.

How to receive payments

To successfully receive a payment, these steps should be implemented:

  1. Use the Mollie API client to create a payment with the requested amount, description and optionally, a payment method. It is important to specify a unique redirect URL where the customer is supposed to return to after the payment is completed.

  2. Immediately after the payment is completed, our platform will send an asynchronous request to the configured webhook to allow the payment details to be retrieved, so you know when exactly to start processing the customer's order.

  3. The customer returns, and should be satisfied to see that the order was paid and is now being processed.

Getting started

Requiring the Mollie API Client.

import Mollie

Initializing the Mollie API client, and setting your API key.

mollie = Mollie.API.Client()

Creating a new payment.

payment = mollie.payments.create({
    'amount':      10.00,
    'description': 'My first API payment',
    'redirectUrl': '',
    'webhookUrl':  ''

Retrieving a payment.

payment = mollie.payments.get(payment['id'])

if payment.isPaid():
    print 'Payment received.'

How to pass the different parameter types

In the example above, a new payment is created by passing a dictionary of payment data, which corresponds to the data parameter of the mollie.payments.create method. This data will be used as request body in a POST request to Mollie. In general, the methods for POST requests, which accept request body parameters, have a data parameter to provide such request body parameters.

Every keyword argument (other than data) passed to a method will be interpreted as a query string parameter. For example, the following method call:

payments = mollie.payments.all(count=20)

Will result in a request with query string ?count=20. Furthermore, this is an example of a request that only accepts query string parameters. Both can be combined, however, to for example create a payment that includes a QR code object:

payment = mollie.payments.create(
        'amount': 10.00,
        'description': 'My first API payment',
        'redirectUrl': '',
        'webhookUrl': '',
        'method': Method.IDEAL

Fully integrated iDEAL payments

If you want to fully integrate iDEAL payments in your web site, some additional steps are required. First, you need to retrieve the list of issuers (banks) that support iDEAL and have your customer pick the issuer he/she wants to use for the payment.

Retrieve the list of issuers:

issuers = mollie.issuers.all()

issuers will be a list of Mollie.API.Object.Issuer objects. Use the attribute id of this object in the API call, and the attribute name for displaying the issuer to your customer. For a more in-depth example, see Example 4.

Create a payment with the selected issuer:

payment = mollie.payments.create({
    'amount':      10.00,
    'description': 'My first API payment',
    'redirectUrl': '',
    'webhookUrl':  '',
    'method':      Mollie.API.Object.Method.IDEAL,
    'issuer':      selected_issuer_id,  # e.g. 'ideal_INGBNL2A'

The paymentUrl attribute of the payment object will point directly to the online banking environment of the selected issuer.

Refunding payments

The API also supports refunding payments. Note that there is no confirmation and that all refunds are immediate and definitive. Refunds are only supported for iDEAL, credit card and Bank Transfer payments. Other types of payments cannot be refunded through our API at the moment.

payment = mollie.payments.get(payment['id'])
refund = mollie.payments.refund(payment)


To run the examples you need to install Flask. Simply run:

$ cd mollie-api-python
$ pip install Flask 
$ pip install requests 
$ python examples/


BSD (Berkeley Software Distribution) License. Copyright (c) 2014-2018, Mollie B.V.


Contact: — +31 20-612 88 55