Skip to content

Commit 68ded29

Browse files
authored
Merge pull request #51 from hyperwallet/feature/DTPAYWONE-568-add-webhook-for-transfers
DTPAYWONE-568 Add webhooks types for Transfers
2 parents b36150e + 5b23ebd commit 68ded29

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

hyperwallet/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,9 @@ def __init__(self, data):
899899
"BANK_CARDS": BankCard,
900900
"PAYPAL_ACCOUNTS": PayPalAccount,
901901
"PAPER_CHECKS": PaperCheck,
902-
"VENMO_ACCOUNTS": VenmoAccount
902+
"VENMO_ACCOUNTS": VenmoAccount,
903+
"TRANSFERS": Transfer,
904+
"REFUND": TransferRefunds
903905
}
904906

905907
base, sub = self.type.split('.')[:2]

hyperwallet/tests/test_models.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,44 @@ def test_webhook_model_good_sub_type_paperCheck(self):
580580
)
581581
)
582582

583+
def test_webhook_model_good_sub_type_transfer(self):
584+
585+
webhook_data = {
586+
'token': 'wbh-12345',
587+
'createdOn': '2017-01-01',
588+
'type': 'TRANSFERS.UPDATED.STATUS.SCHEDULED',
589+
'object': self.transfer_method_data
590+
}
591+
592+
test_webhook = Webhook(webhook_data)
593+
594+
self.assertEqual(
595+
test_webhook.object.__repr__(),
596+
'Transfer({date}, {token})'.format(
597+
date=self.transfer_method_data.get('createdOn'),
598+
token=self.transfer_method_data.get('token')
599+
)
600+
)
601+
602+
def test_webhook_model_good_sub_type_transferRefunds(self):
603+
604+
webhook_data = {
605+
'token': 'wbh-12345',
606+
'createdOn': '2017-01-01',
607+
'type': 'TRANSFERS.REFUND.CREATED',
608+
'object': self.transfer_method_data
609+
}
610+
611+
test_webhook = Webhook(webhook_data)
612+
613+
self.assertEqual(
614+
test_webhook.object.__repr__(),
615+
'TransferRefunds({date}, {token})'.format(
616+
date=self.transfer_method_data.get('createdOn'),
617+
token=self.transfer_method_data.get('token')
618+
)
619+
)
620+
583621
def test_webhook_model_bad_object(self):
584622

585623
webhook_data = {

0 commit comments

Comments
 (0)