diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 183377c..1fc78ae 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,11 @@ Changelog ========= +1.7.2 +------------------- +- 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.1 ------------------- - Added attribute 'isDefaultTransferMethod' to identify default accounts. diff --git a/hyperwallet/api.py b/hyperwallet/api.py index 1c938ed..7fa6dbd 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. ''' @@ -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 or 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 bb47602..0f73566 100644 --- a/hyperwallet/tests/test_api.py +++ b/hyperwallet/tests/test_api.py @@ -1534,7 +1534,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 or accountId is required') @mock.patch('hyperwallet.utils.ApiClient._makeRequest') def test_create_paypal_account_success(self, mock_post): @@ -1549,6 +1549,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: