Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dtpayetwo 759 hw parity paypal account php dev #123

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ChangeLog
=========
2.4.4
2.2.5
-------------------
- 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.

2.2.4
-------------------
- Added attribute 'isDefaultTransferMethod' to identify default accounts.

Expand Down
4 changes: 2 additions & 2 deletions src/Hyperwallet/Hyperwallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ public function createPayPalAccount($userToken, PayPalAccount $payPalAccount) {
if (empty($payPalAccount->getTransferMethodCurrency())) {
throw new HyperwalletArgumentException('transferMethodCurrency is required!');
}
if (empty($payPalAccount->getEmail())) {
throw new HyperwalletArgumentException('email is required!');
if (empty($payPalAccount->getEmail()) and empty($payPalAccount->getAccountId()) ) {
throw new HyperwalletArgumentException('email or accountId is required!');
}
$body = $this->client->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => $userToken), $payPalAccount, array());
return new PayPalAccount($body);
Expand Down
21 changes: 21 additions & 0 deletions src/Hyperwallet/Model/PayPalAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @property string $transferMethodCurrency The transfer method currency
* @property bool $isDefaultTransferMethod The flag to denote default account
* @property string $email The PayPal account email
* @property string $accountId The PayPal account identifier

*
* @package Hyperwallet\Model
Expand Down Expand Up @@ -178,4 +179,24 @@ public function setEmail($email) {
$this->email = $email;
return $this;
}

/**
* Set the PayPal account identifier
*
* @param string $accountId
* @return PayPalAccount
*/
public function setAccountId($accountId) {
$this->accountId = $accountId;
return $this;
}

/**
* Get the PayPal account identifier
*
* @return string
*/
public function getAccountId() {
return $this->accountId;
}
}
25 changes: 23 additions & 2 deletions tests/Hyperwallet/Tests/HyperwalletTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ public function testCreatePayPalAccount_noEmail() {
$client->createPayPalAccount('test-user-token', $payPalAccount);
$this->fail('HyperwalletArgumentException expected');
} catch (HyperwalletArgumentException $e) {
$this->assertEquals('email is required!', $e->getMessage());
$this->assertEquals('email or accountId is required!', $e->getMessage());
}
}

Expand Down Expand Up @@ -4036,7 +4036,7 @@ public function testListReceiptsForPrepaidCard_withParameters() {
// Validate mock
\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'));
}

public function testListReceiptsForPrepaidCard_withInvalidFilter() {
$client = new Hyperwallet('test-username', 'test-password', 'test-program-token');
try {
Expand Down Expand Up @@ -5775,4 +5775,25 @@ public function testListTransferMethods_withParameters() {
// Validate mock
\Phake::verify($apiClientMock)->doGet('/rest/v4/users/{user-token}/transfer-methods', array('user-token' => 'test-user-token'), array('type'=>TransferMethod::TYPE_PREPAID_CARD));
}

public function testCreatePayPalAccount_WithAccountId() {
// Setup
$client = new Hyperwallet('test-username', 'test-password');
$apiClientMock = $this->createAndInjectApiClientMock($client);
$payPalAccount = new PayPalAccount();
$payPalAccount->setTransferMethodCountry('test-transferMethodCountry');
$payPalAccount->setTransferMethodCurrency('test-transferMethodCurrency');
$payPalAccount->setAccountId('test-accountId');

\Phake::when($apiClientMock)->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => 'test-user-token'), $payPalAccount, array())->thenReturn(array('token' => 'test-token'));

// Run test
$newPayPalAccount = $client->createPayPalAccount('test-user-token', $payPalAccount);
$this->assertNotNull($newPayPalAccount);
$this->assertEquals(array('token' => 'test-token'), $newPayPalAccount->getProperties());


// Validate mock
\Phake::verify($apiClientMock)->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => 'test-user-token'), $payPalAccount, array());
}
}