Skip to content

Commit 13fe30d

Browse files
iulian03Iulian Masar
and
Iulian Masar
authored
[release] 3.44.0 (#413)
* added country property to recipients (#412) Co-authored-by: Iulian Masar <iulian.masar@codegile.com> * identity verification updates (#410) - removed get checks endpoint - handle get all endpoint - updated event type and tests - skip logo upload test Co-authored-by: Iulian Masar <iulian.masar@codegile.com> * handle get all deposits by card or user (#411) Co-authored-by: Iulian Masar <iulian.masar@codegile.com> * reverted TestKycPageFile.png file --------- Co-authored-by: Iulian Masar <iulian.masar@codegile.com>
1 parent d9a1fb7 commit 13fe30d

File tree

7 files changed

+71
-52
lines changed

7 files changed

+71
-52
lines changed

mangopay/constants.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
('WAITING', 'waiting', 'Waiting'),
3636
('CANCELED', 'canceled', 'Canceled'),
3737
('EXPIRED', 'expired', 'Expired'),
38-
('VALIDATED', 'validated', 'Validated')
38+
('VALIDATED', 'validated', 'Validated'),
39+
('CANCEL_REQUESTED', 'cancel_requested', 'Cancel Requested'),
40+
('TO_BE_COMPLETED', 'to_be_completed', 'To Be Completed'),
41+
('NO_SHOW_REQUESTED', 'no_show_requested', 'No Show Requested'),
42+
('NO_SHOW', 'no_show', 'No Show'),
43+
('FAILED', 'failed', 'Failed')
3944
)
4045

4146
VALIDITY_CHOICES = Choices(
@@ -200,6 +205,7 @@
200205
('IDENTITY_VERIFICATION_INCONCLUSIVE', 'identity_verification_inconclusive', 'Identity Verification Inconclusive'),
201206
('IDENTITY_VERIFICATION_OUTDATED', 'identity_verification_outdated', 'Identity Verification Outdated'),
202207
('IDENTITY_VERIFICATION_TIMEOUT', 'identity_verification_timeout', 'Identity Verification Timeout'),
208+
('IDENTITY_VERIFICATION_PENDING', 'identity_verification_pending', 'Identity Verification Pending'),
203209

204210
('RECIPIENT_ACTIVE', 'recipient_active', 'Recipient Active'),
205211
('RECIPIENT_CANCELED', 'recipient_canceled', 'Recipient Canceled'),

mangopay/resources.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,9 +2584,25 @@ class Meta:
25842584
url = {
25852585
InsertQuery.identifier: '/deposit-preauthorizations/card/direct',
25862586
SelectQuery.identifier: '/deposit-preauthorizations/',
2587-
UpdateQuery.identifier: '/deposit-preauthorizations/'
2587+
UpdateQuery.identifier: '/deposit-preauthorizations/',
2588+
'GET_ALL_FOR_USER': '/users/%(user_id)s/deposit-preauthorizations/',
2589+
'GET_ALL_FOR_CARD': '/cards/%(card_id)s/deposit-preauthorizations/'
25882590
}
25892591

2592+
@classmethod
2593+
def get_all_for_user(cls, user_id, *args, **kwargs):
2594+
kwargs['user_id'] = user_id
2595+
select = SelectQuery(Deposit, *args, **kwargs)
2596+
select.identifier = 'GET_ALL_FOR_USER'
2597+
return select.all(*args, **kwargs)
2598+
2599+
@classmethod
2600+
def get_all_for_card(cls, card_id, *args, **kwargs):
2601+
kwargs['card_id'] = card_id
2602+
select = SelectQuery(Deposit, *args, **kwargs)
2603+
select.identifier = 'GET_ALL_FOR_CARD'
2604+
return select.all(*args, **kwargs)
2605+
25902606

25912607
class VirtualAccount(BaseModel):
25922608
wallet_id = CharField(api_name='WalletId', required=True)
@@ -2625,14 +2641,18 @@ class IdentityVerification(BaseModel):
26252641
hosted_url = CharField(api_name='HostedUrl')
26262642
return_url = CharField(api_name='ReturnUrl', required=True)
26272643
status = CharField(api_name='Status')
2644+
last_update = DateTimeField(api_name='UpdateDate')
2645+
user_id = CharField(api_name='UserId')
2646+
checks = ListField(api_name='Checks')
26282647

26292648
class Meta:
26302649
verbose_name = 'identity_verification'
26312650
verbose_name_plural = 'identity_verifications'
26322651

26332652
url = {
26342653
InsertQuery.identifier: '/users/%(user_id)s/identity-verifications',
2635-
SelectQuery.identifier: '/identity-verifications'
2654+
SelectQuery.identifier: '/identity-verifications',
2655+
'GET_ALL': '/users/%(user_id)s/identity-verifications'
26362656
}
26372657

26382658
def create(self, user_id, idempotency_key=None, **kwargs):
@@ -2641,34 +2661,12 @@ def create(self, user_id, idempotency_key=None, **kwargs):
26412661
insert.insert_query = self.get_field_dict()
26422662
return insert.execute()
26432663

2644-
def get_checks(self, *args, **kwargs):
2645-
kwargs['id'] = self.id
2646-
select = SelectQuery(IdentityVerificationCheck, *args, **kwargs)
2647-
select.identifier = 'GET_CHECKS'
2648-
return select.get("", *args, **kwargs)
2649-
2650-
2651-
class IdentityVerificationCheck(BaseModel):
2652-
session_id = CharField(api_name='SessionId')
2653-
status = CharField(api_name='Status')
2654-
creation_date = DateTimeField(api_name='CreationDate')
2655-
last_update = DateTimeField(api_name='LastUpdate')
2656-
checks = ListField(api_name='Checks')
2657-
2658-
class Meta:
2659-
verbose_name = 'identity_verification_check'
2660-
verbose_name_plural = 'identity_verifications_checks'
2661-
2662-
url = {
2663-
'GET_CHECKS': '/identity-verifications/%(id)s/checks'
2664-
}
2665-
26662664
@classmethod
2667-
def get(cls, identity_verification_id, *args, **kwargs):
2668-
kwargs['id'] = identity_verification_id
2669-
select = SelectQuery(IdentityVerificationCheck, *args, **kwargs)
2670-
select.identifier = 'GET_CHECKS'
2671-
return select.get("", *args, **kwargs)
2665+
def get_all(cls, user_id, *args, **kwargs):
2666+
kwargs['user_id'] = user_id
2667+
select = SelectQuery(IdentityVerification, *args, **kwargs)
2668+
select.identifier = 'GET_ALL'
2669+
return select.all(*args, **kwargs)
26722670

26732671

26742672
class Recipient(BaseModel):
@@ -2677,6 +2675,7 @@ class Recipient(BaseModel):
26772675
payout_method_type = CharField(api_name='PayoutMethodType', required=True)
26782676
recipient_type = CharField(api_name='RecipientType', required=True)
26792677
currency = CharField(api_name='Currency', required=True)
2678+
country = CharField(api_name='Country')
26802679
recipient_scope = CharField(api_name='RecipientScope')
26812680
user_id = CharField(api_name='UserId')
26822681
individual_recipient = IndividualRecipientField(api_name='IndividualRecipient')
@@ -2728,6 +2727,7 @@ class RecipientSchema(BaseModel):
27282727
payout_method_type = RecipientPropertySchemaField(api_name='PayoutMethodType')
27292728
recipient_type = RecipientPropertySchemaField(api_name='RecipientType')
27302729
currency = RecipientPropertySchemaField(api_name='Currency')
2730+
country = RecipientPropertySchemaField(api_name='Country')
27312731
recipient_scope = RecipientPropertySchemaField(api_name='RecipientScope')
27322732
tag = RecipientPropertySchemaField(api_name='Tag')
27332733
individual_recipient = IndividualRecipientPropertySchemaField(api_name='IndividualRecipient')
@@ -2741,14 +2741,15 @@ class Meta:
27412741

27422742
url = {
27432743
SelectQuery.identifier: '/recipients/schema?payoutMethodType=%(payout_method_type)s&recipientType=%('
2744-
'recipient_type)s&currency=%(currency)s'
2744+
'recipient_type)s&currency=%(currency)s&country=%(country)s'
27452745
}
27462746

27472747
@classmethod
2748-
def get(cls, payout_method_type, recipient_type, currency, *args, **kwargs):
2748+
def get(cls, payout_method_type, recipient_type, currency, country, *args, **kwargs):
27492749
kwargs['payout_method_type'] = payout_method_type
27502750
kwargs['recipient_type'] = recipient_type
27512751
kwargs['currency'] = currency
2752+
kwargs['country'] = country
27522753
select = SelectQuery(RecipientSchema, *args, **kwargs)
27532754
return select.get("", *args, **kwargs)
27542755

tests/resources/TestKycPageFile.png

36.2 KB
Loading

tests/test_clients.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import base64
22
import os
3-
import random
3+
import unittest
44

5-
from mangopay.resources import Client, ClientLogo, Address, BankWirePayOut, ClientWallet
5+
from mangopay.resources import Client, ClientLogo, BankWirePayOut, ClientWallet
66
from mangopay.utils import Money
77
from tests.test_base import BaseTestLive
88

@@ -29,6 +29,7 @@ def test_ClientGet(self):
2929
# self.assertEqual(client.headquarters_phone_number, phone_number, "Headquarter's phone number was not updated "
3030
# "correctly")
3131

32+
@unittest.skip("skipped")
3233
def test_LogoUpload(self):
3334
file_path = os.path.join(os.path.dirname(__file__), 'resources', 'TestKycPageFile.png')
3435
with open(file_path, 'rb') as f:

tests/test_deposits.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ def test_get(self):
1717
self.assertIsNotNone(fetched_deposit)
1818
self.assertEqual(deposit.id, fetched_deposit.id)
1919

20+
def test_get_all_for_user(self):
21+
deposit = self.create_new_deposit()
22+
result = Deposit.get_all_for_user(deposit.author_id)
23+
24+
self.assertIsNotNone(result)
25+
self.assertIsInstance(result.data, list)
26+
self.assertTrue(len(result.data) > 0)
27+
28+
def test_get_all_for_card(self):
29+
deposit = self.create_new_deposit()
30+
result = Deposit.get_all_for_card(deposit.card_id)
31+
32+
self.assertIsNotNone(result)
33+
self.assertIsInstance(result.data, list)
34+
self.assertTrue(len(result.data) > 0)
35+
2036
@unittest.skip("can't be tested yet")
2137
def test_cancel(self):
2238
deposit = self.create_new_deposit()

tests/test_identity_verification.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import unittest
2-
3-
from mangopay.resources import IdentityVerification, IdentityVerificationCheck
4-
from mangopay.utils import timestamp_from_datetime
1+
from mangopay.resources import IdentityVerification
52
from tests.test_base import BaseTestLive
63

74

@@ -24,20 +21,14 @@ def test_get_identity_verification(self):
2421
self.assertEqual(IdentityVerificationTest._identity_verification.return_url, fetched.return_url)
2522
self.assertEqual(IdentityVerificationTest._identity_verification.status, fetched.status)
2623

27-
@unittest.skip("api returning 404")
28-
def test_get_checks(self):
24+
def test_get_all_identity_verifications_for_user(self):
2925
self.create_new_identity_verification()
30-
# can be fetched in 2 ways:
31-
32-
# checks: IdentityVerificationCheck = IdentityVerificationCheck.get(
33-
# IdentityVerificationTest._identity_verification.id)
34-
checks: IdentityVerificationCheck = IdentityVerificationTest._identity_verification.get_checks()
26+
john = BaseTestLive.get_john()
27+
fetched = IdentityVerification.get_all(john.id)
3528

36-
self.assertIsNotNone(checks)
37-
self.assertEqual(checks.status, 'PENDING')
38-
self.assertTrue(timestamp_from_datetime(checks.creation_date) > 0)
39-
self.assertTrue(timestamp_from_datetime(checks.last_update) > 0)
40-
self.assertIsNotNone(checks.checks)
29+
self.assertIsNotNone(fetched)
30+
self.assertIsInstance(fetched.data, list)
31+
self.assertTrue(len(fetched.data) > 0)
4132

4233
@staticmethod
4334
def create_new_identity_verification():

tests/test_recipients.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_create_recipient(self):
2222
self.assertIsNotNone(RecipientsTest._recipient.local_bank_transfer)
2323
self.assertIsNone(RecipientsTest._recipient.international_bank_transfer)
2424
self.assertIsNone(RecipientsTest._recipient.business_recipient)
25+
self.assertIsNotNone(RecipientsTest._recipient.country)
2526

2627
def test_get_recipient(self):
2728
self.create_new_recipient()
@@ -41,7 +42,7 @@ def test_get_user_recipients(self):
4142
self.assertTrue(len(fetched.data) > 0)
4243

4344
def test_get_recipient_schema_local_bank_transfer_individual(self):
44-
schema = RecipientSchema.get('LocalBankTransfer', 'Individual', 'GBP')
45+
schema = RecipientSchema.get('LocalBankTransfer', 'Individual', 'GBP', 'GB')
4546

4647
self.assertIsNotNone(schema)
4748
self.assertIsNotNone(schema.display_name)
@@ -54,9 +55,10 @@ def test_get_recipient_schema_local_bank_transfer_individual(self):
5455
self.assertIsNotNone(schema.individual_recipient)
5556
self.assertIsNone(schema.business_recipient)
5657
self.assertIsNone(schema.international_bank_transfer)
58+
self.assertIsNotNone(schema.country)
5759

5860
def test_get_recipient_schema_international_bank_transfer_business(self):
59-
schema = RecipientSchema.get('InternationalBankTransfer', 'Business', 'GBP')
61+
schema = RecipientSchema.get('InternationalBankTransfer', 'Business', 'GBP', 'GB')
6062

6163
self.assertIsNotNone(schema)
6264
self.assertIsNotNone(schema.display_name)
@@ -69,6 +71,7 @@ def test_get_recipient_schema_international_bank_transfer_business(self):
6971
self.assertIsNotNone(schema.international_bank_transfer)
7072
self.assertIsNone(schema.local_bank_transfer)
7173
self.assertIsNone(schema.individual_recipient)
74+
self.assertIsNotNone(schema.country)
7275

7376
def test_get_payout_methods(self):
7477
payout_methods = PayoutMethod.get("DE", "EUR")
@@ -115,6 +118,7 @@ def get_new_recipient_obj():
115118
recipient.payout_method_type = 'LocalBankTransfer'
116119
recipient.recipient_type = 'Individual'
117120
recipient.currency = 'GBP'
121+
recipient.country = 'GB'
118122

119123
individual_recipient = IndividualRecipient()
120124
individual_recipient.first_name = 'Alex'

0 commit comments

Comments
 (0)