3
3
namespace Omnipay \Neteller \Message ;
4
4
5
5
use Guzzle \Http \Exception \BadResponseException ;
6
+ use Omnipay \Common \Exception \InvalidRequestException ;
6
7
7
8
/**
8
9
* Neteller Payout Request.
@@ -16,45 +17,55 @@ class PayoutRequest extends AbstractRequest
16
17
/**
17
18
* @return string|null
18
19
*/
19
- public function getEmail ()
20
+ public function getAccount ()
20
21
{
21
- return $ this ->getParameter ('email ' );
22
+ return $ this ->getParameter ('account ' );
22
23
}
23
24
24
25
/**
25
26
* @param string $value
26
27
*
27
28
* @return self
28
29
*/
29
- public function setEmail ($ value )
30
+ public function setAccount ($ value )
30
31
{
31
- return $ this ->setParameter ('email ' , $ value );
32
+ return $ this ->setParameter ('account ' , $ value );
32
33
}
33
34
34
35
/**
35
36
* @return array request data
37
+ * @throws InvalidRequestException
36
38
*/
37
39
public function getData ()
38
40
{
39
41
$ this ->validate (
40
- 'email ' ,
42
+ 'account ' ,
41
43
'description ' ,
42
44
'transactionId ' ,
43
45
'amount ' ,
44
46
'currency '
45
47
);
46
48
47
- return array (
48
- 'payeeProfile ' => array (
49
- 'email ' => (string ) $ this ->getEmail ()
50
- ),
49
+ $ account = $ this ->getAccount ();
50
+ $ data = array (
51
+ 'payeeProfile ' => array (),
51
52
'transaction ' => array (
52
53
'merchantRefId ' => (string ) $ this ->getTransactionId (),
53
54
'amount ' => (int ) $ this ->getAmountInteger (),
54
55
'currency ' => (string ) $ this ->getCurrency (),
55
56
),
56
57
'message ' => (string ) $ this ->getDescription ()
57
58
);
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 ;
58
69
}
59
70
60
71
/**
0 commit comments