Skip to content

Commit 3c29dc4

Browse files
Merge pull request #58 from hyperwallet/feature/DTPAYETWO-759-HW-Parity
[DTPAYETWO-759] HW Parity PaypalAccount Representation changes
2 parents bcdc35f + ab6bd00 commit 3c29dc4

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Changelog
22
=========
3+
1.7.2
4+
-------------------
5+
- Added field 'accountId' to PayPal.
6+
- PayPal account creation allowed using field 'accountId' which accepts Email, Phone Number, PayPal PayerID.
7+
- Venmo account creation allowed using field 'accountId' which accepts Email, Phone Number, Venmo Handle, Venmo External ID.
8+
39
1.7.1
410
-------------------
511
- Added attribute 'isDefaultTransferMethod' to identify default accounts.

hyperwallet/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ def createPayPalAccount(self,
15371537
:param userToken:
15381538
A token identifying the User. **REQUIRED**
15391539
:param data:
1540-
A dictionary containing PayPal Account information. **REQUIRED**
1540+
A dictionary containing PayPal Account information. Required fields transferMethodCountry, transferMethodCurrency , email or accountId **REQUIRED**
15411541
:returns:
15421542
A PayPal Account.
15431543
'''
@@ -1554,8 +1554,8 @@ def createPayPalAccount(self,
15541554
if not ('transferMethodCurrency' in data) or not (data['transferMethodCurrency']):
15551555
raise HyperwalletException('transferMethodCurrency is required')
15561556

1557-
if not ('email' in data) or not (data['email']):
1558-
raise HyperwalletException('email is required')
1557+
if (not ('email' in data) or not (data['email'])) and (not ('accountId' in data) or not (data['accountId'])):
1558+
raise HyperwalletException('email or accountId is required')
15591559

15601560
response = self.apiClient.doPost(
15611561
self.__buildUrl('users', userToken, 'paypal-accounts'),

hyperwallet/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ def __init__(self, data):
548548
super(PayPalAccount, self).__init__(data)
549549

550550
self.defaults = {
551-
'email': None
551+
'email': None,
552+
'accountId': None
552553
}
553554

554555
for (param, default) in self.defaults.items():

hyperwallet/tests/test_api.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ def test_create_paypal_account_fail_need_email(self):
15341534
with self.assertRaises(HyperwalletException) as exc:
15351535
self.api.createPayPalAccount('token', paypal_account_data)
15361536

1537-
self.assertEqual(exc.exception.message, 'email is required')
1537+
self.assertEqual(exc.exception.message, 'email or accountId is required')
15381538

15391539
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
15401540
def test_create_paypal_account_success(self, mock_post):
@@ -1549,6 +1549,19 @@ def test_create_paypal_account_success(self, mock_post):
15491549

15501550
self.assertTrue(response.email, paypal_account_data.get('token'))
15511551

1552+
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
1553+
def test_create_paypal_account_accountId_success(self, mock_post):
1554+
1555+
paypal_account_data = {
1556+
'transferMethodCountry': 'test-transfer-method-country',
1557+
'transferMethodCurrency': 'test-transfer-method-currency',
1558+
'accountId': 'test-email'
1559+
}
1560+
mock_post.return_value = paypal_account_data
1561+
response = self.api.createPayPalAccount('token', paypal_account_data)
1562+
1563+
self.assertTrue(response.accountId, paypal_account_data.get('token'))
1564+
15521565
def test_update_paypal_account_fail_need_user_token(self):
15531566

15541567
with self.assertRaises(HyperwalletException) as exc:

0 commit comments

Comments
 (0)