-
Notifications
You must be signed in to change notification settings - Fork 49
/
6-list-activated-methods.py
46 lines (35 loc) · 1.21 KB
/
6-list-activated-methods.py
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
# coding=utf-8
#
# Example 6 - How to get the currently activated payment methods.
#
from __future__ import print_function
import sys, os
#
# Add Mollie library to module path so we can import it.
# This is not necessary if you use pip or easy_install.
#
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/../'))
import Mollie
def main():
try:
#
# Initialize the Mollie API library with your API key.
#
# See: https://www.mollie.com/dashboard/settings/profiles
#
mollie = Mollie.API.Client()
mollie.setApiKey('test_bt7vvByF6jTcBR4dLuW66eNnHYNIJp')
#
# Get the all the activated methods for this API key.
#
methods = mollie.methods.all()
body = 'Your API key has %u activated payment methods:<br>' % int(methods['totalCount'])
for method in methods:
body += '<div style="line-height:40px; vertical-align:top">'
body += '<img src="%s"> %s (%s)' % (method['image']['normal'], method['description'], method['id'])
body += '</div>'
return body
except Mollie.API.Error as e:
return 'API call failed: ' + e.message
if __name__ == '__main__':
print(main())