@@ -68,7 +68,7 @@ |
||
68 | 68 | * |
69 | 69 | * @param \SimpleXMLElement $xml Response xml object |
70 | 70 | * |
71 | - * @return ResponseInterface |
|
71 | + * @return TransactionModificationResponse |
|
72 | 72 | */ |
73 | 73 | protected function newResponse($xml) |
74 | 74 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getData() |
30 | 30 | { |
31 | - $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount'); |
|
31 | + $this->validate( 'merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount' ); |
|
32 | 32 | |
33 | 33 | $data = [ |
34 | 34 | 'AcquirerId' => $this->getAcquirerId(), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function getEndpoint() |
52 | 52 | { |
53 | - return parent::getEndpoint() . 'TransactionModification'; |
|
53 | + return parent::getEndpoint().'TransactionModification'; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return ResponseInterface |
72 | 72 | */ |
73 | - protected function newResponse($xml) |
|
73 | + protected function newResponse( $xml ) |
|
74 | 74 | { |
75 | - return new TransactionModificationResponse($this, $xml); |
|
75 | + return new TransactionModificationResponse( $this, $xml ); |
|
76 | 76 | } |
77 | 77 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * FACPG2 Transaction Modification Request |
9 | 9 | */ |
10 | -class TransactionModificationRequest extends AbstractRequest |
|
11 | -{ |
|
10 | +class TransactionModificationRequest extends AbstractRequest { |
|
12 | 11 | /** |
13 | 12 | * @var string; |
14 | 13 | */ |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | * |
27 | 26 | * @return array |
28 | 27 | */ |
29 | - public function getData() |
|
30 | - { |
|
28 | + public function getData() { |
|
31 | 29 | $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount'); |
32 | 30 | |
33 | 31 | $data = [ |
@@ -48,8 +46,7 @@ discard block |
||
48 | 46 | * |
49 | 47 | * @return string Endpoint URL |
50 | 48 | */ |
51 | - protected function getEndpoint() |
|
52 | - { |
|
49 | + protected function getEndpoint() { |
|
53 | 50 | return parent::getEndpoint() . 'TransactionModification'; |
54 | 51 | } |
55 | 52 | |
@@ -58,8 +55,7 @@ discard block |
||
58 | 55 | * |
59 | 56 | * @return int Modification Type |
60 | 57 | */ |
61 | - protected function getModificationType() |
|
62 | - { |
|
58 | + protected function getModificationType() { |
|
63 | 59 | return $this->modificationType; |
64 | 60 | } |
65 | 61 | |
@@ -70,8 +66,7 @@ discard block |
||
70 | 66 | * |
71 | 67 | * @return ResponseInterface |
72 | 68 | */ |
73 | - protected function newResponse($xml) |
|
74 | - { |
|
69 | + protected function newResponse($xml) { |
|
75 | 70 | return new TransactionModificationResponse($this, $xml); |
76 | 71 | } |
77 | 72 | } |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return \Omnipay\FirstAtlanticCommerce\Message\AuthorizeRequest |
43 | 43 | */ |
44 | - public function authorize(array $parameters = []) |
|
44 | + public function authorize( array $parameters = [] ) |
|
45 | 45 | { |
46 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\AuthorizeRequest', $parameters); |
|
46 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\AuthorizeRequest', $parameters ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return \Omnipay\FirstAtlanticCommerce\Message\CaptureRequest |
55 | 55 | */ |
56 | - public function capture(array $parameters = []) |
|
56 | + public function capture( array $parameters = [] ) |
|
57 | 57 | { |
58 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\CaptureRequest', $parameters); |
|
58 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\CaptureRequest', $parameters ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return \Omnipay\FirstAtlanticCommerce\Message\PurchaseRequest |
67 | 67 | */ |
68 | - public function purchase(array $parameters = []) |
|
68 | + public function purchase( array $parameters = [] ) |
|
69 | 69 | { |
70 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\PurchaseRequest', $parameters); |
|
70 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\PurchaseRequest', $parameters ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return \Omnipay\FirstAtlanticCommerce\Message\RefundRequest |
79 | 79 | */ |
80 | - public function refund(array $parameters = []) |
|
80 | + public function refund( array $parameters = [] ) |
|
81 | 81 | { |
82 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\RefundRequest', $parameters); |
|
82 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\RefundRequest', $parameters ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return \Omnipay\FirstAtlanticCommerce\Message\VoidRequest |
91 | 91 | */ |
92 | - public function void(array $parameters = []) |
|
92 | + public function void( array $parameters = [] ) |
|
93 | 93 | { |
94 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\VoidRequest', $parameters); |
|
94 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\VoidRequest', $parameters ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return \Omnipay\FirstAtlanticCommerce\Message\StatusRequest |
103 | 103 | */ |
104 | - public function status(array $parameters = []) |
|
104 | + public function status( array $parameters = [] ) |
|
105 | 105 | { |
106 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\StatusRequest', $parameters); |
|
106 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\StatusRequest', $parameters ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return \Omnipay\FirstAtlanticCommerce\Message\CreateCardRequest |
115 | 115 | */ |
116 | - public function createCard(array $parameters = []) |
|
116 | + public function createCard( array $parameters = [] ) |
|
117 | 117 | { |
118 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\CreateCardRequest', $parameters); |
|
118 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\CreateCardRequest', $parameters ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return \Omnipay\FirstAtlanticCommerce\Message\UpdateCardRequest |
127 | 127 | */ |
128 | - public function updateCard(array $parameters = []) |
|
128 | + public function updateCard( array $parameters = [] ) |
|
129 | 129 | { |
130 | - return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\UpdateCardRequest', $parameters); |
|
130 | + return $this->createRequest( '\Omnipay\FirstAtlanticCommerce\Message\UpdateCardRequest', $parameters ); |
|
131 | 131 | } |
132 | 132 | } |
@@ -8,23 +8,20 @@ discard block |
||
8 | 8 | /** |
9 | 9 | * First Atlantic Commerce Payment Gateway 2 (XML POST Service) |
10 | 10 | */ |
11 | -class Gateway extends AbstractGateway |
|
12 | -{ |
|
11 | +class Gateway extends AbstractGateway { |
|
13 | 12 | use ParameterTrait; |
14 | 13 | |
15 | 14 | /** |
16 | 15 | * @return string Gateway name. |
17 | 16 | */ |
18 | - public function getName() |
|
19 | - { |
|
17 | + public function getName() { |
|
20 | 18 | return 'First Atlantic Commerce Payment Gateway 2'; |
21 | 19 | } |
22 | 20 | |
23 | 21 | /** |
24 | 22 | * @return array Default parameters. |
25 | 23 | */ |
26 | - public function getDefaultParameters() |
|
27 | - { |
|
24 | + public function getDefaultParameters() { |
|
28 | 25 | return [ |
29 | 26 | 'merchantId' => null, |
30 | 27 | 'merchantPassword' => null, |
@@ -41,8 +38,7 @@ discard block |
||
41 | 38 | * |
42 | 39 | * @return \Omnipay\FirstAtlanticCommerce\Message\AuthorizeRequest |
43 | 40 | */ |
44 | - public function authorize(array $parameters = []) |
|
45 | - { |
|
41 | + public function authorize(array $parameters = []) { |
|
46 | 42 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\AuthorizeRequest', $parameters); |
47 | 43 | } |
48 | 44 | |
@@ -53,8 +49,7 @@ discard block |
||
53 | 49 | * |
54 | 50 | * @return \Omnipay\FirstAtlanticCommerce\Message\CaptureRequest |
55 | 51 | */ |
56 | - public function capture(array $parameters = []) |
|
57 | - { |
|
52 | + public function capture(array $parameters = []) { |
|
58 | 53 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\CaptureRequest', $parameters); |
59 | 54 | } |
60 | 55 | |
@@ -65,8 +60,7 @@ discard block |
||
65 | 60 | * |
66 | 61 | * @return \Omnipay\FirstAtlanticCommerce\Message\PurchaseRequest |
67 | 62 | */ |
68 | - public function purchase(array $parameters = []) |
|
69 | - { |
|
63 | + public function purchase(array $parameters = []) { |
|
70 | 64 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\PurchaseRequest', $parameters); |
71 | 65 | } |
72 | 66 | |
@@ -77,8 +71,7 @@ discard block |
||
77 | 71 | * |
78 | 72 | * @return \Omnipay\FirstAtlanticCommerce\Message\RefundRequest |
79 | 73 | */ |
80 | - public function refund(array $parameters = []) |
|
81 | - { |
|
74 | + public function refund(array $parameters = []) { |
|
82 | 75 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\RefundRequest', $parameters); |
83 | 76 | } |
84 | 77 | |
@@ -89,8 +82,7 @@ discard block |
||
89 | 82 | * |
90 | 83 | * @return \Omnipay\FirstAtlanticCommerce\Message\VoidRequest |
91 | 84 | */ |
92 | - public function void(array $parameters = []) |
|
93 | - { |
|
85 | + public function void(array $parameters = []) { |
|
94 | 86 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\VoidRequest', $parameters); |
95 | 87 | } |
96 | 88 | |
@@ -101,8 +93,7 @@ discard block |
||
101 | 93 | * |
102 | 94 | * @return \Omnipay\FirstAtlanticCommerce\Message\StatusRequest |
103 | 95 | */ |
104 | - public function status(array $parameters = []) |
|
105 | - { |
|
96 | + public function status(array $parameters = []) { |
|
106 | 97 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\StatusRequest', $parameters); |
107 | 98 | } |
108 | 99 | |
@@ -113,8 +104,7 @@ discard block |
||
113 | 104 | * |
114 | 105 | * @return \Omnipay\FirstAtlanticCommerce\Message\CreateCardRequest |
115 | 106 | */ |
116 | - public function createCard(array $parameters = []) |
|
117 | - { |
|
107 | + public function createCard(array $parameters = []) { |
|
118 | 108 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\CreateCardRequest', $parameters); |
119 | 109 | } |
120 | 110 | |
@@ -125,8 +115,7 @@ discard block |
||
125 | 115 | * |
126 | 116 | * @return \Omnipay\FirstAtlanticCommerce\Message\UpdateCardRequest |
127 | 117 | */ |
128 | - public function updateCard(array $parameters = []) |
|
129 | - { |
|
118 | + public function updateCard(array $parameters = []) { |
|
130 | 119 | return $this->createRequest('\Omnipay\FirstAtlanticCommerce\Message\UpdateCardRequest', $parameters); |
131 | 120 | } |
132 | 121 | } |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | { |
23 | 23 | $parameters = func_get_args(); |
24 | 24 | |
25 | - if ( count($parameters) == 0 ) |
|
25 | + if ( count( $parameters ) == 0 ) |
|
26 | 26 | { |
27 | 27 | $parameters = ['number', 'cvv', 'expiryMonth', 'expiryYear']; |
28 | 28 | } |
29 | 29 | |
30 | - foreach ($parameters as $key) |
|
30 | + foreach ( $parameters as $key ) |
|
31 | 31 | { |
32 | - $value = $this->parameters->get($key); |
|
32 | + $value = $this->parameters->get( $key ); |
|
33 | 33 | |
34 | 34 | if ( empty($value) ) |
35 | 35 | { |
36 | - throw new InvalidCreditCardException("The $key parameter is required"); |
|
36 | + throw new InvalidCreditCardException( "The $key parameter is required" ); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | if ( isset($parameters['expiryMonth']) && isset($parameters['expiryYear']) ) |
41 | 41 | { |
42 | - if ( $this->getExpiryDate('Ym') < gmdate('Ym') ) |
|
42 | + if ( $this->getExpiryDate( 'Ym' ) < gmdate( 'Ym' ) ) |
|
43 | 43 | { |
44 | - throw new InvalidCreditCardException('Card has expired'); |
|
44 | + throw new InvalidCreditCardException( 'Card has expired' ); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | { |
50 | 50 | if ( !Helper::validateLuhn( $this->getNumber() ) ) |
51 | 51 | { |
52 | - throw new InvalidCreditCardException('Card number is invalid'); |
|
52 | + throw new InvalidCreditCardException( 'Card number is invalid' ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if ( !is_null( $this->getNumber() ) && !preg_match( '/^\d{12,19}$/i', $this->getNumber() ) ) |
56 | 56 | { |
57 | - throw new InvalidCreditCardException('Card number should have 12 to 19 digits'); |
|
57 | + throw new InvalidCreditCardException( 'Card number should have 12 to 19 digits' ); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | if ( !is_null( $this->getCvv() ) && !preg_match( '/^\d{3,4}$/i', $this->getCvv() ) ) |
64 | 64 | { |
65 | - throw new InvalidCreditCardException('Card CVV should have 3 to 4 digits'); |
|
65 | + throw new InvalidCreditCardException( 'Card CVV should have 3 to 4 digits' ); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use Omnipay\Common\CreditCard as BaseCreditCard; |
6 | 6 | use Omnipay\Common\Exception\InvalidCreditCardException; |
7 | 7 | |
8 | -class CreditCard extends BaseCreditCard |
|
9 | -{ |
|
8 | +class CreditCard extends BaseCreditCard { |
|
10 | 9 | /** |
11 | 10 | * Validate this credit card. If the card is invalid, InvalidCreditCardException is thrown. |
12 | 11 | * |
@@ -18,50 +17,39 @@ discard block |
||
18 | 17 | * @param string ... Optional variable length list of required parameters |
19 | 18 | * @throws InvalidCreditCardException |
20 | 19 | */ |
21 | - public function validate() |
|
22 | - { |
|
20 | + public function validate() { |
|
23 | 21 | $parameters = func_get_args(); |
24 | 22 | |
25 | - if ( count($parameters) == 0 ) |
|
26 | - { |
|
23 | + if ( count($parameters) == 0 ) { |
|
27 | 24 | $parameters = ['number', 'cvv', 'expiryMonth', 'expiryYear']; |
28 | 25 | } |
29 | 26 | |
30 | - foreach ($parameters as $key) |
|
31 | - { |
|
27 | + foreach ($parameters as $key) { |
|
32 | 28 | $value = $this->parameters->get($key); |
33 | 29 | |
34 | - if ( empty($value) ) |
|
35 | - { |
|
30 | + if ( empty($value) ) { |
|
36 | 31 | throw new InvalidCreditCardException("The $key parameter is required"); |
37 | 32 | } |
38 | 33 | } |
39 | 34 | |
40 | - if ( isset($parameters['expiryMonth']) && isset($parameters['expiryYear']) ) |
|
41 | - { |
|
42 | - if ( $this->getExpiryDate('Ym') < gmdate('Ym') ) |
|
43 | - { |
|
35 | + if ( isset($parameters['expiryMonth']) && isset($parameters['expiryYear']) ) { |
|
36 | + if ( $this->getExpiryDate('Ym') < gmdate('Ym') ) { |
|
44 | 37 | throw new InvalidCreditCardException('Card has expired'); |
45 | 38 | } |
46 | 39 | } |
47 | 40 | |
48 | - if ( isset($parameters['number']) ) |
|
49 | - { |
|
50 | - if ( !Helper::validateLuhn( $this->getNumber() ) ) |
|
51 | - { |
|
41 | + if ( isset($parameters['number']) ) { |
|
42 | + if ( !Helper::validateLuhn( $this->getNumber() ) ) { |
|
52 | 43 | throw new InvalidCreditCardException('Card number is invalid'); |
53 | 44 | } |
54 | 45 | |
55 | - if ( !is_null( $this->getNumber() ) && !preg_match( '/^\d{12,19}$/i', $this->getNumber() ) ) |
|
56 | - { |
|
46 | + if ( !is_null( $this->getNumber() ) && !preg_match( '/^\d{12,19}$/i', $this->getNumber() ) ) { |
|
57 | 47 | throw new InvalidCreditCardException('Card number should have 12 to 19 digits'); |
58 | 48 | } |
59 | 49 | } |
60 | 50 | |
61 | - if ( isset($parameters['cvv']) ) |
|
62 | - { |
|
63 | - if ( !is_null( $this->getCvv() ) && !preg_match( '/^\d{3,4}$/i', $this->getCvv() ) ) |
|
64 | - { |
|
51 | + if ( isset($parameters['cvv']) ) { |
|
52 | + if ( !is_null( $this->getCvv() ) && !preg_match( '/^\d{3,4}$/i', $this->getCvv() ) ) { |
|
65 | 53 | throw new InvalidCreditCardException('Card CVV should have 3 to 4 digits'); |
66 | 54 | } |
67 | 55 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | if ( empty($value) ) |
35 | 35 | { |
36 | - throw new InvalidCreditCardException("The $key parameter is required"); |
|
36 | + throw new InvalidCreditCardException("the $key parameter is required"); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 |
@@ -7,8 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * FACPG2 Reversal Request |
9 | 9 | */ |
10 | -class VoidRequest extends TransactionModificationRequest |
|
11 | -{ |
|
10 | +class VoidRequest extends TransactionModificationRequest { |
|
12 | 11 | /** |
13 | 12 | * Flag as a reversal |
14 | 13 | * |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $signature .= $this->formatAmount(); |
39 | 39 | $signature .= $this->getCurrencyNumeric(); |
40 | 40 | |
41 | - return base64_encode( sha1($signature, true) ); |
|
41 | + return base64_encode( sha1( $signature, true ) ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,23 +48,23 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getData() |
50 | 50 | { |
51 | - $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount', 'currency', 'card'); |
|
51 | + $this->validate( 'merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount', 'currency', 'card' ); |
|
52 | 52 | |
53 | 53 | // Check for AVS and require billingAddress1 and billingPostcode |
54 | 54 | if ( $this->getRequireAvsCheck() ) |
55 | 55 | { |
56 | - $this->getCard()->validate('billingAddress1', 'billingPostcode'); |
|
56 | + $this->getCard()->validate( 'billingAddress1', 'billingPostcode' ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tokenized cards require the CVV and nothing else, token replaces the card number |
60 | 60 | if ( $this->getCardReference() ) |
61 | 61 | { |
62 | - $this->validate('cardReference'); |
|
63 | - $this->getCard()->validate('cvv', 'expiryMonth', 'expiryYear'); |
|
62 | + $this->validate( 'cardReference' ); |
|
63 | + $this->getCard()->validate( 'cvv', 'expiryMonth', 'expiryYear' ); |
|
64 | 64 | |
65 | 65 | $cardDetails = [ |
66 | 66 | 'CardCVV2' => $this->getCard()->getCvv(), |
67 | - 'CardExpiryDate' => $this->getCard()->getExpiryDate('my'), |
|
67 | + 'CardExpiryDate' => $this->getCard()->getExpiryDate( 'my' ), |
|
68 | 68 | 'CardNumber' => $this->getCardReference() |
69 | 69 | ]; |
70 | 70 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $cardDetails = [ |
76 | 76 | 'CardCVV2' => $this->getCard()->getCvv(), |
77 | - 'CardExpiryDate' => $this->getCard()->getExpiryDate('my'), |
|
77 | + 'CardExpiryDate' => $this->getCard()->getExpiryDate( 'my' ), |
|
78 | 78 | 'CardNumber' => $this->getCard()->getNumber(), |
79 | 79 | 'IssueNumber' => $this->getCard()->getIssueNumber() |
80 | 80 | ]; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Only pass the StartDate if year/month are set otherwise it returns 1299 |
84 | 84 | if ( $this->getCard()->getStartYear() && $this->getCard()->getStartMonth() ) |
85 | 85 | { |
86 | - $cardDetails['StartDate'] = $this->getCard()->getStartDate('my'); |
|
86 | + $cardDetails['StartDate'] = $this->getCard()->getStartDate( 'my' ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $transactionDetails = [ |
@@ -137,21 +137,21 @@ discard block |
||
137 | 137 | { |
138 | 138 | $country = $this->getCard()->getCountry(); |
139 | 139 | |
140 | - if ( !is_null($country) && !is_numeric($country) ) |
|
140 | + if ( !is_null( $country ) && !is_numeric( $country ) ) |
|
141 | 141 | { |
142 | 142 | $iso3166 = new ISO3166; |
143 | 143 | |
144 | - if ( strlen($country) == 2 ) |
|
144 | + if ( strlen( $country ) == 2 ) |
|
145 | 145 | { |
146 | - $country = $iso3166->getByAlpha2($country)['numeric']; |
|
146 | + $country = $iso3166->getByAlpha2( $country )['numeric']; |
|
147 | 147 | } |
148 | - elseif ( strlen($country) == 3 ) |
|
148 | + elseif ( strlen( $country ) == 3 ) |
|
149 | 149 | { |
150 | - $country = $iso3166->getByAlpha3($country)['numeric']; |
|
150 | + $country = $iso3166->getByAlpha3( $country )['numeric']; |
|
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - throw new InvalidRequestException("The country parameter must be ISO 3166-1 numeric, aplha2 or alpha3."); |
|
154 | + throw new InvalidRequestException( "The country parameter must be ISO 3166-1 numeric, aplha2 or alpha3." ); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | { |
170 | 170 | $state = $this->getCard()->getState(); |
171 | 171 | |
172 | - if ( strlen($state) != 2 ) |
|
172 | + if ( strlen( $state ) != 2 ) |
|
173 | 173 | { |
174 | - throw new InvalidRequestException("The state must be a two character abbreviation."); |
|
174 | + throw new InvalidRequestException( "The state must be a two character abbreviation." ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $state; |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | { |
190 | 190 | $postal = preg_replace( '/[\s\-]/', '', $this->getCard()->getPostcode() ); |
191 | 191 | |
192 | - if ( preg_match('/[^a-z0-9]/i', $postal) ) |
|
192 | + if ( preg_match( '/[^a-z0-9]/i', $postal ) ) |
|
193 | 193 | { |
194 | - throw new InvalidRequestException("The postal code must be alpha-numeric."); |
|
194 | + throw new InvalidRequestException( "The postal code must be alpha-numeric." ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $postal; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function getEndpoint() |
206 | 206 | { |
207 | - return parent::getEndpoint() . 'Authorize'; |
|
207 | + return parent::getEndpoint().'Authorize'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return AuthorizeResponse |
226 | 226 | */ |
227 | - protected function newResponse($xml) |
|
227 | + protected function newResponse( $xml ) |
|
228 | 228 | { |
229 | - return new AuthorizeResponse($this, $xml); |
|
229 | + return new AuthorizeResponse( $this, $xml ); |
|
230 | 230 | } |
231 | 231 | } |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * FACPG2 Authorize Request |
11 | 11 | */ |
12 | -class AuthorizeRequest extends AbstractRequest |
|
13 | -{ |
|
12 | +class AuthorizeRequest extends AbstractRequest { |
|
14 | 13 | /** |
15 | 14 | * @var string; |
16 | 15 | */ |
@@ -29,8 +28,7 @@ discard block |
||
29 | 28 | * @return string base64 encoded sha1 hash of the merchantPassword, merchantId, |
30 | 29 | * acquirerId, transactionId, amount and currency code. |
31 | 30 | */ |
32 | - protected function generateSignature() |
|
33 | - { |
|
31 | + protected function generateSignature() { |
|
34 | 32 | $signature = $this->getMerchantPassword(); |
35 | 33 | $signature .= $this->getMerchantId(); |
36 | 34 | $signature .= $this->getAcquirerId(); |
@@ -46,19 +44,16 @@ discard block |
||
46 | 44 | * |
47 | 45 | * @return array |
48 | 46 | */ |
49 | - public function getData() |
|
50 | - { |
|
47 | + public function getData() { |
|
51 | 48 | $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount', 'currency', 'card'); |
52 | 49 | |
53 | 50 | // Check for AVS and require billingAddress1 and billingPostcode |
54 | - if ( $this->getRequireAvsCheck() ) |
|
55 | - { |
|
51 | + if ( $this->getRequireAvsCheck() ) { |
|
56 | 52 | $this->getCard()->validate('billingAddress1', 'billingPostcode'); |
57 | 53 | } |
58 | 54 | |
59 | 55 | // Tokenized cards require the CVV and nothing else, token replaces the card number |
60 | - if ( $this->getCardReference() ) |
|
61 | - { |
|
56 | + if ( $this->getCardReference() ) { |
|
62 | 57 | $this->validate('cardReference'); |
63 | 58 | $this->getCard()->validate('cvv', 'expiryMonth', 'expiryYear'); |
64 | 59 | |
@@ -67,9 +62,7 @@ discard block |
||
67 | 62 | 'CardExpiryDate' => $this->getCard()->getExpiryDate('my'), |
68 | 63 | 'CardNumber' => $this->getCardReference() |
69 | 64 | ]; |
70 | - } |
|
71 | - else |
|
72 | - { |
|
65 | + } else { |
|
73 | 66 | $this->getCard()->validate(); |
74 | 67 | |
75 | 68 | $cardDetails = [ |
@@ -81,8 +74,7 @@ discard block |
||
81 | 74 | } |
82 | 75 | |
83 | 76 | // Only pass the StartDate if year/month are set otherwise it returns 1299 |
84 | - if ( $this->getCard()->getStartYear() && $this->getCard()->getStartMonth() ) |
|
85 | - { |
|
77 | + if ( $this->getCard()->getStartYear() && $this->getCard()->getStartMonth() ) { |
|
86 | 78 | $cardDetails['StartDate'] = $this->getCard()->getStartDate('my'); |
87 | 79 | } |
88 | 80 | |
@@ -112,8 +104,7 @@ discard block |
||
112 | 104 | ]; |
113 | 105 | |
114 | 106 | // FAC only accepts two digit state abbreviations from the USA |
115 | - if ( $billingDetails['BillToCountry'] == 840 ) |
|
116 | - { |
|
107 | + if ( $billingDetails['BillToCountry'] == 840 ) { |
|
117 | 108 | $billingDetails['BillToState'] = $this->formatState(); |
118 | 109 | } |
119 | 110 | |
@@ -133,24 +124,17 @@ discard block |
||
133 | 124 | * |
134 | 125 | * @return int ISO 3166-1 numeric country |
135 | 126 | */ |
136 | - protected function formatCountry() |
|
137 | - { |
|
127 | + protected function formatCountry() { |
|
138 | 128 | $country = $this->getCard()->getCountry(); |
139 | 129 | |
140 | - if ( !is_null($country) && !is_numeric($country) ) |
|
141 | - { |
|
130 | + if ( !is_null($country) && !is_numeric($country) ) { |
|
142 | 131 | $iso3166 = new ISO3166; |
143 | 132 | |
144 | - if ( strlen($country) == 2 ) |
|
145 | - { |
|
133 | + if ( strlen($country) == 2 ) { |
|
146 | 134 | $country = $iso3166->getByAlpha2($country)['numeric']; |
147 | - } |
|
148 | - elseif ( strlen($country) == 3 ) |
|
149 | - { |
|
135 | + } elseif ( strlen($country) == 3 ) { |
|
150 | 136 | $country = $iso3166->getByAlpha3($country)['numeric']; |
151 | - } |
|
152 | - else |
|
153 | - { |
|
137 | + } else { |
|
154 | 138 | throw new InvalidRequestException("The country parameter must be ISO 3166-1 numeric, aplha2 or alpha3."); |
155 | 139 | } |
156 | 140 | } |
@@ -165,12 +149,10 @@ discard block |
||
165 | 149 | * |
166 | 150 | * @return string State abbreviation |
167 | 151 | */ |
168 | - public function formatState() |
|
169 | - { |
|
152 | + public function formatState() { |
|
170 | 153 | $state = $this->getCard()->getState(); |
171 | 154 | |
172 | - if ( strlen($state) != 2 ) |
|
173 | - { |
|
155 | + if ( strlen($state) != 2 ) { |
|
174 | 156 | throw new InvalidRequestException("The state must be a two character abbreviation."); |
175 | 157 | } |
176 | 158 | |
@@ -185,12 +167,10 @@ discard block |
||
185 | 167 | * |
186 | 168 | * @return string Postal code |
187 | 169 | */ |
188 | - public function formatPostcode() |
|
189 | - { |
|
170 | + public function formatPostcode() { |
|
190 | 171 | $postal = preg_replace( '/[\s\-]/', '', $this->getCard()->getPostcode() ); |
191 | 172 | |
192 | - if ( preg_match('/[^a-z0-9]/i', $postal) ) |
|
193 | - { |
|
173 | + if ( preg_match('/[^a-z0-9]/i', $postal) ) { |
|
194 | 174 | throw new InvalidRequestException("The postal code must be alpha-numeric."); |
195 | 175 | } |
196 | 176 | |
@@ -202,8 +182,7 @@ discard block |
||
202 | 182 | * |
203 | 183 | * @return string Endpoint URL |
204 | 184 | */ |
205 | - protected function getEndpoint() |
|
206 | - { |
|
185 | + protected function getEndpoint() { |
|
207 | 186 | return parent::getEndpoint() . 'Authorize'; |
208 | 187 | } |
209 | 188 | |
@@ -212,8 +191,7 @@ discard block |
||
212 | 191 | * |
213 | 192 | * @return int Transaction Code |
214 | 193 | */ |
215 | - protected function getTransactionCode() |
|
216 | - { |
|
194 | + protected function getTransactionCode() { |
|
217 | 195 | return $this->getRequireAvsCheck() ? $this->transactionCode + 1 : $this->transactionCode; |
218 | 196 | } |
219 | 197 | |
@@ -224,8 +202,7 @@ discard block |
||
224 | 202 | * |
225 | 203 | * @return AuthorizeResponse |
226 | 204 | */ |
227 | - protected function newResponse($xml) |
|
228 | - { |
|
205 | + protected function newResponse($xml) { |
|
229 | 206 | return new AuthorizeResponse($this, $xml); |
230 | 207 | } |
231 | 208 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $signature .= $this->getMerchantId(); |
27 | 27 | $signature .= $this->getAcquirerId(); |
28 | 28 | |
29 | - return base64_encode( sha1($signature, true) ); |
|
29 | + return base64_encode( sha1( $signature, true ) ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getData() |
38 | 38 | { |
39 | - $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'customerReference', 'card'); |
|
39 | + $this->validate( 'merchantId', 'merchantPassword', 'acquirerId', 'customerReference', 'card' ); |
|
40 | 40 | $this->getCard()->validate(); |
41 | 41 | |
42 | 42 | $data = [ |
43 | 43 | 'CardNumber' => $this->getCard()->getNumber(), |
44 | 44 | 'CustomerReference' => $this->getCustomerReference(), |
45 | - 'ExpiryDate' => $this->getCard()->getExpiryDate('my'), |
|
45 | + 'ExpiryDate' => $this->getCard()->getExpiryDate( 'my' ), |
|
46 | 46 | 'MerchantNumber' => $this->getMerchantId(), |
47 | 47 | 'Signature' => $this->generateSignature() |
48 | 48 | ]; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getCustomerReference() |
59 | 59 | { |
60 | - return $this->getParameter('customerReference'); |
|
60 | + return $this->getParameter( 'customerReference' ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $value |
67 | 67 | */ |
68 | - public function setCustomerReference($value) |
|
68 | + public function setCustomerReference( $value ) |
|
69 | 69 | { |
70 | - return $this->setParameter('customerReference', $value); |
|
70 | + return $this->setParameter( 'customerReference', $value ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function getEndpoint() |
79 | 79 | { |
80 | - return parent::getEndpoint() . 'Tokenize'; |
|
80 | + return parent::getEndpoint().'Tokenize'; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return CreateCardResponse |
89 | 89 | */ |
90 | - protected function newResponse($xml) |
|
90 | + protected function newResponse( $xml ) |
|
91 | 91 | { |
92 | - return new CreateCardResponse($this, $xml); |
|
92 | + return new CreateCardResponse( $this, $xml ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * FACPG2 Tokenize Request |
9 | 9 | */ |
10 | -class CreateCardRequest extends AbstractRequest |
|
11 | -{ |
|
10 | +class CreateCardRequest extends AbstractRequest { |
|
12 | 11 | /** |
13 | 12 | * @var string; |
14 | 13 | */ |
@@ -20,8 +19,7 @@ discard block |
||
20 | 19 | * @return string base64 encoded sha1 hash of the merchantPassword, merchantId, |
21 | 20 | * and acquirerId. |
22 | 21 | */ |
23 | - protected function generateSignature() |
|
24 | - { |
|
22 | + protected function generateSignature() { |
|
25 | 23 | $signature = $this->getMerchantPassword(); |
26 | 24 | $signature .= $this->getMerchantId(); |
27 | 25 | $signature .= $this->getAcquirerId(); |
@@ -34,8 +32,7 @@ discard block |
||
34 | 32 | * |
35 | 33 | * @return array |
36 | 34 | */ |
37 | - public function getData() |
|
38 | - { |
|
35 | + public function getData() { |
|
39 | 36 | $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'customerReference', 'card'); |
40 | 37 | $this->getCard()->validate(); |
41 | 38 | |
@@ -55,8 +52,7 @@ discard block |
||
55 | 52 | * |
56 | 53 | * @return string |
57 | 54 | */ |
58 | - public function getCustomerReference() |
|
59 | - { |
|
55 | + public function getCustomerReference() { |
|
60 | 56 | return $this->getParameter('customerReference'); |
61 | 57 | } |
62 | 58 | |
@@ -65,8 +61,7 @@ discard block |
||
65 | 61 | * |
66 | 62 | * @param string $value |
67 | 63 | */ |
68 | - public function setCustomerReference($value) |
|
69 | - { |
|
64 | + public function setCustomerReference($value) { |
|
70 | 65 | return $this->setParameter('customerReference', $value); |
71 | 66 | } |
72 | 67 | |
@@ -75,8 +70,7 @@ discard block |
||
75 | 70 | * |
76 | 71 | * @return string Endpoint URL |
77 | 72 | */ |
78 | - protected function getEndpoint() |
|
79 | - { |
|
73 | + protected function getEndpoint() { |
|
80 | 74 | return parent::getEndpoint() . 'Tokenize'; |
81 | 75 | } |
82 | 76 | |
@@ -87,8 +81,7 @@ discard block |
||
87 | 81 | * |
88 | 82 | * @return CreateCardResponse |
89 | 83 | */ |
90 | - protected function newResponse($xml) |
|
91 | - { |
|
84 | + protected function newResponse($xml) { |
|
92 | 85 | return new CreateCardResponse($this, $xml); |
93 | 86 | } |
94 | 87 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param RequestInterface $request |
18 | 18 | * @param string $data |
19 | 19 | */ |
20 | - public function __construct(RequestInterface $request, $data) |
|
20 | + public function __construct( RequestInterface $request, $data ) |
|
21 | 21 | { |
22 | 22 | if ( empty($data) ) |
23 | 23 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | $this->request = $request; |
28 | - $this->data = $this->xmlDeserialize($data); |
|
28 | + $this->data = $this->xmlDeserialize( $data ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -9,18 +9,15 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * FACPG2 Transaction Modification Response |
11 | 11 | */ |
12 | -class TransactionModificationResponse extends AbstractResponse |
|
13 | -{ |
|
12 | +class TransactionModificationResponse extends AbstractResponse { |
|
14 | 13 | /** |
15 | 14 | * Constructor |
16 | 15 | * |
17 | 16 | * @param RequestInterface $request |
18 | 17 | * @param string $data |
19 | 18 | */ |
20 | - public function __construct(RequestInterface $request, $data) |
|
21 | - { |
|
22 | - if ( empty($data) ) |
|
23 | - { |
|
19 | + public function __construct(RequestInterface $request, $data) { |
|
20 | + if ( empty($data) ) { |
|
24 | 21 | throw new InvalidResponseException(); |
25 | 22 | } |
26 | 23 | |
@@ -33,8 +30,7 @@ discard block |
||
33 | 30 | * |
34 | 31 | * @return boolean |
35 | 32 | */ |
36 | - public function isSuccessful() |
|
37 | - { |
|
33 | + public function isSuccessful() { |
|
38 | 34 | return isset($this->data['ResponseCode']) && '1' === $this->data['ResponseCode']; |
39 | 35 | } |
40 | 36 | |
@@ -43,8 +39,7 @@ discard block |
||
43 | 39 | * |
44 | 40 | * @return string |
45 | 41 | */ |
46 | - public function getCode() |
|
47 | - { |
|
42 | + public function getCode() { |
|
48 | 43 | return isset($this->data['ReasonCode']) ? $this->data['ReasonCode'] : null; |
49 | 44 | } |
50 | 45 | |
@@ -53,8 +48,7 @@ discard block |
||
53 | 48 | * |
54 | 49 | * @return string |
55 | 50 | */ |
56 | - public function getMessage() |
|
57 | - { |
|
51 | + public function getMessage() { |
|
58 | 52 | return isset($this->data['ReasonCodeDescription']) ? $this->data['ReasonCodeDescription'] : null; |
59 | 53 | } |
60 | 54 | } |
@@ -14,20 +14,20 @@ |
||
14 | 14 | * |
15 | 15 | * @return array data |
16 | 16 | */ |
17 | - protected function xmlDeserialize($xml) |
|
17 | + protected function xmlDeserialize( $xml ) |
|
18 | 18 | { |
19 | 19 | $array = []; |
20 | 20 | |
21 | - if (!$xml instanceof SimpleXMLElement) |
|
21 | + if ( !$xml instanceof SimpleXMLElement ) |
|
22 | 22 | { |
23 | - $xml = new SimpleXMLElement($xml); |
|
23 | + $xml = new SimpleXMLElement( $xml ); |
|
24 | 24 | } |
25 | 25 | |
26 | - foreach ($xml->children() as $key => $child) |
|
26 | + foreach ( $xml->children() as $key => $child ) |
|
27 | 27 | { |
28 | 28 | $value = (string) $child; |
29 | - $_children = $this->xmlDeserialize($child); |
|
30 | - $_push = ( $_hasChild = ( count($_children) > 0 ) ) ? $_children : $value; |
|
29 | + $_children = $this->xmlDeserialize( $child ); |
|
30 | + $_push = ($_hasChild = (count( $_children ) > 0)) ? $_children : $value; |
|
31 | 31 | |
32 | 32 | if ( $_hasChild && !empty($value) && $value !== '' ) |
33 | 33 | { |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse; |
6 | 6 | use SimpleXMLElement; |
7 | 7 | |
8 | -abstract class AbstractResponse extends BaseAbstractResponse |
|
9 | -{ |
|
8 | +abstract class AbstractResponse extends BaseAbstractResponse { |
|
10 | 9 | /** |
11 | 10 | * Seserializes XML to an array |
12 | 11 | * |
@@ -14,23 +13,19 @@ discard block |
||
14 | 13 | * |
15 | 14 | * @return array data |
16 | 15 | */ |
17 | - protected function xmlDeserialize($xml) |
|
18 | - { |
|
16 | + protected function xmlDeserialize($xml) { |
|
19 | 17 | $array = []; |
20 | 18 | |
21 | - if (!$xml instanceof SimpleXMLElement) |
|
22 | - { |
|
19 | + if (!$xml instanceof SimpleXMLElement) { |
|
23 | 20 | $xml = new SimpleXMLElement($xml); |
24 | 21 | } |
25 | 22 | |
26 | - foreach ($xml->children() as $key => $child) |
|
27 | - { |
|
23 | + foreach ($xml->children() as $key => $child) { |
|
28 | 24 | $value = (string) $child; |
29 | 25 | $_children = $this->xmlDeserialize($child); |
30 | 26 | $_push = ( $_hasChild = ( count($_children) > 0 ) ) ? $_children : $value; |
31 | 27 | |
32 | - if ( $_hasChild && !empty($value) && $value !== '' ) |
|
33 | - { |
|
28 | + if ( $_hasChild && !empty($value) && $value !== '' ) { |
|
34 | 29 | $_push[] = $value; |
35 | 30 | } |
36 | 31 |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | { |
49 | 49 | $amount = $this->getAmount(); |
50 | 50 | |
51 | - $amount = str_replace('.', '', $amount); |
|
52 | - $amount = str_pad($amount, 12, '0', STR_PAD_LEFT); |
|
51 | + $amount = str_replace( '.', '', $amount ); |
|
52 | + $amount = str_pad( $amount, 12, '0', STR_PAD_LEFT ); |
|
53 | 53 | |
54 | 54 | return $amount; |
55 | 55 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return ResponseInterface |
73 | 73 | */ |
74 | - abstract protected function newResponse($xml); |
|
74 | + abstract protected function newResponse( $xml ); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Send the request payload |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return ResponseInterface |
82 | 82 | */ |
83 | - public function sendData($data) |
|
83 | + public function sendData( $data ) |
|
84 | 84 | { |
85 | 85 | $httpResponse = $this->httpClient->post( |
86 | 86 | $this->getEndpoint(), |
87 | 87 | ['Content-Type' => 'text/xml; charset=utf-8'], |
88 | - $this->xmlSerialize($data) |
|
88 | + $this->xmlSerialize( $data ) |
|
89 | 89 | )->send(); |
90 | 90 | |
91 | 91 | return $this->response = $this->newResponse( $httpResponse->xml() ); |
@@ -99,28 +99,28 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string XML |
101 | 101 | */ |
102 | - protected function xmlSerialize($data, $xml = null) |
|
102 | + protected function xmlSerialize( $data, $xml = null ) |
|
103 | 103 | { |
104 | 104 | if ( !$xml instanceof SimpleXMLElement ) |
105 | 105 | { |
106 | - $xml = new SimpleXMLElement('<'. $this->requestName .' xmlns="'. $this->namespace .'" />'); |
|
106 | + $xml = new SimpleXMLElement( '<'.$this->requestName.' xmlns="'.$this->namespace.'" />' ); |
|
107 | 107 | } |
108 | 108 | |
109 | - foreach ($data as $key => $value) |
|
109 | + foreach ( $data as $key => $value ) |
|
110 | 110 | { |
111 | 111 | if ( !isset($value) ) |
112 | 112 | { |
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - if ( is_array($value) ) |
|
116 | + if ( is_array( $value ) ) |
|
117 | 117 | { |
118 | - $node = $xml->addChild($key); |
|
119 | - $this->xmlSerialize($value, $node); |
|
118 | + $node = $xml->addChild( $key ); |
|
119 | + $this->xmlSerialize( $value, $node ); |
|
120 | 120 | } |
121 | 121 | else |
122 | 122 | { |
123 | - $xml->addChild($key, $value); |
|
123 | + $xml->addChild( $key, $value ); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return AbstractRequest Provides a fluent interface |
136 | 136 | */ |
137 | - public function setCard($value) |
|
137 | + public function setCard( $value ) |
|
138 | 138 | { |
139 | - if ($value && !$value instanceof CreditCard) |
|
139 | + if ( $value && !$value instanceof CreditCard ) |
|
140 | 140 | { |
141 | - $value = new CreditCard($value); |
|
141 | + $value = new CreditCard( $value ); |
|
142 | 142 | } |
143 | 143 | |
144 | - return $this->setParameter('card', $value); |
|
144 | + return $this->setParameter( 'card', $value ); |
|
145 | 145 | } |
146 | 146 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | use Omnipay\FirstAtlanticCommerce\ParameterTrait; |
8 | 8 | use SimpleXMLElement; |
9 | 9 | |
10 | -abstract class AbstractRequest extends BaseAbstractRequest |
|
11 | -{ |
|
10 | +abstract class AbstractRequest extends BaseAbstractRequest { |
|
12 | 11 | use ParameterTrait; |
13 | 12 | |
14 | 13 | /** |
@@ -44,8 +43,7 @@ discard block |
||
44 | 43 | * |
45 | 44 | * @return string The amount padded with zeros on the left to 12 digits and no decimal place. |
46 | 45 | */ |
47 | - protected function formatAmount() |
|
48 | - { |
|
46 | + protected function formatAmount() { |
|
49 | 47 | $amount = $this->getAmount(); |
50 | 48 | |
51 | 49 | $amount = str_replace('.', '', $amount); |
@@ -59,8 +57,7 @@ discard block |
||
59 | 57 | * |
60 | 58 | * @return string Endpoint URL |
61 | 59 | */ |
62 | - protected function getEndpoint() |
|
63 | - { |
|
60 | + protected function getEndpoint() { |
|
64 | 61 | return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; |
65 | 62 | } |
66 | 63 | |
@@ -80,8 +77,7 @@ discard block |
||
80 | 77 | * |
81 | 78 | * @return ResponseInterface |
82 | 79 | */ |
83 | - public function sendData($data) |
|
84 | - { |
|
80 | + public function sendData($data) { |
|
85 | 81 | $httpResponse = $this->httpClient->post( |
86 | 82 | $this->getEndpoint(), |
87 | 83 | ['Content-Type' => 'text/xml; charset=utf-8'], |
@@ -99,27 +95,20 @@ discard block |
||
99 | 95 | * |
100 | 96 | * @return string XML |
101 | 97 | */ |
102 | - protected function xmlSerialize($data, $xml = null) |
|
103 | - { |
|
104 | - if ( !$xml instanceof SimpleXMLElement ) |
|
105 | - { |
|
98 | + protected function xmlSerialize($data, $xml = null) { |
|
99 | + if ( !$xml instanceof SimpleXMLElement ) { |
|
106 | 100 | $xml = new SimpleXMLElement('<'. $this->requestName .' xmlns="'. $this->namespace .'" />'); |
107 | 101 | } |
108 | 102 | |
109 | - foreach ($data as $key => $value) |
|
110 | - { |
|
111 | - if ( !isset($value) ) |
|
112 | - { |
|
103 | + foreach ($data as $key => $value) { |
|
104 | + if ( !isset($value) ) { |
|
113 | 105 | continue; |
114 | 106 | } |
115 | 107 | |
116 | - if ( is_array($value) ) |
|
117 | - { |
|
108 | + if ( is_array($value) ) { |
|
118 | 109 | $node = $xml->addChild($key); |
119 | 110 | $this->xmlSerialize($value, $node); |
120 | - } |
|
121 | - else |
|
122 | - { |
|
111 | + } else { |
|
123 | 112 | $xml->addChild($key, $value); |
124 | 113 | } |
125 | 114 | } |
@@ -134,10 +123,8 @@ discard block |
||
134 | 123 | * |
135 | 124 | * @return AbstractRequest Provides a fluent interface |
136 | 125 | */ |
137 | - public function setCard($value) |
|
138 | - { |
|
139 | - if ($value && !$value instanceof CreditCard) |
|
140 | - { |
|
126 | + public function setCard($value) { |
|
127 | + if ($value && !$value instanceof CreditCard) { |
|
141 | 128 | $value = new CreditCard($value); |
142 | 129 | } |
143 | 130 |