Changeset 12029
- Timestamp:
- 21 Nov 2014, 13:07:57 (10 years ago)
- Location:
- main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/paypal.py
r12026 r12029 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 """Support for PayPal payments. 19 """ 18 20 import ConfigParser 19 21 import paypalrestsdk … … 53 55 54 56 57 def configure_sdk(path): 58 """Configure the PayPal SDK with values from config in `path`. 59 60 Parse paypal configuration from file in `path` and set 61 configuration in SDK accordingly. 62 63 Returns a dict with values from config file and path set. 64 65 This function will normally be called during start-up and only 66 this one time. 67 68 It is neccessary to authorize later calls to other part of the 69 PayPal API. 70 """ 71 conf = parse_paypal_config(path) 72 paypalrestsdk.configure({ 73 'mode': conf['mode'], 74 'client_id': conf['client_id'], 75 'client_secret': conf['client_secret'], 76 }) 77 conf['path'] = path 78 return conf 79 80 55 81 def get_access_token(): 56 82 """Get an access token for further calls. -
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_paypal.py
r12027 r12029 20 20 import tempfile 21 21 import unittest 22 import paypalrestsdk 22 23 from zope.component import getGlobalSiteManager, queryUtility 23 24 from waeup.ikoba.interfaces import IPayPalConfig 24 25 from waeup.ikoba.payments.paypal import ( 25 26 get_paypal_config_file_path, parse_paypal_config, get_access_token, 27 configure_sdk, 26 28 ) 27 29 from waeup.ikoba.testing import ( … … 79 81 assert result['mode'] == "sandbox" 80 82 83 def test_configure_sdk(self): 84 # we can configure the paypal sdk 85 path = os.path.join(self.workdir, 'sample.cfg') 86 open(path, 'w').write( 87 "[rest-client]\n" 88 "id = my-special-id\n" 89 ) 90 result = configure_sdk(path) 91 assert result['client_id'] == 'my-special-id' 92 assert result['client_secret'] is None 93 assert result['mode'] == "sandbox" 94 assert paypalrestsdk.api.__api__.mode == 'sandbox' 95 assert paypalrestsdk.api.__api__.client_id == 'my-special-id' 96 81 97 82 98 class FunctionalPaypalTests(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.