Changeset 12496 for main/waeup.ikoba/trunk
- Timestamp:
- 20 Jan 2015, 05:57:59 (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
r12494 r12496 300 300 ) 301 301 302 payer_id = schema.TextLine(302 external_customer_id = schema.TextLine( 303 303 title=u'Payer ID', 304 304 description=(u'A unique identifier for the credit card. This ' … … 390 390 data. Required if using a stored credit card. 391 391 392 ` payer_id`: Unique identifier. If none is given, we assign a393 uuid. The uuid reads 'PAYER_<32 hex digits>'.392 `external_customer_id`: Unique identifier. If none is given, we 393 assign a uuid. The uuid reads 'PAYER_<32 hex digits>'. 394 394 395 395 `number`: Credit card number. Numeric characters only with no … … 426 426 grok.implements(ICreditCard) 427 427 428 def __init__(self, paypal_id=None, payer_id=None, number=None, 429 credit_card_type=None, expire_month=1, expire_year=2000, 430 cvv2=None, first_name=None, last_name=None, 431 billing_address=None, state=None, paypal_valid_until=None): 428 def __init__(self, paypal_id=None, external_customer_id=None, 429 number=None, credit_card_type=None, expire_month=1, 430 expire_year=2000, cvv2=None, first_name=None, 431 last_name=None, billing_address=None, state=None, 432 paypal_valid_until=None): 432 433 if not re.match('^[0-9]+$', number): 433 434 raise ValueError("Credit card number may " 434 435 "not contain non-numbers.") 435 if payer_id is None:436 payer_id = u'PAYER_' + unicode(uuid.uuid4().hex)436 if external_customer_id is None: 437 external_customer_id = u'PAYER_' + unicode(uuid.uuid4().hex) 437 438 self.paypal_id = paypal_id 438 self. payer_id = payer_id439 self.external_customer_id = external_customer_id 439 440 self.number = number 440 441 self.credit_card_type = credit_card_type … … 1189 1190 1190 1191 def create_payment(self, payer, payment_item, payee=None): 1192 """Create a creditcard payment. 1193 1194 XXX: payer_id is deprecated by paypal: use 1195 XXX: external_customer_id instead (also when creating credit cards). 1196 XXX: This is a Good Thing(tm) because `payer_id` is already used in 1197 XXX: some parts of the API for PayPal-assigned values. 1198 """ 1191 1199 if not IPayer.providedBy(payer): 1192 1200 payer = IPayer(payer) -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_paypal.py
r12494 r12496 286 286 ) 287 287 assert credit_card.paypal_id is None 288 assert credit_card. payer_id is not None288 assert credit_card.external_customer_id is not None 289 289 assert credit_card.number == u"12345678" 290 290 assert credit_card.credit_card_type == "visa" … … 298 298 assert credit_card.paypal_valid_until is None 299 299 300 def test_ payer_id_given(self):301 # we do not override given payer ids300 def test_external_customer_id_given(self): 301 # we do not override given curstomer ids 302 302 credit_card = CreditCard( 303 303 number=u"12345678", … … 305 305 expire_month=4, 306 306 expire_year=2012, 307 payer_id=u'MySpecialPayerId',308 ) 309 assert credit_card. payer_id == u'MySpecialPayerId'310 311 def test_ payer_id_not_given(self):312 # in case no payer id is given, we generate one307 external_customer_id=u'MySpecialPayerId', 308 ) 309 assert credit_card.external_customer_id == u'MySpecialPayerId' 310 311 def test_external_customer_id_not_given(self): 312 # in case no customer id is given, we generate one 313 313 credit_card = CreditCard( 314 314 number=u"12345678", … … 317 317 expire_year=2012, 318 318 ) 319 # our payer ids contain a leading 'PAYER_' and 32 hex digits 320 assert re.match('PAYER_[0-9a-f]{32}$', credit_card.payer_id) 319 # our customer ids contain a leading 'PAYER_' and 32 hex digits 320 assert re.match( 321 'PAYER_[0-9a-f]{32}$', credit_card.external_customer_id) 321 322 322 323 def test_number_is_checked(self): … … 340 341 credit_card = CreditCard( 341 342 credit_card_type=u"visa", 342 payer_id=u"PAYER_0123456789012345678901",343 external_customer_id=u"PAYER_0123456789012345678901", 343 344 number=u"4417119669820331", 344 345 expire_month=11, … … 353 354 "type": u"visa", 354 355 "number": u"4417119669820331", 355 " payer_id": u"PAYER_0123456789012345678901",356 "external_customer_id": u"PAYER_0123456789012345678901", 356 357 "expire_month": u"11", 357 358 "expire_year": u"2018", … … 1213 1214 result = payment.create() 1214 1215 assert result is True 1216 1217 ### 1218 ### hier gehts weiter 1215 1219 1216 1220
Note: See TracChangeset for help on using the changeset viewer.