source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/paypal/config.py @ 17246

Last change on this file since 17246 was 17239, checked in by uli, 21 months ago

Sketches of paypal :)

File size: 1.8 KB
Line 
1## $Id$
2##
3## Copyright (C) 2022 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import ConfigParser
19import grok
20from zope.component import queryUtility
21from zope.interface import implementer
22from kofacustom.nigeria.paypal.interfaces import IPaypalConfig
23
24VERIFY_URL_PROD = 'https://ipnpb.paypal.com/cgi-bin/webscr'
25VERIFY_URL_TEST = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr'
26VALID_PAYPAL_EMAILS = [
27        "sample_biz@paypal.com",
28        ]
29
30
31def parse_paypal_config(path):
32    """Get paypal credentials from config file
33
34    This is called on initialisation when the `kofacustomng:paypalconf`
35    directive is set in ZCML configuration.
36
37    Retrieve the respective config with: `getUtility(IPaypalConfig)`
38    """
39    parser = ConfigParser.SafeConfigParser({'id': None, 'secret': None, 'mode': 'sandbox',})
40    with open(path) as fp:
41        parser.readfp(fp)
42    return {
43            'client_id': parser.get('rest-client', 'id', None),
44            'client_secret': parser.get('rest-client', 'secret', None),
45            'mode': parser.get('rest-client', 'mode', 'sandbox'),
46            }
Note: See TracBrowser for help on using the repository browser.