Skip to content

Commit

Permalink
Added missing fields to CardValidation entity and updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviana Ghita committed Sep 6, 2023
1 parent 5b4a175 commit 270b2f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mangopay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
TRANSACTION_TYPE_CHOICES = Choices(
('PAYIN', 'payin', 'Pay In'),
('PAYOUT', 'payout', 'Pay out'),
('TRANSFER', 'transfer', 'Transfer')
('TRANSFER', 'transfer', 'Transfer'),
('CARD_VALIDATION', 'card_validation', 'Card validation')
)

NATURE_CHOICES = Choices(
Expand Down
14 changes: 14 additions & 0 deletions mangopay/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,24 @@ def __str__(self):


class CardValidation(BaseModel):
creation_date = DateTimeField(api_name='CreationDate')
author = ForeignKeyField(User, api_name='AuthorId', required=True)
ip_address = CharField(api_name='IpAddress', required=True)
browser_info = BrowserInfoField(api_name='BrowserInfo', required=True)
secure_mode_return_url = CharField(api_name='SecureModeReturnURL', required=True)
secure_mode_redirect_url = CharField(api_name='SecureModeRedirectURL')
secure_mode_needed = BooleanField(api_name='SecureModeNeeded')
validity = CharField(api_name='Validity',
choices=constants.VALIDITY_CHOICES,
default=constants.VALIDITY_CHOICES.unknown)
type = CharField(api_name='Type', choices=constants.TRANSACTION_TYPE_CHOICES, default=None)
applied_3ds_version = CharField(api_name='Applied3DSVersion')
status = CharField(api_name='Status',
choices=constants.STATUS_CHOICES,
default=None)
result_code = CharField(api_name='ResultCode')
result_message = CharField(api_name='ResultMessage')


def validate(self, *args, **kwargs):
kwargs['id'] = self.id
Expand Down
3 changes: 1 addition & 2 deletions tests/test_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ def test_cardValidation(self):
card_validation.browser_info = BaseTest.get_browser_info()

validation_response = card_validation.validate()
updated_card = Card.get(updated_registration['card_id'])

self.assertIsNotNone(validation_response)
self.assertEqual(updated_card.validity, 'VALID')
self.assertIsNotNone(validation_response['id'])

0 comments on commit 270b2f9

Please sign in to comment.