Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions hyperwallet/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'''
Expand All @@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion hyperwallet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
15 changes: 14 additions & 1 deletion hyperwallet/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down