Skip to content

Instantly share code, notes, and snippets.

Created August 10, 2018 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Example: Python Mollie API v2 request (with multicurrency support)
import urllib2
import json
# Construct a request:
payment_data = {
'amount': { 'currency': 'USD', 'value': '2.50'},
'description': 'something',
'redirectUrl': '',
'webhookUrl': '',
'metadata': {
'my_key': 'some value'
# Set opener, headers and method:
opener = urllib2.build_opener(urllib2.HTTPSHandler)
request = urllib2.Request("")
request.add_header('Authorization', 'Bearer ' + MOLLIE_API_KEY)
request.add_header('Content-Type', 'application/json')
request.get_method = lambda: 'POST'
# Send request:
r =
# Check response code and parse the JSON response:
assert r.code == 200
response = json.loads(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment