diff --git a/mangopay/resources.py b/mangopay/resources.py index 5630ac2..2362d6d 100644 --- a/mangopay/resources.py +++ b/mangopay/resources.py @@ -427,6 +427,9 @@ class CardValidation(BaseModel): default=None) result_code = CharField(api_name='ResultCode') result_message = CharField(api_name='ResultMessage') + preferred_card_network = CharField(api_name='PreferredCardNetwork') + authorization_date = DateTimeField(api_name='AuthorizationDate') + card_info = CardInfoField(api_name='CardInfo') def validate(self, card_id, **kwargs): insert = InsertQuery(self, **kwargs) @@ -435,11 +438,19 @@ def validate(self, card_id, **kwargs): insert.identifier = 'CARD_VALIDATE' return insert.execute() + def get_card_validation(self, card_id, *args, **kwargs): + kwargs['card_id'] = card_id + kwargs['id'] = self.id + select = SelectQuery(CardValidation, *args, **kwargs) + select.identifier = 'GET_CARD_VALIDATION' + return select.all(*args, **kwargs) + class Meta: verbose_name = 'card_validation' verbose_name_plural = 'card_validations' url = { - 'CARD_VALIDATE': '/cards/%(id)s/validation' + 'CARD_VALIDATE': '/cards/%(id)s/validation', + 'GET_CARD_VALIDATION': '/cards/%(card_id)s/validation/%(id)s' } diff --git a/tests/test_bankaccounts.py b/tests/test_bankaccounts.py index 9e60bce..78cd1b6 100644 --- a/tests/test_bankaccounts.py +++ b/tests/test_bankaccounts.py @@ -486,6 +486,7 @@ def test_deactivateBankAccount(self): def test_BankAccount_getTransactions(self): account = BaseTestLive.get_johns_account() + time.sleep(2) transactions_page = account.get_transactions() self.assertIsNotNone(transactions_page.data) diff --git a/tests/test_base.py b/tests/test_base.py index 3861ba8..34692bb 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -122,7 +122,7 @@ def card(self): self.mock_tokenization_request() response = requests.post(card_registration.card_registration_url, data={ - 'cardNumber': '4970100000000154', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '0124', 'accessKeyRef': card_registration.access_key, @@ -148,7 +148,7 @@ def natural_user_card(self): self.mock_tokenization_request() response = requests.post(card_registration.card_registration_url, data={ - 'cardNumber': '4970101122334422', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '0124', 'accessKeyRef': card_registration.access_key, @@ -174,7 +174,7 @@ def legal_user_card(self): self.mock_tokenization_request() response = requests.post(card_registration.card_registration_url, data={ - 'cardNumber': '4970101122334406', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '0124', 'accessKeyRef': card_registration.access_key, @@ -539,7 +539,7 @@ def get_johns_card(recreate=False): params = { "data_XXX": card_registration.preregistration_data, "accessKeyRef": card_registration.access_key, - "cardNumber": '4970101122334422', + "cardNumber": '4970107111111119', "cardExpirationDate": '1224', "cardCvx": '123' } @@ -563,7 +563,7 @@ def get_johns_card_3dsecure(recreate=False): params = { "data_XXX": card_registration.preregistration_data, "accessKeyRef": card_registration.access_key, - "cardNumber": '4970105191923460', + "cardNumber": '4970107111111119', "cardExpirationDate": '1224', "cardCvx": '123' } @@ -609,7 +609,7 @@ def create_new_card_registration_for_deposit(): params = { "data_XXX": card_registration.preregistration_data, "accessKeyRef": card_registration.access_key, - "cardNumber": '4970105181818183', + "cardNumber": '4970107111111119', "cardExpirationDate": '1224', "cardCvx": '123' } diff --git a/tests/test_cards.py b/tests/test_cards.py index b58c42d..6c90847 100644 --- a/tests/test_cards.py +++ b/tests/test_cards.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import time + from tests import settings try: @@ -67,7 +69,7 @@ def test_cards_registration(self): # Send card details to the Tokenization server response = requests.post(card_registration.card_registration_url, urlrequest.urlencode({ - 'cardNumber': '4970100000000154', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '0128', 'accessKeyRef': card_registration.access_key, @@ -163,7 +165,7 @@ def test_cards_for_fingerprint(self): self.assertIsNotNone(card_registration.get_pk()) response = requests.post(card_registration.card_registration_url, urlrequest.urlencode({ - 'cardNumber': '4970100000000154', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '0128', 'accessKeyRef': card_registration.access_key, @@ -239,7 +241,7 @@ def test_desactive_card(self): # Send card details to the Tokenization server response = requests.post(card_registration.card_registration_url, urlrequest.urlencode({ - 'cardNumber': '4970100000000154', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '0128', 'accessKeyRef': card_registration.access_key, @@ -273,6 +275,7 @@ def test_getCardPreAuthorizations(self): def test_getCardTransactions(self): card = BaseTestLive.get_johns_card() + time.sleep(2) transactions_page = card.get_transactions() self.assertIsNotNone(transactions_page.data) @@ -312,3 +315,43 @@ def test_cardValidation(self): self.assertIsNotNone(validation_response) self.assertIsNotNone(validation_response['id']) + + def test_getCardValidation(self): + user = BaseTestLive.get_john() + + card_registration = CardRegistration() + card_registration.user = user + card_registration.currency = 'EUR' + + saved_registration = card_registration.save() + data = { + 'cardNumber': '4970107111111119', + 'cardCvx': '123', + 'cardExpirationDate': '1224', + 'accessKeyRef': card_registration.access_key, + 'data': card_registration.preregistration_data + } + headers = { + 'content-type': 'application/x-www-form-urlencoded' + } + registration_data_response = requests.post(card_registration.card_registration_url, data=data, headers=headers) + saved_registration['registration_data'] = registration_data_response.text + updated_registration = CardRegistration(**saved_registration).save() + card_id = updated_registration['card_id'] + + card_validation = CardValidation() + card_validation.author = user + card_validation.tag = "test" + card_validation.secure_mode_return_url = "http://www.example.com/" + card_validation.ip_address = "2001:0620:0000:0000:0211:24FF:FE80:C12C" + card_validation.browser_info = BaseTest.get_browser_info() + + validation_response = card_validation.validate(card_id) + + get_card_validation = CardValidation() + get_card_validation.id = validation_response['id'] + get_card_validation_response = get_card_validation.get_card_validation(card_id) + + self.assertIsNotNone(get_card_validation_response.data[0]) + self.assertIsNotNone(get_card_validation_response.data[0].id) + self.assertEqual(get_card_validation_response.data[0].id, validation_response['id']) diff --git a/tests/test_preauthorizations.py b/tests/test_preauthorizations.py index e06ae01..a9bbe45 100644 --- a/tests/test_preauthorizations.py +++ b/tests/test_preauthorizations.py @@ -676,7 +676,7 @@ def test_PreAuthorizations_CreateWithAvs(self): saved_registration = card_registration.save() data = { - 'cardNumber': '4970105191923460', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '1224', 'accessKeyRef': card_registration.access_key, @@ -729,7 +729,7 @@ def test_PreAuthorizations_CreateDirect(self): saved_registration = card_registration.save() data = { - 'cardNumber': '4970105191923460', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '1224', 'accessKeyRef': card_registration.access_key, @@ -782,6 +782,7 @@ def test_PreAuthorizations_CreateDirect(self): payin.culture = 'fr' BaseTestLive._johns_payin = PreAuthorizedPayIn(**payin.save()) + time.sleep(2) transactions = pre_authorization.get_transactions() self.assertIsNotNone(saved_pre_authorization) @@ -799,7 +800,7 @@ def test_PreAuthorizations_CheckCardInfo(self): saved_registration = card_registration.save() data = { - 'cardNumber': '4970105191923460', + 'cardNumber': '4970107111111119', 'cardCvx': '123', 'cardExpirationDate': '1224', 'accessKeyRef': card_registration.access_key,