Changeset 12453 for main/waeup.ikoba/trunk
- Timestamp:
- 12 Jan 2015, 14:33:22 (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
r12326 r12453 1139 1139 return site['creditcards'].get(payer_id, None) 1140 1140 1141 def store_credit_card(self, paypal_credit_card): 1142 """Store `paypal_credit_card` in vault. 1143 1144 Returns a credit card token in case of success. 1145 1146 `paypal_credit_card` must provide `ICreditCard`. The credit 1147 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 a 1151 container. 1152 """ 1153 site = grok.getSite() 1154 if not 'creditcards' in site: 1155 site['creditcards'] = grok.Container() 1156 return 1157 1141 1158 def create_payment(self, payer, payment_item, payee=None): 1142 1159 if not IPayer.providedBy(payer): -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_paypal.py
r12326 r12453 1100 1100 return site 1101 1101 1102 def get_credit_card(self): 1103 # get a valid credit card 1104 credit_card = CreditCard( 1105 credit_card_type=u"visa", 1106 payer_id=u"PAYER_0123456789012345678901", 1107 number=u"4417119669820331", 1108 expire_month=11, 1109 expire_year=2018, 1110 cvv2=u"874", 1111 first_name=u"Joe", 1112 last_name=u"Shopper", 1113 ) 1114 return credit_card 1115 1102 1116 def test_iface(self): 1103 1117 # we fullfill all interface contracts … … 1127 1141 def test_get_credit_card(self): 1128 1142 # we can get a credit card, if one was stored 1129 class MyCard( grok.Model):1143 class MyCard(object): 1130 1144 myid = 'CARD1' 1131 1145 … … 1136 1150 site['creditcards'] = grok.Container() 1137 1151 card = MyCard() 1138 card.myid = 'CHANGED ID'1152 card.myid = 'CHANGED CARD ID' 1139 1153 site['creditcards'][u'CARD1'] = card 1140 1154 service = PayPalCreditCardService() 1141 1155 assert service.get_credit_card(u'CARD1') == card 1142 1156 assert service.get_credit_card(u'CARD2') is None 1157 1158 def test_store_credit_card_no_credcard_container(self): 1159 # a missing creditcards container is created on-the-fly 1160 site = self.create_site() 1161 assert 'creditcards' not in site 1162 service = PayPalCreditCardService() 1163 credit_card = self.get_credit_card() 1164 service.store_credit_card(credit_card) 1165 assert 'creditcards' in site 1143 1166 1144 1167 def test_create_payment_no_credictard(self):
Note: See TracChangeset for help on using the changeset viewer.