From 645ba10fbf7234587152b6e63278c28e540fdb0a Mon Sep 17 00:00:00 2001 From: dvengatesh Date: Wed, 30 Nov 2022 19:07:44 +0530 Subject: [PATCH 1/3] HW Parity PaypalAccount Representation changes --- hyperwallet/api.py | 4 ++-- hyperwallet/models.py | 3 ++- hyperwallet/tests/test_api.py | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hyperwallet/api.py b/hyperwallet/api.py index 490a363..c7abd50 100644 --- a/hyperwallet/api.py +++ b/hyperwallet/api.py @@ -1554,8 +1554,8 @@ def createPayPalAccount(self, if not ('transferMethodCurrency' in data) or not (data['transferMethodCurrency']): raise HyperwalletException('transferMethodCurrency is required') - if not ('email' in data) or not (data['email']): - raise HyperwalletException('email is required') + if (not ('email' in data) or not (data['email'])) and (not ('accountId' in data) or not (data['accountId'])): + raise HyperwalletException('email/accountId is required') response = self.apiClient.doPost( self.__buildUrl('users', userToken, 'paypal-accounts'), diff --git a/hyperwallet/models.py b/hyperwallet/models.py index f432c5e..9e9a39e 100644 --- a/hyperwallet/models.py +++ b/hyperwallet/models.py @@ -548,7 +548,8 @@ def __init__(self, data): super(PayPalAccount, self).__init__(data) self.defaults = { - 'email': None + 'email': None, + 'accountId': None } for (param, default) in self.defaults.items(): diff --git a/hyperwallet/tests/test_api.py b/hyperwallet/tests/test_api.py index c8515ae..4210019 100644 --- a/hyperwallet/tests/test_api.py +++ b/hyperwallet/tests/test_api.py @@ -1529,7 +1529,7 @@ def test_create_paypal_account_fail_need_email(self): with self.assertRaises(HyperwalletException) as exc: self.api.createPayPalAccount('token', paypal_account_data) - self.assertEqual(exc.exception.message, 'email is required') + self.assertEqual(exc.exception.message, 'email/accountId is required') @mock.patch('hyperwallet.utils.ApiClient._makeRequest') def test_create_paypal_account_success(self, mock_post): @@ -1544,6 +1544,19 @@ def test_create_paypal_account_success(self, mock_post): self.assertTrue(response.email, paypal_account_data.get('token')) + @mock.patch('hyperwallet.utils.ApiClient._makeRequest') + def test_create_paypal_account_accountId_success(self, mock_post): + + paypal_account_data = { + 'transferMethodCountry': 'test-transfer-method-country', + 'transferMethodCurrency': 'test-transfer-method-currency', + 'accountId': 'test-email' + } + mock_post.return_value = paypal_account_data + response = self.api.createPayPalAccount('token', paypal_account_data) + + self.assertTrue(response.accountId, paypal_account_data.get('token')) + def test_update_paypal_account_fail_need_user_token(self): with self.assertRaises(HyperwalletException) as exc: From daa19cb897356220b482c3a79bbe53bdfbcfad4a Mon Sep 17 00:00:00 2001 From: dvengatesh Date: Thu, 1 Dec 2022 11:24:57 +0530 Subject: [PATCH 2/3] Review comments fix --- CHANGELOG.rst | 6 ++++++ hyperwallet/api.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ea1a0da..5b48974 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,11 @@ Changelog ========= +1.7.1 +------------------- +- Added field 'accountId' to PayPal. +- PayPal account creation allowed using field 'accountId' which accepts Email, Phone Number, PayPal PayerID. +- Venmo account creation allowed using field 'accountId' which accepts Email, Phone Number, Venmo Handle, Venmo External ID. + 1.7.0 ------------------- - Added missing webhook groups diff --git a/hyperwallet/api.py b/hyperwallet/api.py index c7abd50..a354416 100644 --- a/hyperwallet/api.py +++ b/hyperwallet/api.py @@ -1537,7 +1537,7 @@ def createPayPalAccount(self, :param userToken: A token identifying the User. **REQUIRED** :param data: - A dictionary containing PayPal Account information. **REQUIRED** + A dictionary containing PayPal Account information. Required fields transferMethodCountry, transferMethodCurrency , email or accountId **REQUIRED** :returns: A PayPal Account. ''' From 1b737b0a8707aefede6a748c3b30c2ca764cb142 Mon Sep 17 00:00:00 2001 From: dvengatesh Date: Thu, 1 Dec 2022 11:26:55 +0530 Subject: [PATCH 3/3] Review comments fix --- hyperwallet/api.py | 2 +- hyperwallet/tests/test_api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hyperwallet/api.py b/hyperwallet/api.py index a354416..ee2f99c 100644 --- a/hyperwallet/api.py +++ b/hyperwallet/api.py @@ -1555,7 +1555,7 @@ def createPayPalAccount(self, raise HyperwalletException('transferMethodCurrency is required') if (not ('email' in data) or not (data['email'])) and (not ('accountId' in data) or not (data['accountId'])): - raise HyperwalletException('email/accountId is required') + raise HyperwalletException('email or accountId is required') response = self.apiClient.doPost( self.__buildUrl('users', userToken, 'paypal-accounts'), diff --git a/hyperwallet/tests/test_api.py b/hyperwallet/tests/test_api.py index 4210019..9c8f9ec 100644 --- a/hyperwallet/tests/test_api.py +++ b/hyperwallet/tests/test_api.py @@ -1529,7 +1529,7 @@ def test_create_paypal_account_fail_need_email(self): with self.assertRaises(HyperwalletException) as exc: self.api.createPayPalAccount('token', paypal_account_data) - self.assertEqual(exc.exception.message, 'email/accountId is required') + self.assertEqual(exc.exception.message, 'email or accountId is required') @mock.patch('hyperwallet.utils.ApiClient._makeRequest') def test_create_paypal_account_success(self, mock_post):