Changeset 12454 for main/waeup.ikoba/trunk/src/waeup/ikoba
- Timestamp:
- 12 Jan 2015, 15:19:54 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/payments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/paypal.py
r12453 r12454 1142 1142 """Store `paypal_credit_card` in vault. 1143 1143 1144 Returns a credit card token in case of success. 1144 Returns a credit card token in case of success. Otherwise an 1145 IOError is raised. 1145 1146 1146 1147 `paypal_credit_card` must provide `ICreditCard`. The credit 1147 1148 card created is stored at PayPal and gets a token stored 1148 locally .1149 1150 If no `creditcards` are available in local site, we create a1151 c ontainer.1149 locally (in site['creditcards']). 1150 1151 If no `creditcards` folder is available in local site, we 1152 create a new container. 1152 1153 """ 1153 1154 site = grok.getSite() 1154 1155 if not 'creditcards' in site: 1155 1156 site['creditcards'] = grok.Container() 1156 return 1157 pp_credit_card = paypalrestsdk.CreditCard( 1158 paypal_credit_card.to_dict()) 1159 result = pp_credit_card.create() 1160 if not result: 1161 # error 1162 raise IOError(pp_credit_card.error) 1163 result = CreditCardToken( 1164 pp_credit_card.id, pp_credit_card.payer_id, 1165 pp_credit_card.number, pp_credit_card.type, 1166 pp_credit_card.expire_month, pp_credit_card.expire_year 1167 ) 1168 site['creditcards'][pp_credit_card.payer_id] = result 1169 return result 1157 1170 1158 1171 def create_payment(self, payer, payment_item, payee=None): -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_paypal.py
r12453 r12454 1156 1156 assert service.get_credit_card(u'CARD2') is None 1157 1157 1158 def test_store_credit_card_no_credcard_container(self): 1159 # a missing creditcards container is created on-the-fly 1158 @external_paypal_test 1159 def test_store_credit_card(self): 1160 # we can (and must) store credit card data online. 1160 1161 site = self.create_site() 1161 1162 assert 'creditcards' not in site 1162 1163 service = PayPalCreditCardService() 1163 1164 credit_card = self.get_credit_card() 1164 service.store_credit_card(credit_card) 1165 result = service.store_credit_card(credit_card) 1166 # a missing creditcards container is created on-the-fly 1165 1167 assert 'creditcards' in site 1168 assert ICreditCardToken.providedBy(result) 1169 assert result.payer_id in site['creditcards'] 1170 assert site['creditcards'][result.payer_id] == result 1171 1172 @external_paypal_test 1173 def test_store_credit_card_invalid(self): 1174 # an exception is raised with invalid credit cards. 1175 site = self.create_site() 1176 service = PayPalCreditCardService() 1177 credit_card = CreditCard( 1178 number=u"12345678", 1179 credit_card_type="visa", 1180 expire_month=4, 1181 expire_year=2012, 1182 ) 1183 self.assertRaises( 1184 IOError, service.store_credit_card, credit_card) 1166 1185 1167 1186 def test_create_payment_no_credictard(self):
Note: See TracChangeset for help on using the changeset viewer.