Mollie API Client for Python
raw JSON → 4.0.0 verified Fri May 01 auth: no python
Official Mollie API client for Python. Provides synchronous and asynchronous access to Mollie's payment, subscription, order, and other resources. Latest version 4.0.0 drops support for Python 3.8 and 3.9. Releases are ongoing, with several patches per year.
pip install mollie-api-python Common errors
error ImportError: cannot import name 'MollieClient' from 'mollie' ↓
cause Incorrect import path; MollieClient is in mollie.api.client, not directly in mollie.
fix
from mollie.api.client import MollieClient
error AttributeError: 'NoneType' object has no attribute 'id' ↓
cause Pagination next() returned None but code tried to access .id.
fix
Check if the result is not None before accessing attributes.
error mollie.api.error.Error: Invalid API key ↓
cause API key missing or incorrect; usually due to empty environment variable or wrong key format.
fix
Set MOLLIE_API_KEY environment variable to a valid API key (test or live).
Warnings
breaking Version 4.0.0 drops support for Python 3.8 and 3.9. Users on those versions must pin to 3.9.1 or earlier. ↓
fix Upgrade Python to 3.10+ or pin mollie-api-python to <4.0.0.
deprecated The 'testmode' parameter must be passed as a boolean (not a string) to avoid incorrect behavior. In older versions, testmode might not be sent correctly on POST/PATCH/DELETE. ↓
fix Always pass testmode as a boolean, e.g., 'testmode': True. Upgrade to 3.7.4+ for proper handling.
gotcha When using pagination, the 'next()' method may return None instead of raising an exception. Ensure you check for None before accessing properties. ↓
fix Check if result is not None before accessing attributes.
Imports
- MollieClient wrong
from mollie import MollieClientcorrectfrom mollie.api.client import MollieClient - Payment wrong
from mollie import Paymentcorrectfrom mollie.api.resources.payment import Payment
Quickstart
import os
from mollie.api.client import MollieClient
client = MollieClient()
client.set_api_key(os.environ.get('MOLLIE_API_KEY', 'test_dHar4XY7LxsDOt2kVbK0GPLH4eLkgR'))
# Create a payment
payment = client.payments.create({
'amount': {'currency': 'EUR', 'value': '10.00'},
'description': 'Order #12345',
'redirectUrl': 'https://example.com/return',
'webhookUrl': 'https://example.com/webhook'
})
print(f'Payment created: {payment.id}')