Skip to content

Commit

Permalink
Merge pull request #362 from Mangopay/feature/payment-category-param
Browse files Browse the repository at this point in the history
added payment_category param
  • Loading branch information
iulian03 authored May 31, 2024
2 parents 5fdb26c + a3c473e commit 5ae9978
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mangopay/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class CardValidation(BaseModel):
preferred_card_network = CharField(api_name='PreferredCardNetwork')
authorization_date = DateTimeField(api_name='AuthorizationDate')
card_info = CardInfoField(api_name='CardInfo')
payment_category = CharField(api_name='PaymentCategory')

def validate(self, card_id, **kwargs):
insert = InsertQuery(self, **kwargs)
Expand Down Expand Up @@ -800,6 +801,7 @@ class DirectPayIn(PayIn):
requested_3ds_version = CharField(api_name='Requested3DSVersion')
applied_3ds_version = CharField(api_name='Applied3DSVersion')
card_info = CardInfoField(api_name='CardInfo')
payment_category = CharField(api_name='PaymentCategory')

class Meta:
verbose_name = 'payin'
Expand Down Expand Up @@ -1279,6 +1281,7 @@ class PreAuthorization(BaseModel):
requested_3ds_version = CharField(api_name='Requested3DSVersion')
applied_3ds_version = CharField(api_name='Applied3DSVersion')
card_info = CardInfoField(api_name='CardInfo')
payment_category = CharField(api_name='PaymentCategory')

def get_transactions(self, *args, **kwargs):
kwargs['id'] = self.id
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ def test_cardValidation(self):
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()
card_validation.payment_category = 'TelephoneOrder'

validation_response = card_validation.validate(card_id)

self.assertIsNotNone(validation_response)
self.assertIsNotNone(validation_response['id'])
self.assertEqual('TelephoneOrder', validation_response['payment_category'])

def test_getCardValidation(self):
user = BaseTestLive.get_john()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_payins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,7 @@ def test_PayIns_CardDirect_CheckCardInfo(self):
pay_in.secure_mode_return_url = "http://www.example.com/"
pay_in.ip_address = "2001:0620:0000:0000:0211:24FF:FE80:C12C"
pay_in.browser_info = BaseTest.get_browser_info()
pay_in.payment_category = 'TelephoneOrder'

address = Address()
address.address_line_1 = "Big Street"
Expand All @@ -1688,6 +1689,7 @@ def test_PayIns_CardDirect_CheckCardInfo(self):
card_info = result['card_info']
self.assertIsNotNone(card_info)
self.assertIsInstance(card_info, CardInfo)
self.assertEqual('TelephoneOrder', result['payment_category'])

def test_PayIns_CardDirect_GetPaymentMethodMetadata(self):
user = BaseTestLive.get_john(True)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_preauthorizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ def test_PreAuthorizations_CheckCardInfo(self):
pre_authorization.secure_mode_return_url = "http://www.example.com/"
pre_authorization.ip_address = "2001:0620:0000:0000:0211:24FF:FE80:C12C"
pre_authorization.browser_info = BaseTest.get_browser_info()
pre_authorization.payment_category = 'TelephoneOrder'

billing = Billing()
billing.address = Address()
Expand All @@ -845,4 +846,5 @@ def test_PreAuthorizations_CheckCardInfo(self):
self.assertIsNotNone(saved_pre_authorization)
card_info = saved_pre_authorization['card_info']
self.assertIsNotNone(card_info)
self.assertIsInstance(card_info, CardInfo)
self.assertIsInstance(card_info, CardInfo)
self.assertEqual('TelephoneOrder', saved_pre_authorization['payment_category'])

0 comments on commit 5ae9978

Please sign in to comment.