Skip to content

Commit 89411f9

Browse files
committed
Parameter "email" changed to "account"
1 parent 9bd0da7 commit 89411f9

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

src/Message/PayoutRequest.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\Neteller\Message;
44

55
use Guzzle\Http\Exception\BadResponseException;
6+
use Omnipay\Common\Exception\InvalidRequestException;
67

78
/**
89
* Neteller Payout Request.
@@ -16,45 +17,55 @@ class PayoutRequest extends AbstractRequest
1617
/**
1718
* @return string|null
1819
*/
19-
public function getEmail()
20+
public function getAccount()
2021
{
21-
return $this->getParameter('email');
22+
return $this->getParameter('account');
2223
}
2324

2425
/**
2526
* @param string $value
2627
*
2728
* @return self
2829
*/
29-
public function setEmail($value)
30+
public function setAccount($value)
3031
{
31-
return $this->setParameter('email', $value);
32+
return $this->setParameter('account', $value);
3233
}
3334

3435
/**
3536
* @return array request data
37+
* @throws InvalidRequestException
3638
*/
3739
public function getData()
3840
{
3941
$this->validate(
40-
'email',
42+
'account',
4143
'description',
4244
'transactionId',
4345
'amount',
4446
'currency'
4547
);
4648

47-
return array(
48-
'payeeProfile' => array(
49-
'email' => (string) $this->getEmail()
50-
),
49+
$account = $this->getAccount();
50+
$data = array(
51+
'payeeProfile' => array(),
5152
'transaction' => array(
5253
'merchantRefId' => (string) $this->getTransactionId(),
5354
'amount' => (int) $this->getAmountInteger(),
5455
'currency' => (string) $this->getCurrency(),
5556
),
5657
'message' => (string) $this->getDescription()
5758
);
59+
60+
if (is_numeric($account)) {
61+
$data['payeeProfile']['accountId'] = (string) $account;
62+
} elseif (filter_var($account, FILTER_VALIDATE_EMAIL)) {
63+
$data['payeeProfile']['email'] = (string) $account;
64+
} else {
65+
throw new InvalidRequestException('The account parameter must be an email or numeric value');
66+
}
67+
68+
return $data;
5869
}
5970

6071
/**

src/Message/PurchaseRequest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ class PurchaseRequest extends AbstractRequest
1616
/**
1717
* @return string|null
1818
*/
19-
public function getEmail()
19+
public function getAccount()
2020
{
21-
return $this->getParameter('email');
21+
return $this->getParameter('account');
2222
}
2323

2424
/**
2525
* @param string $value
2626
*
2727
* @return self
2828
*/
29-
public function setEmail($value)
29+
public function setAccount($value)
3030
{
31-
return $this->setParameter('email', $value);
31+
return $this->setParameter('account', $value);
3232
}
3333

3434
/**
@@ -55,7 +55,7 @@ public function setVerificationCode($value)
5555
public function getData()
5656
{
5757
$this->validate(
58-
'email',
58+
'account',
5959
'verificationCode',
6060
'transactionId',
6161
'amount',
@@ -65,7 +65,7 @@ public function getData()
6565
return array(
6666
'paymentMethod' => array(
6767
'type' => 'neteller',
68-
'value' => (string) $this->getEmail()
68+
'value' => (string) $this->getAccount()
6969
),
7070
'transaction' => array(
7171
'merchantRefId' => (string) $this->getTransactionId(),

tests/Omnipay/Neteller/GatewayTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function setUp()
2222
public function testPurchase()
2323
{
2424
$request = $this->gateway->purchase(array(
25-
'email' => 'netellertest_USD@neteller.com',
25+
'account' => 'netellertest_USD@neteller.com',
2626
'transactionId' => 'TX9997888',
2727
'amount' => '14.65',
2828
'currency' => 'USD'
2929
));
3030

31-
$this->assertSame('netellertest_USD@neteller.com', $request->getEmail());
31+
$this->assertSame('netellertest_USD@neteller.com', $request->getAccount());
3232
$this->assertSame('TX9997888', $request->getTransactionId());
3333
$this->assertSame('14.65', $request->getAmount());
3434
$this->assertSame('USD', $request->getCurrency());
@@ -37,13 +37,13 @@ public function testPurchase()
3737
public function testPayout()
3838
{
3939
$request = $this->gateway->payout(array(
40-
'email' => 'netellertest_USD@neteller.com',
40+
'account' => 'netellertest_USD@neteller.com',
4141
'transactionId' => 'TX8889777',
4242
'amount' => '12.43',
4343
'currency' => 'USD'
4444
));
4545

46-
$this->assertSame('netellertest_USD@neteller.com', $request->getEmail());
46+
$this->assertSame('netellertest_USD@neteller.com', $request->getAccount());
4747
$this->assertSame('TX8889777', $request->getTransactionId());
4848
$this->assertSame('12.43', $request->getAmount());
4949
$this->assertSame('USD', $request->getCurrency());

tests/Omnipay/Neteller/Message/PayoutRequestTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function setUp()
1515
parent::setUp();
1616
$this->request = new PayoutRequest($this->getHttpClient(), $this->getHttpRequest());
1717
$this->request->initialize(array(
18-
'email' => 'netellertest_USD@neteller.com',
18+
'account' => 'netellertest_USD@neteller.com',
1919
'verificationCode' => 270955,
2020
'transactionId' => 4567890,
2121
'description' => 'Free Text Description',
@@ -32,6 +32,14 @@ public function testGetData()
3232
$this->assertSame(1234, $data['transaction']['amount']);
3333
$this->assertSame('USD', $data['transaction']['currency']);
3434
$this->assertSame('Free Text Description', $data['message']);
35+
36+
$this->request->setAccount(454651018446);
37+
$data = $this->request->getData();
38+
$this->assertSame('454651018446', $data['payeeProfile']['accountId']);
39+
40+
$this->request->setAccount('SomeInvalidAccount');
41+
$this->setExpectedException('Omnipay\Common\Exception\InvalidRequestException', 'The account parameter must be an email or numeric value');
42+
$this->request->getData();
3543
}
3644

3745
public function testSendDataSuccess()

tests/Omnipay/Neteller/Message/PurchaseRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function setUp()
1515
parent::setUp();
1616
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
1717
$this->request->initialize(array(
18-
'email' => 'netellertest_USD@neteller.com',
18+
'account' => 'netellertest_USD@neteller.com',
1919
'verificationCode' => 270955,
2020
'transactionId' => 4567890,
2121
'amount' => 12.34,

0 commit comments

Comments
 (0)