33namespace Omnipay \Neteller \Message ;
44
55use 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 /**
0 commit comments