Index: /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/paypal.py
===================================================================
--- /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/paypal.py	(revision 12014)
+++ /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/paypal.py	(revision 12014)
@@ -0,0 +1,58 @@
+## $Id$
+##
+## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+import ConfigParser
+import paypalrestsdk
+from zope.component import queryUtility
+from waeup.ikoba.interfaces import IPayPalConfig
+
+
+def parse_paypal_config(path):
+    """Get paypal credentials from config file.
+    """
+    parser = ConfigParser.SafeConfigParser(
+        {'id': None, 'secret': None, 'mode': 'sandbox', }
+        )
+    parser.readfp(open(path))
+    return {
+        'client_id': parser.get('rest-client', 'id', None),
+        'client_secret': parser.get('rest-client', 'secret', None),
+        'mode': parser.get('rest-client', 'mode', 'sandbox')
+        }
+
+
+def get_paypal_config_file_path():
+    """Get the path of the configuration file (if any).
+
+    If no such file is registered, we get `None`.
+    """
+    util = queryUtility(IPayPalConfig)
+    if util is None:
+        return None
+    return util['path']
+
+
+def get_access_token():
+    """Get an access token for further calls.
+    """
+    conf = parse_paypal_config(get_paypal_config_file_path())
+    api = paypalrestsdk.set_config(
+        mode=conf['mode'],  # sandbox or live
+        client_id=conf['client_id'],
+        client_secret=conf['client_secret'],
+        )
+    return api.get_access_token()
