Skip to content

Commit 27747f2

Browse files
Merge pull request #123 from hyperwallet/feature/DTPAYETWO-759-HWParity_PayPalAccountPhpDev
Feature/dtpayetwo 759 hw parity paypal account php dev
2 parents d9d5891 + 7ed283a commit 27747f2

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
ChangeLog
22
=========
3-
2.4.4
3+
2.2.5
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+
9+
2.2.4
410
-------------------
511
- Added attribute 'isDefaultTransferMethod' to identify default accounts.
612

src/Hyperwallet/Hyperwallet.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,8 @@ public function createPayPalAccount($userToken, PayPalAccount $payPalAccount) {
666666
if (empty($payPalAccount->getTransferMethodCurrency())) {
667667
throw new HyperwalletArgumentException('transferMethodCurrency is required!');
668668
}
669-
if (empty($payPalAccount->getEmail())) {
670-
throw new HyperwalletArgumentException('email is required!');
669+
if (empty($payPalAccount->getEmail()) and empty($payPalAccount->getAccountId()) ) {
670+
throw new HyperwalletArgumentException('email or accountId is required!');
671671
}
672672
$body = $this->client->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => $userToken), $payPalAccount, array());
673673
return new PayPalAccount($body);

src/Hyperwallet/Model/PayPalAccount.php

+21
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* @property string $transferMethodCurrency The transfer method currency
1313
* @property bool $isDefaultTransferMethod The flag to denote default account
1414
* @property string $email The PayPal account email
15+
* @property string $accountId The PayPal account identifier
1516
1617
*
1718
* @package Hyperwallet\Model
@@ -178,4 +179,24 @@ public function setEmail($email) {
178179
$this->email = $email;
179180
return $this;
180181
}
182+
183+
/**
184+
* Set the PayPal account identifier
185+
*
186+
* @param string $accountId
187+
* @return PayPalAccount
188+
*/
189+
public function setAccountId($accountId) {
190+
$this->accountId = $accountId;
191+
return $this;
192+
}
193+
194+
/**
195+
* Get the PayPal account identifier
196+
*
197+
* @return string
198+
*/
199+
public function getAccountId() {
200+
return $this->accountId;
201+
}
181202
}

tests/Hyperwallet/Tests/HyperwalletTest.php

+23-2
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ public function testCreatePayPalAccount_noEmail() {
12841284
$client->createPayPalAccount('test-user-token', $payPalAccount);
12851285
$this->fail('HyperwalletArgumentException expected');
12861286
} catch (HyperwalletArgumentException $e) {
1287-
$this->assertEquals('email is required!', $e->getMessage());
1287+
$this->assertEquals('email or accountId is required!', $e->getMessage());
12881288
}
12891289
}
12901290

@@ -4036,7 +4036,7 @@ public function testListReceiptsForPrepaidCard_withParameters() {
40364036
// Validate mock
40374037
\Phake::verify($apiClientMock)->doGet('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}/receipts', array('user-token' => 'test-user-token', 'prepaid-card-token' => 'test-prepaid-card-token'), array('createdBefore' => 'value'));
40384038
}
4039-
4039+
40404040
public function testListReceiptsForPrepaidCard_withInvalidFilter() {
40414041
$client = new Hyperwallet('test-username', 'test-password', 'test-program-token');
40424042
try {
@@ -5775,4 +5775,25 @@ public function testListTransferMethods_withParameters() {
57755775
// Validate mock
57765776
\Phake::verify($apiClientMock)->doGet('/rest/v4/users/{user-token}/transfer-methods', array('user-token' => 'test-user-token'), array('type'=>TransferMethod::TYPE_PREPAID_CARD));
57775777
}
5778+
5779+
public function testCreatePayPalAccount_WithAccountId() {
5780+
// Setup
5781+
$client = new Hyperwallet('test-username', 'test-password');
5782+
$apiClientMock = $this->createAndInjectApiClientMock($client);
5783+
$payPalAccount = new PayPalAccount();
5784+
$payPalAccount->setTransferMethodCountry('test-transferMethodCountry');
5785+
$payPalAccount->setTransferMethodCurrency('test-transferMethodCurrency');
5786+
$payPalAccount->setAccountId('test-accountId');
5787+
5788+
\Phake::when($apiClientMock)->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => 'test-user-token'), $payPalAccount, array())->thenReturn(array('token' => 'test-token'));
5789+
5790+
// Run test
5791+
$newPayPalAccount = $client->createPayPalAccount('test-user-token', $payPalAccount);
5792+
$this->assertNotNull($newPayPalAccount);
5793+
$this->assertEquals(array('token' => 'test-token'), $newPayPalAccount->getProperties());
5794+
5795+
5796+
// Validate mock
5797+
\Phake::verify($apiClientMock)->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => 'test-user-token'), $payPalAccount, array());
5798+
}
57785799
}

0 commit comments

Comments
 (0)