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 | ## |
---|
18 | import ConfigParser |
---|
19 | import grok |
---|
20 | from zope.component import queryUtility |
---|
21 | from zope.interface import implementer |
---|
22 | from kofacustom.nigeria.paypal.interfaces import IPaypalConfig |
---|
23 | |
---|
24 | VERIFY_URL_PROD = 'https://ipnpb.paypal.com/cgi-bin/webscr' |
---|
25 | VERIFY_URL_TEST = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr' |
---|
26 | VALID_PAYPAL_EMAILS = [ |
---|
27 | "sample_biz@paypal.com", |
---|
28 | ] |
---|
29 | |
---|
30 | |
---|
31 | def 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 | } |
---|