@@ -35,6 +35,9 @@ |
||
35 | 35 | |
36 | 36 | private $value; |
37 | 37 | |
38 | + /** |
|
39 | + * @param string $value |
|
40 | + */ |
|
38 | 41 | public function __construct($value = null) |
39 | 42 | { |
40 | 43 | if ($value) { |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Defines a list of known notification types. |
@@ -29,45 +29,45 @@ discard block |
||
29 | 29 | class PagSeguroNotificationType |
30 | 30 | { |
31 | 31 | |
32 | - private static $typeList = array( |
|
33 | - 'TRANSACTION' => 'transaction' |
|
34 | - ); |
|
32 | + private static $typeList = array( |
|
33 | + 'TRANSACTION' => 'transaction' |
|
34 | + ); |
|
35 | 35 | |
36 | - private $value; |
|
36 | + private $value; |
|
37 | 37 | |
38 | - public function __construct($value = null) |
|
39 | - { |
|
40 | - if ($value) { |
|
41 | - $this->value = $value; |
|
42 | - } |
|
43 | - } |
|
38 | + public function __construct($value = null) |
|
39 | + { |
|
40 | + if ($value) { |
|
41 | + $this->value = $value; |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - public function setValue($value) |
|
46 | - { |
|
47 | - $this->value = $value; |
|
48 | - } |
|
45 | + public function setValue($value) |
|
46 | + { |
|
47 | + $this->value = $value; |
|
48 | + } |
|
49 | 49 | |
50 | - public function setByType($type) |
|
51 | - { |
|
52 | - if (isset(self::$typeList[$type])) { |
|
53 | - $this->value = self::$typeList[$type]; |
|
54 | - } else { |
|
55 | - throw new Exception("undefined index $type"); |
|
56 | - } |
|
57 | - } |
|
50 | + public function setByType($type) |
|
51 | + { |
|
52 | + if (isset(self::$typeList[$type])) { |
|
53 | + $this->value = self::$typeList[$type]; |
|
54 | + } else { |
|
55 | + throw new Exception("undefined index $type"); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - public function getValue() |
|
60 | - { |
|
61 | - return $this->value; |
|
62 | - } |
|
59 | + public function getValue() |
|
60 | + { |
|
61 | + return $this->value; |
|
62 | + } |
|
63 | 63 | |
64 | - /*** |
|
64 | + /*** |
|
65 | 65 | * @param value |
66 | 66 | * @return the PagSeguroNotificationType corresponding to the informed value |
67 | 67 | */ |
68 | - public function getTypeFromValue($value = null) |
|
69 | - { |
|
70 | - $value = ($value == null ? $this->value : $value); |
|
71 | - return array_search($this->value, self::$typeList); |
|
72 | - } |
|
68 | + public function getTypeFromValue($value = null) |
|
69 | + { |
|
70 | + $value = ($value == null ? $this->value : $value); |
|
71 | + return array_search($this->value, self::$typeList); |
|
72 | + } |
|
73 | 73 | } |
@@ -94,6 +94,10 @@ |
||
94 | 94 | * Sets the Sender e-mail |
95 | 95 | * @param email |
96 | 96 | */ |
97 | + |
|
98 | + /** |
|
99 | + * @param string|null $email |
|
100 | + */ |
|
97 | 101 | public function setEmail($email) |
98 | 102 | { |
99 | 103 | $this->email = $email; |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Represents the party on the transaction that is sending the money |
@@ -27,182 +27,182 @@ discard block |
||
27 | 27 | class PagSeguroSender |
28 | 28 | { |
29 | 29 | |
30 | - /*** Sender name */ |
|
31 | - private $name; |
|
30 | + /*** Sender name */ |
|
31 | + private $name; |
|
32 | 32 | |
33 | - /*** Sender email */ |
|
34 | - private $email; |
|
33 | + /*** Sender email */ |
|
34 | + private $email; |
|
35 | 35 | |
36 | - /*** Sender phone */ |
|
37 | - private $phone; |
|
36 | + /*** Sender phone */ |
|
37 | + private $phone; |
|
38 | 38 | |
39 | - /*** Sender documents */ |
|
40 | - private $documents; |
|
39 | + /*** Sender documents */ |
|
40 | + private $documents; |
|
41 | 41 | |
42 | - /*** Sender IP */ |
|
43 | - private $ip; |
|
42 | + /*** Sender IP */ |
|
43 | + private $ip; |
|
44 | 44 | |
45 | - /*** |
|
45 | + /*** |
|
46 | 46 | * Initializes a new instance of the Sender class |
47 | 47 | * |
48 | 48 | * @param array $data |
49 | 49 | */ |
50 | - public function __construct(array $data = null) |
|
51 | - { |
|
52 | - if ($data) { |
|
53 | - if (isset($data['name'])) { |
|
54 | - $this->name = $data['name']; |
|
55 | - } |
|
56 | - if (isset($data['email'])) { |
|
57 | - $this->email = $data['email']; |
|
58 | - } |
|
59 | - if (isset($data['phone']) && $data['phone'] instanceof PagSeguroPhone) { |
|
60 | - $this->phone = $data['phone']; |
|
61 | - } else { |
|
62 | - if (isset($data['areaCode']) && isset($data['number'])) { |
|
63 | - $phone = new PagSeguroPhone($data['areaCode'], $data['number']); |
|
64 | - $this->phone = $phone; |
|
65 | - } |
|
66 | - } |
|
67 | - if (isset($data['documents']) && is_array($data['documents'])) { |
|
68 | - $this->setDocuments($data['documents']); |
|
69 | - } |
|
70 | - if (isset($data['ip'])) { |
|
71 | - $this->getIP(); |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - /*** |
|
50 | + public function __construct(array $data = null) |
|
51 | + { |
|
52 | + if ($data) { |
|
53 | + if (isset($data['name'])) { |
|
54 | + $this->name = $data['name']; |
|
55 | + } |
|
56 | + if (isset($data['email'])) { |
|
57 | + $this->email = $data['email']; |
|
58 | + } |
|
59 | + if (isset($data['phone']) && $data['phone'] instanceof PagSeguroPhone) { |
|
60 | + $this->phone = $data['phone']; |
|
61 | + } else { |
|
62 | + if (isset($data['areaCode']) && isset($data['number'])) { |
|
63 | + $phone = new PagSeguroPhone($data['areaCode'], $data['number']); |
|
64 | + $this->phone = $phone; |
|
65 | + } |
|
66 | + } |
|
67 | + if (isset($data['documents']) && is_array($data['documents'])) { |
|
68 | + $this->setDocuments($data['documents']); |
|
69 | + } |
|
70 | + if (isset($data['ip'])) { |
|
71 | + $this->getIP(); |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + /*** |
|
77 | 77 | * Sets the sender name |
78 | 78 | * @param String $name |
79 | 79 | */ |
80 | - public function setName($name) |
|
81 | - { |
|
82 | - $this->name = PagSeguroHelper::formatString($name, 50, ''); |
|
83 | - } |
|
80 | + public function setName($name) |
|
81 | + { |
|
82 | + $this->name = PagSeguroHelper::formatString($name, 50, ''); |
|
83 | + } |
|
84 | 84 | |
85 | - /*** |
|
85 | + /*** |
|
86 | 86 | * @return String the sender name |
87 | 87 | */ |
88 | - public function getName() |
|
89 | - { |
|
90 | - return $this->name; |
|
91 | - } |
|
88 | + public function getName() |
|
89 | + { |
|
90 | + return $this->name; |
|
91 | + } |
|
92 | 92 | |
93 | - /*** |
|
93 | + /*** |
|
94 | 94 | * Sets the Sender e-mail |
95 | 95 | * @param email |
96 | 96 | */ |
97 | - public function setEmail($email) |
|
98 | - { |
|
99 | - $this->email = $email; |
|
100 | - } |
|
97 | + public function setEmail($email) |
|
98 | + { |
|
99 | + $this->email = $email; |
|
100 | + } |
|
101 | 101 | |
102 | - /*** |
|
102 | + /*** |
|
103 | 103 | * @return String the sender e-mail |
104 | 104 | */ |
105 | - public function getEmail() |
|
106 | - { |
|
107 | - return $this->email; |
|
108 | - } |
|
105 | + public function getEmail() |
|
106 | + { |
|
107 | + return $this->email; |
|
108 | + } |
|
109 | 109 | |
110 | - /*** |
|
110 | + /*** |
|
111 | 111 | * Sets the sender phone |
112 | 112 | * @param String $areaCode |
113 | 113 | * @param String $number |
114 | 114 | */ |
115 | - public function setPhone($areaCode, $number = null) |
|
116 | - { |
|
117 | - $param = $areaCode; |
|
118 | - if ($param instanceof PagSeguroPhone) { |
|
119 | - $this->phone = $param; |
|
120 | - } elseif ($number) { |
|
121 | - $phone = new PagSeguroPhone(); |
|
122 | - $phone->setAreaCode($areaCode); |
|
123 | - $phone->setNumber($number); |
|
124 | - $this->phone = $phone; |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - /*** |
|
115 | + public function setPhone($areaCode, $number = null) |
|
116 | + { |
|
117 | + $param = $areaCode; |
|
118 | + if ($param instanceof PagSeguroPhone) { |
|
119 | + $this->phone = $param; |
|
120 | + } elseif ($number) { |
|
121 | + $phone = new PagSeguroPhone(); |
|
122 | + $phone->setAreaCode($areaCode); |
|
123 | + $phone->setNumber($number); |
|
124 | + $this->phone = $phone; |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + /*** |
|
129 | 129 | * @return PagSeguroPhone the sender phone |
130 | 130 | * @see PagSeguroPhone |
131 | 131 | */ |
132 | - public function getPhone() |
|
133 | - { |
|
134 | - return $this->phone; |
|
135 | - } |
|
132 | + public function getPhone() |
|
133 | + { |
|
134 | + return $this->phone; |
|
135 | + } |
|
136 | 136 | |
137 | - /*** |
|
137 | + /*** |
|
138 | 138 | * Get Sender documents |
139 | 139 | * @return array PagSeguroDocument List of PagSeguroDocument |
140 | 140 | * @see PagSeguroDocument |
141 | 141 | */ |
142 | - public function getDocuments() |
|
143 | - { |
|
144 | - return $this->documents; |
|
145 | - } |
|
142 | + public function getDocuments() |
|
143 | + { |
|
144 | + return $this->documents; |
|
145 | + } |
|
146 | 146 | |
147 | - /*** |
|
147 | + /*** |
|
148 | 148 | * Set PagSeguro documents |
149 | 149 | * @param array $documents |
150 | 150 | * @see PagSeguroDocument |
151 | 151 | */ |
152 | - public function setDocuments(array $documents) |
|
153 | - { |
|
154 | - if (count($documents) > 0) { |
|
155 | - foreach ($documents as $document) { |
|
156 | - if ($document instanceof PagSeguroSenderDocument) { |
|
157 | - $this->documents[] = $document; |
|
158 | - } else { |
|
159 | - if (is_array($document)) { |
|
160 | - $this->addDocument($document['type'], $document['value']); |
|
161 | - } |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - /*** |
|
152 | + public function setDocuments(array $documents) |
|
153 | + { |
|
154 | + if (count($documents) > 0) { |
|
155 | + foreach ($documents as $document) { |
|
156 | + if ($document instanceof PagSeguroSenderDocument) { |
|
157 | + $this->documents[] = $document; |
|
158 | + } else { |
|
159 | + if (is_array($document)) { |
|
160 | + $this->addDocument($document['type'], $document['value']); |
|
161 | + } |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + /*** |
|
168 | 168 | * Add a document for Sender object |
169 | 169 | * @param String $type |
170 | 170 | * @param String $value |
171 | 171 | */ |
172 | - public function addDocument($type, $value) |
|
173 | - { |
|
174 | - if ($type && $value) { |
|
175 | - if (count($this->documents) == 0) { |
|
176 | - $document = new PagSeguroSenderDocument($type, $value); |
|
177 | - $this->documents[] = $document; |
|
178 | - } |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - /*** |
|
172 | + public function addDocument($type, $value) |
|
173 | + { |
|
174 | + if ($type && $value) { |
|
175 | + if (count($this->documents) == 0) { |
|
176 | + $document = new PagSeguroSenderDocument($type, $value); |
|
177 | + $this->documents[] = $document; |
|
178 | + } |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + /*** |
|
183 | 183 | * Add an ip for Sender object |
184 | 184 | */ |
185 | - public function getIP() |
|
186 | - { |
|
187 | - if ( function_exists( 'apache_request_headers' ) ) { |
|
188 | - $headers = apache_request_headers(); |
|
189 | - } else { |
|
190 | - $headers = $_SERVER; |
|
191 | - } |
|
185 | + public function getIP() |
|
186 | + { |
|
187 | + if ( function_exists( 'apache_request_headers' ) ) { |
|
188 | + $headers = apache_request_headers(); |
|
189 | + } else { |
|
190 | + $headers = $_SERVER; |
|
191 | + } |
|
192 | 192 | |
193 | - if ( array_key_exists( 'X-Forwarded-For', $headers ) |
|
194 | - && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { |
|
195 | - $ip = $headers['X-Forwarded-For']; |
|
193 | + if ( array_key_exists( 'X-Forwarded-For', $headers ) |
|
194 | + && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { |
|
195 | + $ip = $headers['X-Forwarded-For']; |
|
196 | 196 | |
197 | - } elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) |
|
198 | - && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { |
|
197 | + } elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) |
|
198 | + && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { |
|
199 | 199 | |
200 | - $ip = $headers['HTTP_X_FORWARDED_FOR']; |
|
200 | + $ip = $headers['HTTP_X_FORWARDED_FOR']; |
|
201 | 201 | |
202 | - } else { |
|
203 | - $ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP ); |
|
204 | - } |
|
202 | + } else { |
|
203 | + $ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP ); |
|
204 | + } |
|
205 | 205 | |
206 | - $this->ip = $ip; |
|
207 | - } |
|
206 | + $this->ip = $ip; |
|
207 | + } |
|
208 | 208 | } |
@@ -184,23 +184,23 @@ |
||
184 | 184 | */ |
185 | 185 | public function getIP() |
186 | 186 | { |
187 | - if ( function_exists( 'apache_request_headers' ) ) { |
|
187 | + if (function_exists('apache_request_headers')) { |
|
188 | 188 | $headers = apache_request_headers(); |
189 | 189 | } else { |
190 | 190 | $headers = $_SERVER; |
191 | 191 | } |
192 | 192 | |
193 | - if ( array_key_exists( 'X-Forwarded-For', $headers ) |
|
194 | - && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { |
|
193 | + if (array_key_exists('X-Forwarded-For', $headers) |
|
194 | + && filter_var($headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
195 | 195 | $ip = $headers['X-Forwarded-For']; |
196 | 196 | |
197 | - } elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) |
|
198 | - && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { |
|
197 | + } elseif (array_key_exists('HTTP_X_FORWARDED_FOR', $headers) |
|
198 | + && filter_var($headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
199 | 199 | |
200 | 200 | $ip = $headers['HTTP_X_FORWARDED_FOR']; |
201 | 201 | |
202 | 202 | } else { |
203 | - $ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP ); |
|
203 | + $ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $this->ip = $ip; |
@@ -66,6 +66,10 @@ discard block |
||
66 | 66 | * @param $type |
67 | 67 | * @throws Exception |
68 | 68 | */ |
69 | + |
|
70 | + /** |
|
71 | + * @param string $type |
|
72 | + */ |
|
69 | 73 | public function setByType($type) |
70 | 74 | { |
71 | 75 | if (isset(self::$typeList[$type])) { |
@@ -97,6 +101,10 @@ discard block |
||
97 | 101 | * @param string |
98 | 102 | * @return integer the code corresponding to the informed shipping type |
99 | 103 | */ |
104 | + |
|
105 | + /** |
|
106 | + * @param string $type |
|
107 | + */ |
|
100 | 108 | public static function getCodeByType($type) |
101 | 109 | { |
102 | 110 | if (isset(self::$typeList[$type])) { |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Defines a list of known shipping types. |
@@ -29,91 +29,91 @@ discard block |
||
29 | 29 | class PagSeguroShippingType |
30 | 30 | { |
31 | 31 | |
32 | - /*** |
|
32 | + /*** |
|
33 | 33 | * @var array |
34 | 34 | */ |
35 | - private static $typeList = array( |
|
36 | - 'PAC' => 1, |
|
37 | - 'SEDEX' => 2, |
|
38 | - 'NOT_SPECIFIED' => 3 |
|
39 | - ); |
|
35 | + private static $typeList = array( |
|
36 | + 'PAC' => 1, |
|
37 | + 'SEDEX' => 2, |
|
38 | + 'NOT_SPECIFIED' => 3 |
|
39 | + ); |
|
40 | 40 | |
41 | - /*** |
|
41 | + /*** |
|
42 | 42 | * the shipping type value |
43 | 43 | * Example: 1 |
44 | 44 | */ |
45 | - private $value; |
|
45 | + private $value; |
|
46 | 46 | |
47 | - /*** |
|
47 | + /*** |
|
48 | 48 | * @param null $value |
49 | 49 | */ |
50 | - public function __construct($value = null) |
|
51 | - { |
|
52 | - if ($value) { |
|
53 | - $this->value = $value; |
|
54 | - } |
|
55 | - } |
|
50 | + public function __construct($value = null) |
|
51 | + { |
|
52 | + if ($value) { |
|
53 | + $this->value = $value; |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - /*** |
|
57 | + /*** |
|
58 | 58 | * @param $value |
59 | 59 | */ |
60 | - public function setValue($value) |
|
61 | - { |
|
62 | - $this->value = $value; |
|
63 | - } |
|
60 | + public function setValue($value) |
|
61 | + { |
|
62 | + $this->value = $value; |
|
63 | + } |
|
64 | 64 | |
65 | - /*** |
|
65 | + /*** |
|
66 | 66 | * @param $type |
67 | 67 | * @throws Exception |
68 | 68 | */ |
69 | - public function setByType($type) |
|
70 | - { |
|
71 | - if (isset(self::$typeList[$type])) { |
|
72 | - $this->value = self::$typeList[$type]; |
|
73 | - } else { |
|
74 | - throw new Exception("undefined index $type"); |
|
75 | - } |
|
76 | - } |
|
69 | + public function setByType($type) |
|
70 | + { |
|
71 | + if (isset(self::$typeList[$type])) { |
|
72 | + $this->value = self::$typeList[$type]; |
|
73 | + } else { |
|
74 | + throw new Exception("undefined index $type"); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - /*** |
|
78 | + /*** |
|
79 | 79 | * @return int the value of the shipping type |
80 | 80 | */ |
81 | - public function getValue() |
|
82 | - { |
|
83 | - return $this->value; |
|
84 | - } |
|
81 | + public function getValue() |
|
82 | + { |
|
83 | + return $this->value; |
|
84 | + } |
|
85 | 85 | |
86 | - /*** |
|
86 | + /*** |
|
87 | 87 | * @param value |
88 | 88 | * @return PagSeguroShippingType the PagSeguroShippingType corresponding to the informed value |
89 | 89 | */ |
90 | - public function getTypeFromValue($value = null) |
|
91 | - { |
|
92 | - $value = ($value === null ? $this->value : $value); |
|
93 | - return array_search($value, self::$typeList); |
|
94 | - } |
|
90 | + public function getTypeFromValue($value = null) |
|
91 | + { |
|
92 | + $value = ($value === null ? $this->value : $value); |
|
93 | + return array_search($value, self::$typeList); |
|
94 | + } |
|
95 | 95 | |
96 | - /*** |
|
96 | + /*** |
|
97 | 97 | * @param string |
98 | 98 | * @return integer the code corresponding to the informed shipping type |
99 | 99 | */ |
100 | - public static function getCodeByType($type) |
|
101 | - { |
|
102 | - if (isset(self::$typeList[$type])) { |
|
103 | - return self::$typeList[$type]; |
|
104 | - } else { |
|
105 | - return false; |
|
106 | - } |
|
107 | - } |
|
100 | + public static function getCodeByType($type) |
|
101 | + { |
|
102 | + if (isset(self::$typeList[$type])) { |
|
103 | + return self::$typeList[$type]; |
|
104 | + } else { |
|
105 | + return false; |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - /*** |
|
109 | + /*** |
|
110 | 110 | * @param string $type |
111 | 111 | * @return PagSeguroShippingType a PagSeguroShippingType object corresponding to the informed type |
112 | 112 | */ |
113 | - public static function createByType($type) |
|
114 | - { |
|
115 | - $ShippingType = new PagSeguroShippingType(); |
|
116 | - $ShippingType->setByType($type); |
|
117 | - return $ShippingType; |
|
118 | - } |
|
113 | + public static function createByType($type) |
|
114 | + { |
|
115 | + $ShippingType = new PagSeguroShippingType(); |
|
116 | + $ShippingType->setByType($type); |
|
117 | + return $ShippingType; |
|
118 | + } |
|
119 | 119 | } |
@@ -308,7 +308,7 @@ |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * @return the cancellation source |
|
311 | + * @return PagSeguroTransactionCancellationSource cancellation source |
|
312 | 312 | * @see PagSeguroTransactionCancellationSource |
313 | 313 | */ |
314 | 314 | public function getCancellationSource() |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Represents a summary of a PagSeguro transaction, typically returned by search services. |
@@ -27,327 +27,327 @@ discard block |
||
27 | 27 | class PagSeguroTransactionSummary |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * Transaction date |
32 | 32 | */ |
33 | - private $date; |
|
33 | + private $date; |
|
34 | 34 | |
35 | - /*** |
|
35 | + /*** |
|
36 | 36 | * Last event date |
37 | 37 | * Date the last notification about this transaction was sent |
38 | 38 | */ |
39 | - private $lastEventDate; |
|
39 | + private $lastEventDate; |
|
40 | 40 | |
41 | - /*** |
|
41 | + /*** |
|
42 | 42 | * Transaction code |
43 | 43 | */ |
44 | - private $code; |
|
44 | + private $code; |
|
45 | 45 | |
46 | - /*** |
|
46 | + /*** |
|
47 | 47 | * Reference code |
48 | 48 | * You can use the reference code to store an identifier so you can |
49 | 49 | * associate the PagSeguro transaction to a transaction in your system. |
50 | 50 | */ |
51 | - private $reference; |
|
51 | + private $reference; |
|
52 | 52 | |
53 | - /*** |
|
53 | + /*** |
|
54 | 54 | * Groos amount of the transaction |
55 | 55 | */ |
56 | - private $grossAmount; |
|
56 | + private $grossAmount; |
|
57 | 57 | |
58 | - /*** |
|
58 | + /*** |
|
59 | 59 | * Transaction type |
60 | 60 | * @see PagSeguroTransactionType |
61 | 61 | */ |
62 | - private $type; |
|
62 | + private $type; |
|
63 | 63 | |
64 | - /*** |
|
64 | + /*** |
|
65 | 65 | * Transaction status |
66 | 66 | * @see PagSeguroTransactionStatus |
67 | 67 | */ |
68 | - private $status; |
|
68 | + private $status; |
|
69 | 69 | |
70 | - /*** |
|
70 | + /*** |
|
71 | 71 | * Net amount |
72 | 72 | */ |
73 | - private $netAmount; |
|
73 | + private $netAmount; |
|
74 | 74 | |
75 | - /*** |
|
75 | + /*** |
|
76 | 76 | * Discount amount |
77 | 77 | */ |
78 | - private $discountAmount; |
|
78 | + private $discountAmount; |
|
79 | 79 | |
80 | - /*** |
|
80 | + /*** |
|
81 | 81 | * Fee amount |
82 | 82 | */ |
83 | - private $feeAmount; |
|
83 | + private $feeAmount; |
|
84 | 84 | |
85 | - /*** |
|
85 | + /*** |
|
86 | 86 | * Extra amount |
87 | 87 | */ |
88 | - private $extraAmount; |
|
88 | + private $extraAmount; |
|
89 | 89 | |
90 | - /*** |
|
90 | + /*** |
|
91 | 91 | * Cancellation Source |
92 | 92 | * @see PagSeguroTransactionCancellationSource |
93 | 93 | */ |
94 | - private $cancellationSource; |
|
94 | + private $cancellationSource; |
|
95 | 95 | |
96 | - /** |
|
97 | - * Payment method |
|
98 | - * @see PagSeguroPaymentMethod |
|
99 | - */ |
|
100 | - private $paymentMethod; |
|
96 | + /** |
|
97 | + * Payment method |
|
98 | + * @see PagSeguroPaymentMethod |
|
99 | + */ |
|
100 | + private $paymentMethod; |
|
101 | 101 | |
102 | - /*** |
|
102 | + /*** |
|
103 | 103 | * Recovery Code |
104 | 104 | */ |
105 | - private $recoveryCode; |
|
105 | + private $recoveryCode; |
|
106 | 106 | |
107 | - /*** |
|
107 | + /*** |
|
108 | 108 | * @return the transaction date |
109 | 109 | */ |
110 | - public function getDate() |
|
111 | - { |
|
112 | - return $this->date; |
|
113 | - } |
|
110 | + public function getDate() |
|
111 | + { |
|
112 | + return $this->date; |
|
113 | + } |
|
114 | 114 | |
115 | - /*** |
|
115 | + /*** |
|
116 | 116 | * Sets the transaction date |
117 | 117 | * @param String $date |
118 | 118 | */ |
119 | - public function setDate($date) |
|
120 | - { |
|
121 | - $this->date = $date; |
|
122 | - } |
|
119 | + public function setDate($date) |
|
120 | + { |
|
121 | + $this->date = $date; |
|
122 | + } |
|
123 | 123 | |
124 | - /*** |
|
124 | + /*** |
|
125 | 125 | * @return the transaction code |
126 | 126 | */ |
127 | - public function getCode() |
|
128 | - { |
|
129 | - return $this->code; |
|
130 | - } |
|
127 | + public function getCode() |
|
128 | + { |
|
129 | + return $this->code; |
|
130 | + } |
|
131 | 131 | |
132 | - /*** |
|
132 | + /*** |
|
133 | 133 | * Sets transaction code |
134 | 134 | * @param String $code |
135 | 135 | */ |
136 | - public function setCode($code) |
|
137 | - { |
|
138 | - $this->code = $code; |
|
139 | - } |
|
136 | + public function setCode($code) |
|
137 | + { |
|
138 | + $this->code = $code; |
|
139 | + } |
|
140 | 140 | |
141 | - /*** |
|
141 | + /*** |
|
142 | 142 | * You can use the reference code to store an identifier so you can |
143 | 143 | * associate the PagSeguro transaction to a transaction in your system. |
144 | 144 | * |
145 | 145 | * @return the reference code |
146 | 146 | */ |
147 | - public function getReference() |
|
148 | - { |
|
149 | - return $this->reference; |
|
150 | - } |
|
147 | + public function getReference() |
|
148 | + { |
|
149 | + return $this->reference; |
|
150 | + } |
|
151 | 151 | |
152 | - /*** |
|
152 | + /*** |
|
153 | 153 | * Sets the reference code |
154 | 154 | * |
155 | 155 | * @param reference |
156 | 156 | */ |
157 | - public function setReference($reference) |
|
158 | - { |
|
159 | - $this->reference = $reference; |
|
160 | - } |
|
157 | + public function setReference($reference) |
|
158 | + { |
|
159 | + $this->reference = $reference; |
|
160 | + } |
|
161 | 161 | |
162 | - /*** |
|
162 | + /*** |
|
163 | 163 | * @return the transaction gross amount |
164 | 164 | */ |
165 | - public function getGrossAmount() |
|
166 | - { |
|
167 | - return $this->grossAmount; |
|
168 | - } |
|
165 | + public function getGrossAmount() |
|
166 | + { |
|
167 | + return $this->grossAmount; |
|
168 | + } |
|
169 | 169 | |
170 | - /*** |
|
170 | + /*** |
|
171 | 171 | * Sets the gorss amount |
172 | 172 | * @param float $grossAmount |
173 | 173 | */ |
174 | - public function setGrossAmount($grossAmount) |
|
175 | - { |
|
176 | - $this->grossAmount = $grossAmount; |
|
177 | - } |
|
174 | + public function setGrossAmount($grossAmount) |
|
175 | + { |
|
176 | + $this->grossAmount = $grossAmount; |
|
177 | + } |
|
178 | 178 | |
179 | - /*** |
|
179 | + /*** |
|
180 | 180 | * @return the transaction type |
181 | 181 | * @see PagSeguroTransactionType |
182 | 182 | */ |
183 | - public function getType() |
|
184 | - { |
|
185 | - return $this->type; |
|
186 | - } |
|
183 | + public function getType() |
|
184 | + { |
|
185 | + return $this->type; |
|
186 | + } |
|
187 | 187 | |
188 | - /*** |
|
188 | + /*** |
|
189 | 189 | * Sets the transaction sype |
190 | 190 | * @param PagSeguroTransactionType $type |
191 | 191 | */ |
192 | - public function setType(PagSeguroTransactionType $type) |
|
193 | - { |
|
194 | - $this->type = $type; |
|
195 | - } |
|
192 | + public function setType(PagSeguroTransactionType $type) |
|
193 | + { |
|
194 | + $this->type = $type; |
|
195 | + } |
|
196 | 196 | |
197 | - /*** |
|
197 | + /*** |
|
198 | 198 | * Date the last notification about this transaction was sent |
199 | 199 | * @return the last event date |
200 | 200 | */ |
201 | - public function getLastEventDate() |
|
202 | - { |
|
203 | - return $this->lastEventDate; |
|
204 | - } |
|
201 | + public function getLastEventDate() |
|
202 | + { |
|
203 | + return $this->lastEventDate; |
|
204 | + } |
|
205 | 205 | |
206 | - /*** |
|
206 | + /*** |
|
207 | 207 | * Sets the last event date |
208 | 208 | * @param String $lastEventDate |
209 | 209 | */ |
210 | - public function setLastEventDate($lastEventDate) |
|
211 | - { |
|
212 | - $this->lastEventDate = $lastEventDate; |
|
213 | - } |
|
210 | + public function setLastEventDate($lastEventDate) |
|
211 | + { |
|
212 | + $this->lastEventDate = $lastEventDate; |
|
213 | + } |
|
214 | 214 | |
215 | - /*** |
|
215 | + /*** |
|
216 | 216 | * @return the transaction status |
217 | 217 | * @see PagSeguroTransactionStatus |
218 | 218 | */ |
219 | - public function getStatus() |
|
220 | - { |
|
221 | - return $this->status; |
|
222 | - } |
|
219 | + public function getStatus() |
|
220 | + { |
|
221 | + return $this->status; |
|
222 | + } |
|
223 | 223 | |
224 | - /*** |
|
224 | + /*** |
|
225 | 225 | * Sets the transaction status |
226 | 226 | * @param PagSeguroTransactionStatus $status |
227 | 227 | */ |
228 | - public function setStatus(PagSeguroTransactionStatus $status) |
|
229 | - { |
|
230 | - $this->status = $status; |
|
231 | - } |
|
228 | + public function setStatus(PagSeguroTransactionStatus $status) |
|
229 | + { |
|
230 | + $this->status = $status; |
|
231 | + } |
|
232 | 232 | |
233 | - /*** |
|
233 | + /*** |
|
234 | 234 | * @return the net amount |
235 | 235 | */ |
236 | - public function getNetAmount() |
|
237 | - { |
|
238 | - return $this->netAmount; |
|
239 | - } |
|
236 | + public function getNetAmount() |
|
237 | + { |
|
238 | + return $this->netAmount; |
|
239 | + } |
|
240 | 240 | |
241 | - /*** |
|
241 | + /*** |
|
242 | 242 | * Sets the net amount |
243 | 243 | * @param float $netAmount |
244 | 244 | */ |
245 | - public function setNetAmount($netAmount) |
|
246 | - { |
|
247 | - $this->netAmount = $netAmount; |
|
248 | - } |
|
245 | + public function setNetAmount($netAmount) |
|
246 | + { |
|
247 | + $this->netAmount = $netAmount; |
|
248 | + } |
|
249 | 249 | |
250 | - /*** |
|
250 | + /*** |
|
251 | 251 | * @return the discount amount |
252 | 252 | */ |
253 | - public function getDiscountAmount() |
|
254 | - { |
|
255 | - return $this->discountAmount; |
|
256 | - } |
|
253 | + public function getDiscountAmount() |
|
254 | + { |
|
255 | + return $this->discountAmount; |
|
256 | + } |
|
257 | 257 | |
258 | - /*** |
|
258 | + /*** |
|
259 | 259 | * Sets the discount amount |
260 | 260 | * @param float $discountAmount |
261 | 261 | */ |
262 | - public function setDiscountAmount($discountAmount) |
|
263 | - { |
|
264 | - $this->discountAmount = $discountAmount; |
|
265 | - } |
|
262 | + public function setDiscountAmount($discountAmount) |
|
263 | + { |
|
264 | + $this->discountAmount = $discountAmount; |
|
265 | + } |
|
266 | 266 | |
267 | - /*** |
|
267 | + /*** |
|
268 | 268 | * @return the fee amount |
269 | 269 | */ |
270 | - public function getFeeAmount() |
|
271 | - { |
|
272 | - return $this->feeAmount; |
|
273 | - } |
|
270 | + public function getFeeAmount() |
|
271 | + { |
|
272 | + return $this->feeAmount; |
|
273 | + } |
|
274 | 274 | |
275 | - /*** |
|
275 | + /*** |
|
276 | 276 | * Sets the fee amount |
277 | 277 | * @param float $feeAmount |
278 | 278 | */ |
279 | - public function setFeeAmount($feeAmount) |
|
280 | - { |
|
281 | - $this->feeAmount = $feeAmount; |
|
282 | - } |
|
279 | + public function setFeeAmount($feeAmount) |
|
280 | + { |
|
281 | + $this->feeAmount = $feeAmount; |
|
282 | + } |
|
283 | 283 | |
284 | - /*** |
|
284 | + /*** |
|
285 | 285 | * @return the extra amount |
286 | 286 | */ |
287 | - public function getExtraAmount() |
|
288 | - { |
|
289 | - return $this->extraAmount; |
|
290 | - } |
|
287 | + public function getExtraAmount() |
|
288 | + { |
|
289 | + return $this->extraAmount; |
|
290 | + } |
|
291 | 291 | |
292 | - /*** |
|
292 | + /*** |
|
293 | 293 | * Sets the extra amount |
294 | 294 | * @param float $extraAmount |
295 | 295 | */ |
296 | - public function setExtraAmount($extraAmount) |
|
297 | - { |
|
298 | - $this->extraAmount = $extraAmount; |
|
299 | - } |
|
296 | + public function setExtraAmount($extraAmount) |
|
297 | + { |
|
298 | + $this->extraAmount = $extraAmount; |
|
299 | + } |
|
300 | 300 | |
301 | - /*** |
|
301 | + /*** |
|
302 | 302 | * Sets the cancellation source |
303 | 303 | * @param PagSeguroTransactionCancellationSource $cancellationSource |
304 | 304 | */ |
305 | - public function setCancellationSource(PagSeguroTransactionCancellationSource $cancellationSource) |
|
306 | - { |
|
307 | - $this->cancellationSource = $cancellationSource; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * @return the cancellation source |
|
312 | - * @see PagSeguroTransactionCancellationSource |
|
313 | - */ |
|
314 | - public function getCancellationSource() |
|
315 | - { |
|
316 | - return $this->cancellationSource; |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * Sets the payment method |
|
321 | - * @param PagSeguroPaymentMethod $paymentMethod |
|
322 | - */ |
|
323 | - public function setPaymentMethod(PagSeguroPaymentMethod $paymentMethod) |
|
324 | - { |
|
325 | - $this->paymentMethod = $paymentMethod; |
|
326 | - } |
|
327 | - |
|
328 | - /*** |
|
305 | + public function setCancellationSource(PagSeguroTransactionCancellationSource $cancellationSource) |
|
306 | + { |
|
307 | + $this->cancellationSource = $cancellationSource; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * @return the cancellation source |
|
312 | + * @see PagSeguroTransactionCancellationSource |
|
313 | + */ |
|
314 | + public function getCancellationSource() |
|
315 | + { |
|
316 | + return $this->cancellationSource; |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * Sets the payment method |
|
321 | + * @param PagSeguroPaymentMethod $paymentMethod |
|
322 | + */ |
|
323 | + public function setPaymentMethod(PagSeguroPaymentMethod $paymentMethod) |
|
324 | + { |
|
325 | + $this->paymentMethod = $paymentMethod; |
|
326 | + } |
|
327 | + |
|
328 | + /*** |
|
329 | 329 | * @return the payment method |
330 | 330 | * @see PagSeguroPaymentMethod |
331 | 331 | */ |
332 | - public function getPaymentMethod() |
|
333 | - { |
|
334 | - return $this->paymentMethod; |
|
335 | - } |
|
332 | + public function getPaymentMethod() |
|
333 | + { |
|
334 | + return $this->paymentMethod; |
|
335 | + } |
|
336 | 336 | |
337 | - /*** |
|
337 | + /*** |
|
338 | 338 | * @return the recovery code |
339 | 339 | */ |
340 | - public function getRecoveryCode() |
|
341 | - { |
|
342 | - return $this->recoveryCode; |
|
343 | - } |
|
340 | + public function getRecoveryCode() |
|
341 | + { |
|
342 | + return $this->recoveryCode; |
|
343 | + } |
|
344 | 344 | |
345 | - /*** |
|
345 | + /*** |
|
346 | 346 | * Sets the recovery code |
347 | 347 | * @param string $recoveryCode |
348 | 348 | */ |
349 | - public function setRecoveryCode($recoverycode) |
|
350 | - { |
|
351 | - $this->recoveryCode = $recoverycode; |
|
352 | - } |
|
349 | + public function setRecoveryCode($recoverycode) |
|
350 | + { |
|
351 | + $this->recoveryCode = $recoverycode; |
|
352 | + } |
|
353 | 353 | } |
@@ -32,6 +32,11 @@ |
||
32 | 32 | * @param $credentials PagSeguroAuthorizationCredentials |
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | + |
|
36 | + /** |
|
37 | + * @param PagSeguroAuthorizationRequest $authorization |
|
38 | + * @param PagSeguroCredentials $credentials |
|
39 | + */ |
|
35 | 40 | public static function getData($authorization, $credentials) |
36 | 41 | { |
37 | 42 |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Class PagSeguroAuthorizationParser |
@@ -27,201 +27,201 @@ discard block |
||
27 | 27 | class PagSeguroAuthorizationParser extends PagSeguroServiceParser |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * @param $authorization PagSeguroAuthorizationRequest |
32 | 32 | * @param $credentials PagSeguroAuthorizationCredentials |
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | - public static function getData($authorization, $credentials) |
|
36 | - { |
|
37 | - |
|
38 | - $data = null; |
|
39 | - |
|
40 | - // AppID |
|
41 | - if ($credentials->getAppId() != null) { |
|
42 | - $data['appId'] = $credentials->getAppId(); |
|
43 | - } |
|
44 | - // AppKey |
|
45 | - if ($credentials->getAppKey() != null) { |
|
46 | - $data['appKey'] = $credentials->getAppKey(); |
|
47 | - } |
|
48 | - // Reference |
|
49 | - if ($authorization->getReference() != null) { |
|
50 | - $data['reference'] = $authorization->getReference(); |
|
51 | - } |
|
52 | - // RedirectURL |
|
53 | - if ($authorization->getRedirectURL() != null) { |
|
54 | - $data['redirectURL'] = $authorization->getRedirectURL(); |
|
55 | - } |
|
56 | - // NotificationURL |
|
57 | - if ($authorization->getNotificationURL() != null) { |
|
58 | - $data['notificationURL'] = $authorization->getNotificationURL(); |
|
59 | - } |
|
60 | - // Permissions |
|
61 | - if ($authorization->getPermissions()->getPermissions() != null) { |
|
62 | - $data['permissions'] = implode(',',$authorization->getPermissions()->getPermissions()); |
|
63 | - } |
|
64 | - |
|
65 | - // parameter |
|
66 | - if (count($authorization->getParameter()->getItems()) > 0) { |
|
67 | - foreach ($authorization->getParameter()->getItems() as $item) { |
|
68 | - if ($item instanceof PagSeguroParameterItem) { |
|
69 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
70 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
71 | - $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
72 | - } else { |
|
73 | - $data[$item->getKey()] = $item->getValue(); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
35 | + public static function getData($authorization, $credentials) |
|
36 | + { |
|
37 | + |
|
38 | + $data = null; |
|
39 | + |
|
40 | + // AppID |
|
41 | + if ($credentials->getAppId() != null) { |
|
42 | + $data['appId'] = $credentials->getAppId(); |
|
43 | + } |
|
44 | + // AppKey |
|
45 | + if ($credentials->getAppKey() != null) { |
|
46 | + $data['appKey'] = $credentials->getAppKey(); |
|
47 | + } |
|
48 | + // Reference |
|
49 | + if ($authorization->getReference() != null) { |
|
50 | + $data['reference'] = $authorization->getReference(); |
|
51 | + } |
|
52 | + // RedirectURL |
|
53 | + if ($authorization->getRedirectURL() != null) { |
|
54 | + $data['redirectURL'] = $authorization->getRedirectURL(); |
|
55 | + } |
|
56 | + // NotificationURL |
|
57 | + if ($authorization->getNotificationURL() != null) { |
|
58 | + $data['notificationURL'] = $authorization->getNotificationURL(); |
|
59 | + } |
|
60 | + // Permissions |
|
61 | + if ($authorization->getPermissions()->getPermissions() != null) { |
|
62 | + $data['permissions'] = implode(',',$authorization->getPermissions()->getPermissions()); |
|
63 | + } |
|
64 | + |
|
65 | + // parameter |
|
66 | + if (count($authorization->getParameter()->getItems()) > 0) { |
|
67 | + foreach ($authorization->getParameter()->getItems() as $item) { |
|
68 | + if ($item instanceof PagSeguroParameterItem) { |
|
69 | + if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
70 | + if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
71 | + $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
72 | + } else { |
|
73 | + $data[$item->getKey()] = $item->getValue(); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - return $data; |
|
81 | - } |
|
80 | + return $data; |
|
81 | + } |
|
82 | 82 | |
83 | - /*** |
|
83 | + /*** |
|
84 | 84 | * @param $str_xml |
85 | 85 | * @return PagSeguroAuthorization |
86 | 86 | */ |
87 | - public static function readAuthorization($str_xml) |
|
88 | - { |
|
89 | - // Parser |
|
90 | - $parser = new PagSeguroXmlParser($str_xml); |
|
87 | + public static function readAuthorization($str_xml) |
|
88 | + { |
|
89 | + // Parser |
|
90 | + $parser = new PagSeguroXmlParser($str_xml); |
|
91 | 91 | |
92 | - return self::buildAuthorization(new PagSeguroAuthorization(), |
|
93 | - $parser->getResult('authorization')); |
|
94 | - } |
|
92 | + return self::buildAuthorization(new PagSeguroAuthorization(), |
|
93 | + $parser->getResult('authorization')); |
|
94 | + } |
|
95 | 95 | |
96 | - /*** |
|
96 | + /*** |
|
97 | 97 | * @param $str_xml |
98 | 98 | * @return PagSeguroAuthorization |
99 | 99 | */ |
100 | - public static function readSearchResult($str_xml) |
|
101 | - { |
|
102 | - // Parser |
|
103 | - $parser = new PagSeguroXmlParser($str_xml); |
|
104 | - |
|
105 | - $authorization = new PagSeguroAuthorizationSearchResult(); |
|
106 | - |
|
107 | - // <authorizationSearchResult> |
|
108 | - $data = $parser->getResult('authorizationSearchResult'); |
|
109 | - |
|
110 | - // <authorizationSearchResult><date> |
|
111 | - if (isset($data["date"])) { |
|
112 | - $authorization->setDate($data['date']); |
|
113 | - } |
|
114 | - |
|
115 | - //<authorizationSearchResult><authorizations><authorization> |
|
116 | - if (isset($data['authorizations']) && is_array($data['authorizations'])) { |
|
117 | - |
|
118 | - if (isset($data['authorizations']['authorization']) |
|
119 | - && $data["resultsInThisPage"] > 1) { |
|
120 | - |
|
121 | - $i = 0; |
|
122 | - foreach ($data['authorizations']['authorization'] as $key => $value) { |
|
123 | - $newAuthorization = new PagSeguroAuthorization(); |
|
124 | - $nAuthorization[$i++] = self::buildAuthorization($newAuthorization,$value); |
|
125 | - } |
|
126 | - $authorization->setAuthorizations($nAuthorization); |
|
127 | - |
|
128 | - } else { |
|
129 | - |
|
130 | - $newAuthorization = new PagSeguroAuthorization(); |
|
131 | - $authorization->setAuthorizations( |
|
132 | - self::buildAuthorization($newAuthorization, |
|
133 | - $data['authorizations']['authorization'])); |
|
134 | - } |
|
135 | - |
|
136 | - } |
|
137 | - |
|
138 | - // <authorizationSearchResult><resultsInThisPage> |
|
139 | - if (isset($data["resultsInThisPage"])) { |
|
140 | - $authorization->setResultsInThisPage($data['resultsInThisPage']); |
|
141 | - } |
|
142 | - // <authorizationSearchResult><totalPages> |
|
143 | - if (isset($data["totalPages"])) { |
|
144 | - $authorization->setTotalPages($data['totalPages']); |
|
145 | - } |
|
146 | - // <authorizationSearchResult><currentPage> |
|
147 | - if (isset($data["currentPage"])) { |
|
148 | - $authorization->setCurrentPage($data["currentPage"]); |
|
149 | - } |
|
150 | - |
|
151 | - return $authorization; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @param PagSeguroAuthorization $authorization |
|
156 | - * @param $data |
|
157 | - */ |
|
158 | - private function buildAuthorization(PagSeguroAuthorization $authorization, $data) |
|
159 | - { |
|
160 | - // <authorization><code> |
|
161 | - if (isset($data["code"])) { |
|
162 | - $authorization->setCode($data['code']); |
|
163 | - } |
|
164 | - |
|
165 | - // <authorization><creationDate> |
|
166 | - if (isset($data["creationDate"])) { |
|
167 | - $authorization->setCreationDate($data['creationDate']); |
|
168 | - } |
|
169 | - |
|
170 | - // <authorization><reference> |
|
171 | - if (isset($data["reference"])) { |
|
172 | - $authorization->setReference($data['reference']); |
|
173 | - } |
|
174 | - |
|
175 | - // <authorization><account><publicKey> |
|
176 | - if (isset($data["account"]) and isset($data["account"]['publicKey'])) { |
|
177 | - $authorization->setAccount(new PagSeguroAuthorizationAccount($data["account"]['publicKey'])); |
|
178 | - } |
|
179 | - |
|
180 | - // <authorization><permissions> |
|
181 | - if (isset($data["permissions"])) { |
|
182 | - if (isset($data["permissions"]["permission"])) { |
|
183 | - |
|
184 | - foreach ($data["permissions"]["permission"] as $permission) { |
|
185 | - |
|
186 | - $permissions[] = new PagSeguroAuthorizationPermission( |
|
187 | - $permission['code'], |
|
188 | - $permission['status'], |
|
189 | - $permission['lastUpdate'] |
|
190 | - ); |
|
191 | - } |
|
192 | - } |
|
193 | - $permissions = new PagSeguroAuthorizationPermissions($permissions); |
|
194 | - $authorization->setPermissions($permissions); |
|
195 | - |
|
196 | - return $authorization; |
|
197 | - } |
|
198 | - } |
|
199 | - |
|
200 | - /*** |
|
100 | + public static function readSearchResult($str_xml) |
|
101 | + { |
|
102 | + // Parser |
|
103 | + $parser = new PagSeguroXmlParser($str_xml); |
|
104 | + |
|
105 | + $authorization = new PagSeguroAuthorizationSearchResult(); |
|
106 | + |
|
107 | + // <authorizationSearchResult> |
|
108 | + $data = $parser->getResult('authorizationSearchResult'); |
|
109 | + |
|
110 | + // <authorizationSearchResult><date> |
|
111 | + if (isset($data["date"])) { |
|
112 | + $authorization->setDate($data['date']); |
|
113 | + } |
|
114 | + |
|
115 | + //<authorizationSearchResult><authorizations><authorization> |
|
116 | + if (isset($data['authorizations']) && is_array($data['authorizations'])) { |
|
117 | + |
|
118 | + if (isset($data['authorizations']['authorization']) |
|
119 | + && $data["resultsInThisPage"] > 1) { |
|
120 | + |
|
121 | + $i = 0; |
|
122 | + foreach ($data['authorizations']['authorization'] as $key => $value) { |
|
123 | + $newAuthorization = new PagSeguroAuthorization(); |
|
124 | + $nAuthorization[$i++] = self::buildAuthorization($newAuthorization,$value); |
|
125 | + } |
|
126 | + $authorization->setAuthorizations($nAuthorization); |
|
127 | + |
|
128 | + } else { |
|
129 | + |
|
130 | + $newAuthorization = new PagSeguroAuthorization(); |
|
131 | + $authorization->setAuthorizations( |
|
132 | + self::buildAuthorization($newAuthorization, |
|
133 | + $data['authorizations']['authorization'])); |
|
134 | + } |
|
135 | + |
|
136 | + } |
|
137 | + |
|
138 | + // <authorizationSearchResult><resultsInThisPage> |
|
139 | + if (isset($data["resultsInThisPage"])) { |
|
140 | + $authorization->setResultsInThisPage($data['resultsInThisPage']); |
|
141 | + } |
|
142 | + // <authorizationSearchResult><totalPages> |
|
143 | + if (isset($data["totalPages"])) { |
|
144 | + $authorization->setTotalPages($data['totalPages']); |
|
145 | + } |
|
146 | + // <authorizationSearchResult><currentPage> |
|
147 | + if (isset($data["currentPage"])) { |
|
148 | + $authorization->setCurrentPage($data["currentPage"]); |
|
149 | + } |
|
150 | + |
|
151 | + return $authorization; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @param PagSeguroAuthorization $authorization |
|
156 | + * @param $data |
|
157 | + */ |
|
158 | + private function buildAuthorization(PagSeguroAuthorization $authorization, $data) |
|
159 | + { |
|
160 | + // <authorization><code> |
|
161 | + if (isset($data["code"])) { |
|
162 | + $authorization->setCode($data['code']); |
|
163 | + } |
|
164 | + |
|
165 | + // <authorization><creationDate> |
|
166 | + if (isset($data["creationDate"])) { |
|
167 | + $authorization->setCreationDate($data['creationDate']); |
|
168 | + } |
|
169 | + |
|
170 | + // <authorization><reference> |
|
171 | + if (isset($data["reference"])) { |
|
172 | + $authorization->setReference($data['reference']); |
|
173 | + } |
|
174 | + |
|
175 | + // <authorization><account><publicKey> |
|
176 | + if (isset($data["account"]) and isset($data["account"]['publicKey'])) { |
|
177 | + $authorization->setAccount(new PagSeguroAuthorizationAccount($data["account"]['publicKey'])); |
|
178 | + } |
|
179 | + |
|
180 | + // <authorization><permissions> |
|
181 | + if (isset($data["permissions"])) { |
|
182 | + if (isset($data["permissions"]["permission"])) { |
|
183 | + |
|
184 | + foreach ($data["permissions"]["permission"] as $permission) { |
|
185 | + |
|
186 | + $permissions[] = new PagSeguroAuthorizationPermission( |
|
187 | + $permission['code'], |
|
188 | + $permission['status'], |
|
189 | + $permission['lastUpdate'] |
|
190 | + ); |
|
191 | + } |
|
192 | + } |
|
193 | + $permissions = new PagSeguroAuthorizationPermissions($permissions); |
|
194 | + $authorization->setPermissions($permissions); |
|
195 | + |
|
196 | + return $authorization; |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + /*** |
|
201 | 201 | * @param $str_xml |
202 | 202 | * @return PagSeguroParserData Success |
203 | 203 | */ |
204 | - public static function readSuccessXml($str_xml) |
|
205 | - { |
|
206 | - $parser = new PagSeguroXmlParser($str_xml); |
|
207 | - |
|
208 | - $data = $parser->getResult('authorizationRequest'); |
|
209 | - $authorizationParserData = new PagSeguroParserData(); |
|
210 | - $authorizationParserData->setCode($data['code']); |
|
211 | - $authorizationParserData->setRegistrationDate($data['date']); |
|
212 | - return $authorizationParserData; |
|
213 | - } |
|
214 | - |
|
215 | - /*** |
|
204 | + public static function readSuccessXml($str_xml) |
|
205 | + { |
|
206 | + $parser = new PagSeguroXmlParser($str_xml); |
|
207 | + |
|
208 | + $data = $parser->getResult('authorizationRequest'); |
|
209 | + $authorizationParserData = new PagSeguroParserData(); |
|
210 | + $authorizationParserData->setCode($data['code']); |
|
211 | + $authorizationParserData->setRegistrationDate($data['date']); |
|
212 | + return $authorizationParserData; |
|
213 | + } |
|
214 | + |
|
215 | + /*** |
|
216 | 216 | * @param $error Authorization error |
217 | 217 | * @return object() |
218 | 218 | */ |
219 | - private static function readError($error) |
|
220 | - { |
|
221 | - $err = new stdClass(); |
|
222 | - $err->message = key($error); |
|
223 | - $err->status = true; |
|
224 | - |
|
225 | - return $err; |
|
226 | - } |
|
219 | + private static function readError($error) |
|
220 | + { |
|
221 | + $err = new stdClass(); |
|
222 | + $err->message = key($error); |
|
223 | + $err->status = true; |
|
224 | + |
|
225 | + return $err; |
|
226 | + } |
|
227 | 227 | } |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | } |
60 | 60 | // Permissions |
61 | 61 | if ($authorization->getPermissions()->getPermissions() != null) { |
62 | - $data['permissions'] = implode(',',$authorization->getPermissions()->getPermissions()); |
|
62 | + $data['permissions'] = implode(',', $authorization->getPermissions()->getPermissions()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // parameter |
66 | 66 | if (count($authorization->getParameter()->getItems()) > 0) { |
67 | 67 | foreach ($authorization->getParameter()->getItems() as $item) { |
68 | 68 | if ($item instanceof PagSeguroParameterItem) { |
69 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
70 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
71 | - $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
69 | + if ( ! PagSeguroHelper::isEmpty($item->getKey()) && ! PagSeguroHelper::isEmpty($item->getValue())) { |
|
70 | + if ( ! PagSeguroHelper::isEmpty($item->getGroup())) { |
|
71 | + $data[$item->getKey().''.$item->getGroup()] = $item->getValue(); |
|
72 | 72 | } else { |
73 | 73 | $data[$item->getKey()] = $item->getValue(); |
74 | 74 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $i = 0; |
122 | 122 | foreach ($data['authorizations']['authorization'] as $key => $value) { |
123 | 123 | $newAuthorization = new PagSeguroAuthorization(); |
124 | - $nAuthorization[$i++] = self::buildAuthorization($newAuthorization,$value); |
|
124 | + $nAuthorization[$i++] = self::buildAuthorization($newAuthorization, $value); |
|
125 | 125 | } |
126 | 126 | $authorization->setAuthorizations($nAuthorization); |
127 | 127 |
@@ -31,6 +31,10 @@ |
||
31 | 31 | * @param $payment PagSeguroDirectPaymentRequest |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | + |
|
35 | + /** |
|
36 | + * @param PagSeguroDirectPaymentRequest $payment |
|
37 | + */ |
|
34 | 38 | public static function getData($payment) |
35 | 39 | { |
36 | 40 |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Class PagSeguroDirectPaymentParser |
@@ -27,329 +27,329 @@ discard block |
||
27 | 27 | class PagSeguroDirectPaymentParser extends PagSeguroServiceParser |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * @param $payment PagSeguroDirectPaymentRequest |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | - public static function getData($payment) |
|
35 | - { |
|
36 | - |
|
37 | - $data = null; |
|
38 | - |
|
39 | - // paymentMode |
|
40 | - if ($payment->getPaymentMode() != null) { |
|
41 | - $data["paymentMode"] = $payment->getPaymentMode()->getValue(); |
|
42 | - } |
|
43 | - |
|
44 | - // paymentMethod |
|
45 | - if ($payment->getPaymentMethod()->getPaymentMethod() != null) { |
|
46 | - $data["paymentMethod"] = $payment->getPaymentMethod()->getPaymentMethod(); |
|
47 | - } |
|
48 | - |
|
49 | - // senderHash |
|
50 | - if ($payment->getSenderHash() != null) { |
|
51 | - $data["senderHash"] = $payment->getSenderHash(); |
|
52 | - } |
|
53 | - |
|
54 | - // receiverEmail |
|
55 | - if ($payment->getReceiverEmail() != null) { |
|
56 | - $data["receiverEmail"] = $payment->getReceiverEmail(); |
|
57 | - } |
|
58 | - |
|
59 | - // reference |
|
60 | - if ($payment->getReference() != null) { |
|
61 | - $data["reference"] = $payment->getReference(); |
|
62 | - } |
|
63 | - |
|
64 | - // sender |
|
65 | - if ($payment->getSender() != null) { |
|
66 | - |
|
67 | - if ($payment->getSender()->getName() != null) { |
|
68 | - $data['senderName'] = $payment->getSender()->getName(); |
|
69 | - } |
|
70 | - if ($payment->getSender()->getEmail() != null) { |
|
71 | - $data['senderEmail'] = $payment->getSender()->getEmail(); |
|
72 | - } |
|
73 | - |
|
74 | - // phone |
|
75 | - if ($payment->getSender()->getPhone() != null) { |
|
76 | - if ($payment->getSender()->getPhone()->getAreaCode() != null) { |
|
77 | - $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode(); |
|
78 | - } |
|
79 | - if ($payment->getSender()->getPhone()->getNumber() != null) { |
|
80 | - $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber(); |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - // documents |
|
85 | - /*** @var $document PagSeguroDocument */ |
|
86 | - if ($payment->getSender()->getDocuments() != null) { |
|
87 | - $documents = $payment->getSender()->getDocuments(); |
|
88 | - if (is_array($documents) && count($documents) == 1) { |
|
89 | - foreach ($documents as $document) { |
|
90 | - if (!is_null($document)) { |
|
91 | - $data['senderCPF'] = $document->getValue(); |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - // ip |
|
97 | - if ($payment->getSender()->getIP() != null) { |
|
98 | - $data['ip'] = $payment->getSender()->getIP(); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - // currency |
|
103 | - if ($payment->getCurrency() != null) { |
|
104 | - $data['currency'] = $payment->getCurrency(); |
|
105 | - } |
|
106 | - |
|
107 | - // items |
|
108 | - $items = $payment->getItems(); |
|
109 | - if (count($items) > 0) { |
|
110 | - |
|
111 | - $i = 0; |
|
112 | - |
|
113 | - foreach ($items as $key => $value) { |
|
114 | - $i++; |
|
115 | - if ($items[$key]->getId() != null) { |
|
116 | - $data["itemId$i"] = $items[$key]->getId(); |
|
117 | - } |
|
118 | - if ($items[$key]->getDescription() != null) { |
|
119 | - $data["itemDescription$i"] = $items[$key]->getDescription(); |
|
120 | - } |
|
121 | - if ($items[$key]->getQuantity() != null) { |
|
122 | - $data["itemQuantity$i"] = $items[$key]->getQuantity(); |
|
123 | - } |
|
124 | - if ($items[$key]->getAmount() != null) { |
|
125 | - $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount()); |
|
126 | - $data["itemAmount$i"] = $amount; |
|
127 | - } |
|
128 | - if ($items[$key]->getWeight() != null) { |
|
129 | - $data["itemWeight$i"] = $items[$key]->getWeight(); |
|
130 | - } |
|
131 | - if ($items[$key]->getShippingCost() != null) { |
|
132 | - $data["itemShippingCost$i"] = PagSeguroHelper::decimalFormat($items[$key]->getShippingCost()); |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - // extraAmount |
|
138 | - if ($payment->getExtraAmount() != null) { |
|
139 | - $data['extraAmount'] = PagSeguroHelper::decimalFormat($payment->getExtraAmount()); |
|
140 | - } |
|
141 | - |
|
142 | - // shipping |
|
143 | - if ($payment->getShipping() != null) { |
|
144 | - |
|
145 | - if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) { |
|
146 | - $data['shippingType'] = $payment->getShipping()->getType()->getValue(); |
|
147 | - } |
|
148 | - |
|
149 | - if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) { |
|
150 | - $data['shippingCost'] = PagSeguroHelper::decimalFormat($payment->getShipping()->getCost()); |
|
151 | - } |
|
152 | - |
|
153 | - // address |
|
154 | - if ($payment->getShipping()->getAddress() != null) { |
|
155 | - if ($payment->getShipping()->getAddress()->getStreet() != null) { |
|
156 | - $data['shippingAddressStreet'] = $payment->getShipping()->getAddress()->getStreet(); |
|
157 | - } |
|
158 | - if ($payment->getShipping()->getAddress()->getNumber() != null) { |
|
159 | - $data['shippingAddressNumber'] = $payment->getShipping()->getAddress()->getNumber(); |
|
160 | - } |
|
161 | - if ($payment->getShipping()->getAddress()->getComplement() != null) { |
|
162 | - $data['shippingAddressComplement'] = $payment->getShipping()->getAddress()->getComplement(); |
|
163 | - } |
|
164 | - if ($payment->getShipping()->getAddress()->getCity() != null) { |
|
165 | - $data['shippingAddressCity'] = $payment->getShipping()->getAddress()->getCity(); |
|
166 | - } |
|
167 | - if ($payment->getShipping()->getAddress()->getState() != null) { |
|
168 | - $data['shippingAddressState'] = $payment->getShipping()->getAddress()->getState(); |
|
169 | - } |
|
170 | - if ($payment->getShipping()->getAddress()->getDistrict() != null) { |
|
171 | - $data['shippingAddressDistrict'] = $payment->getShipping()->getAddress()->getDistrict(); |
|
172 | - } |
|
173 | - if ($payment->getShipping()->getAddress()->getPostalCode() != null) { |
|
174 | - $data['shippingAddressPostalCode'] = $payment->getShipping()->getAddress()->getPostalCode(); |
|
175 | - } |
|
176 | - if ($payment->getShipping()->getAddress()->getCountry() != null) { |
|
177 | - $data['shippingAddressCountry'] = $payment->getShipping()->getAddress()->getCountry(); |
|
178 | - } |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - // Bank name |
|
183 | - if ($payment->getOnlineDebit() != null) { |
|
184 | - $data["bankName"] = $payment->getOnlineDebit()->getBankName(); |
|
185 | - } |
|
186 | - |
|
187 | - //Credit Card |
|
188 | - if ($payment->getCreditCard() != null) { |
|
34 | + public static function getData($payment) |
|
35 | + { |
|
36 | + |
|
37 | + $data = null; |
|
38 | + |
|
39 | + // paymentMode |
|
40 | + if ($payment->getPaymentMode() != null) { |
|
41 | + $data["paymentMode"] = $payment->getPaymentMode()->getValue(); |
|
42 | + } |
|
43 | + |
|
44 | + // paymentMethod |
|
45 | + if ($payment->getPaymentMethod()->getPaymentMethod() != null) { |
|
46 | + $data["paymentMethod"] = $payment->getPaymentMethod()->getPaymentMethod(); |
|
47 | + } |
|
48 | + |
|
49 | + // senderHash |
|
50 | + if ($payment->getSenderHash() != null) { |
|
51 | + $data["senderHash"] = $payment->getSenderHash(); |
|
52 | + } |
|
53 | + |
|
54 | + // receiverEmail |
|
55 | + if ($payment->getReceiverEmail() != null) { |
|
56 | + $data["receiverEmail"] = $payment->getReceiverEmail(); |
|
57 | + } |
|
58 | + |
|
59 | + // reference |
|
60 | + if ($payment->getReference() != null) { |
|
61 | + $data["reference"] = $payment->getReference(); |
|
62 | + } |
|
63 | + |
|
64 | + // sender |
|
65 | + if ($payment->getSender() != null) { |
|
66 | + |
|
67 | + if ($payment->getSender()->getName() != null) { |
|
68 | + $data['senderName'] = $payment->getSender()->getName(); |
|
69 | + } |
|
70 | + if ($payment->getSender()->getEmail() != null) { |
|
71 | + $data['senderEmail'] = $payment->getSender()->getEmail(); |
|
72 | + } |
|
73 | + |
|
74 | + // phone |
|
75 | + if ($payment->getSender()->getPhone() != null) { |
|
76 | + if ($payment->getSender()->getPhone()->getAreaCode() != null) { |
|
77 | + $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode(); |
|
78 | + } |
|
79 | + if ($payment->getSender()->getPhone()->getNumber() != null) { |
|
80 | + $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber(); |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + // documents |
|
85 | + /*** @var $document PagSeguroDocument */ |
|
86 | + if ($payment->getSender()->getDocuments() != null) { |
|
87 | + $documents = $payment->getSender()->getDocuments(); |
|
88 | + if (is_array($documents) && count($documents) == 1) { |
|
89 | + foreach ($documents as $document) { |
|
90 | + if (!is_null($document)) { |
|
91 | + $data['senderCPF'] = $document->getValue(); |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | + // ip |
|
97 | + if ($payment->getSender()->getIP() != null) { |
|
98 | + $data['ip'] = $payment->getSender()->getIP(); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + // currency |
|
103 | + if ($payment->getCurrency() != null) { |
|
104 | + $data['currency'] = $payment->getCurrency(); |
|
105 | + } |
|
106 | + |
|
107 | + // items |
|
108 | + $items = $payment->getItems(); |
|
109 | + if (count($items) > 0) { |
|
110 | + |
|
111 | + $i = 0; |
|
112 | + |
|
113 | + foreach ($items as $key => $value) { |
|
114 | + $i++; |
|
115 | + if ($items[$key]->getId() != null) { |
|
116 | + $data["itemId$i"] = $items[$key]->getId(); |
|
117 | + } |
|
118 | + if ($items[$key]->getDescription() != null) { |
|
119 | + $data["itemDescription$i"] = $items[$key]->getDescription(); |
|
120 | + } |
|
121 | + if ($items[$key]->getQuantity() != null) { |
|
122 | + $data["itemQuantity$i"] = $items[$key]->getQuantity(); |
|
123 | + } |
|
124 | + if ($items[$key]->getAmount() != null) { |
|
125 | + $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount()); |
|
126 | + $data["itemAmount$i"] = $amount; |
|
127 | + } |
|
128 | + if ($items[$key]->getWeight() != null) { |
|
129 | + $data["itemWeight$i"] = $items[$key]->getWeight(); |
|
130 | + } |
|
131 | + if ($items[$key]->getShippingCost() != null) { |
|
132 | + $data["itemShippingCost$i"] = PagSeguroHelper::decimalFormat($items[$key]->getShippingCost()); |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + // extraAmount |
|
138 | + if ($payment->getExtraAmount() != null) { |
|
139 | + $data['extraAmount'] = PagSeguroHelper::decimalFormat($payment->getExtraAmount()); |
|
140 | + } |
|
141 | + |
|
142 | + // shipping |
|
143 | + if ($payment->getShipping() != null) { |
|
144 | + |
|
145 | + if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) { |
|
146 | + $data['shippingType'] = $payment->getShipping()->getType()->getValue(); |
|
147 | + } |
|
148 | + |
|
149 | + if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) { |
|
150 | + $data['shippingCost'] = PagSeguroHelper::decimalFormat($payment->getShipping()->getCost()); |
|
151 | + } |
|
152 | + |
|
153 | + // address |
|
154 | + if ($payment->getShipping()->getAddress() != null) { |
|
155 | + if ($payment->getShipping()->getAddress()->getStreet() != null) { |
|
156 | + $data['shippingAddressStreet'] = $payment->getShipping()->getAddress()->getStreet(); |
|
157 | + } |
|
158 | + if ($payment->getShipping()->getAddress()->getNumber() != null) { |
|
159 | + $data['shippingAddressNumber'] = $payment->getShipping()->getAddress()->getNumber(); |
|
160 | + } |
|
161 | + if ($payment->getShipping()->getAddress()->getComplement() != null) { |
|
162 | + $data['shippingAddressComplement'] = $payment->getShipping()->getAddress()->getComplement(); |
|
163 | + } |
|
164 | + if ($payment->getShipping()->getAddress()->getCity() != null) { |
|
165 | + $data['shippingAddressCity'] = $payment->getShipping()->getAddress()->getCity(); |
|
166 | + } |
|
167 | + if ($payment->getShipping()->getAddress()->getState() != null) { |
|
168 | + $data['shippingAddressState'] = $payment->getShipping()->getAddress()->getState(); |
|
169 | + } |
|
170 | + if ($payment->getShipping()->getAddress()->getDistrict() != null) { |
|
171 | + $data['shippingAddressDistrict'] = $payment->getShipping()->getAddress()->getDistrict(); |
|
172 | + } |
|
173 | + if ($payment->getShipping()->getAddress()->getPostalCode() != null) { |
|
174 | + $data['shippingAddressPostalCode'] = $payment->getShipping()->getAddress()->getPostalCode(); |
|
175 | + } |
|
176 | + if ($payment->getShipping()->getAddress()->getCountry() != null) { |
|
177 | + $data['shippingAddressCountry'] = $payment->getShipping()->getAddress()->getCountry(); |
|
178 | + } |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + // Bank name |
|
183 | + if ($payment->getOnlineDebit() != null) { |
|
184 | + $data["bankName"] = $payment->getOnlineDebit()->getBankName(); |
|
185 | + } |
|
186 | + |
|
187 | + //Credit Card |
|
188 | + if ($payment->getCreditCard() != null) { |
|
189 | 189 | |
190 | - //Token |
|
191 | - if ($payment->getCreditCard()->getToken() != null) { |
|
192 | - $data['creditCardToken'] = $payment->getCreditCard()->getToken(); |
|
193 | - } |
|
194 | - |
|
195 | - //Installments |
|
196 | - if ($payment->getCreditCard()->getInstallment() != null) { |
|
197 | - $installment = $payment->getCreditCard()->getInstallment(); |
|
198 | - if ($installment->getQuantity() != null && $installment->getValue()) { |
|
199 | - $data['installmentQuantity'] = $installment->getQuantity(); |
|
200 | - $data['installmentValue'] = PagSeguroHelper::decimalFormat($installment->getValue()); |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - //Holder |
|
205 | - if ($payment->getCreditCard()->getHolder() != null) { |
|
206 | - $holder = $payment->getCreditCard()->getHolder(); |
|
207 | - if ($holder->getName() != null) { |
|
208 | - $data['creditCardHolderName'] = $holder->getName(); |
|
209 | - } |
|
210 | - // documents |
|
211 | - /*** @var $document PagSeguroDocument */ |
|
212 | - if ($payment->getCreditCard()->getHolder()->getDocuments() != null) { |
|
213 | - $documents = $payment->getCreditCard()->getHolder()->getDocuments(); |
|
214 | - $data['creditCardHolderCPF'] = $documents->getValue(); |
|
215 | - } |
|
216 | - if ($holder->getBirthDate() != null) { |
|
217 | - $data['creditCardHolderBirthDate'] = $holder->getBirthDate(); |
|
218 | - } |
|
219 | - // phone |
|
220 | - if ($holder->getPhone() != null) { |
|
221 | - if ($holder->getPhone()->getAreaCode() != null) { |
|
222 | - $data['creditCardHolderAreaCode'] = $holder->getPhone()->getAreaCode(); |
|
223 | - } |
|
224 | - if ($holder->getPhone()->getNumber() != null) { |
|
225 | - $data['creditCardHolderPhone'] = $holder->getPhone()->getNumber(); |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - //Billing Address |
|
231 | - if ($payment->getCreditCard()->getBilling() != null) { |
|
232 | - $billingAddress = $payment->getCreditCard()->getBilling()->getAddress(); |
|
233 | - if ($billingAddress->getStreet() != null) { |
|
234 | - $data['billingAddressStreet'] = $billingAddress->getStreet(); |
|
235 | - } |
|
236 | - if ($billingAddress->getNumber() != null) { |
|
237 | - $data['billingAddressNumber'] = $billingAddress->getNumber(); |
|
238 | - } |
|
239 | - if ($billingAddress->getComplement() != null) { |
|
240 | - $data['billingAddressComplement'] = $billingAddress->getComplement(); |
|
241 | - } |
|
242 | - if ($billingAddress->getCity() != null) { |
|
243 | - $data['billingAddressCity'] = $billingAddress->getCity(); |
|
244 | - } |
|
245 | - if ($billingAddress->getState() != null) { |
|
246 | - $data['billingAddressState'] = $billingAddress->getState(); |
|
247 | - } |
|
248 | - if ($billingAddress->getDistrict() != null) { |
|
249 | - $data['billingAddressDistrict'] = $billingAddress->getDistrict(); |
|
250 | - } |
|
251 | - if ($billingAddress->getPostalCode() != null) { |
|
252 | - $data['billingAddressPostalCode'] = $billingAddress->getPostalCode(); |
|
253 | - } |
|
254 | - if ($billingAddress->getCountry() != null) { |
|
255 | - $data['billingAddressCountry'] = $billingAddress->getCountry(); |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - } |
|
260 | - |
|
261 | - // maxAge |
|
262 | - if ($payment->getMaxAge() != null) { |
|
263 | - $data['maxAge'] = $payment->getMaxAge(); |
|
264 | - } |
|
265 | - // maxUses |
|
266 | - if ($payment->getMaxUses() != null) { |
|
267 | - $data['maxUses'] = $payment->getMaxUses(); |
|
268 | - } |
|
269 | - |
|
270 | - // redirectURL |
|
271 | - if ($payment->getRedirectURL() != null) { |
|
272 | - $data['redirectURL'] = $payment->getRedirectURL(); |
|
273 | - } |
|
274 | - |
|
275 | - // notificationURL |
|
276 | - if ($payment->getNotificationURL() != null) { |
|
277 | - $data['notificationURL'] = $payment->getNotificationURL(); |
|
278 | - } |
|
279 | - |
|
280 | - // metadata |
|
281 | - if (count($payment->getMetaData()->getItems()) > 0) { |
|
282 | - $i = 0; |
|
283 | - foreach ($payment->getMetaData()->getItems() as $item) { |
|
284 | - if ($item instanceof PagSeguroMetaDataItem) { |
|
285 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
286 | - $i++; |
|
287 | - $data['metadataItemKey' . $i] = $item->getKey(); |
|
288 | - $data['metadataItemValue' . $i] = $item->getValue(); |
|
289 | - |
|
290 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
291 | - $data['metadataItemGroup' . $i] = $item->getGroup(); |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - // parameter |
|
299 | - if (count($payment->getParameter()->getItems()) > 0) { |
|
300 | - foreach ($payment->getParameter()->getItems() as $item) { |
|
301 | - if ($item instanceof PagSeguroParameterItem) { |
|
302 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
303 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
304 | - $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
305 | - } else { |
|
306 | - $data[$item->getKey()] = $item->getValue(); |
|
307 | - } |
|
308 | - } |
|
309 | - } |
|
310 | - } |
|
311 | - } |
|
312 | - return $data; |
|
313 | - } |
|
314 | - |
|
315 | - /*** |
|
190 | + //Token |
|
191 | + if ($payment->getCreditCard()->getToken() != null) { |
|
192 | + $data['creditCardToken'] = $payment->getCreditCard()->getToken(); |
|
193 | + } |
|
194 | + |
|
195 | + //Installments |
|
196 | + if ($payment->getCreditCard()->getInstallment() != null) { |
|
197 | + $installment = $payment->getCreditCard()->getInstallment(); |
|
198 | + if ($installment->getQuantity() != null && $installment->getValue()) { |
|
199 | + $data['installmentQuantity'] = $installment->getQuantity(); |
|
200 | + $data['installmentValue'] = PagSeguroHelper::decimalFormat($installment->getValue()); |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + //Holder |
|
205 | + if ($payment->getCreditCard()->getHolder() != null) { |
|
206 | + $holder = $payment->getCreditCard()->getHolder(); |
|
207 | + if ($holder->getName() != null) { |
|
208 | + $data['creditCardHolderName'] = $holder->getName(); |
|
209 | + } |
|
210 | + // documents |
|
211 | + /*** @var $document PagSeguroDocument */ |
|
212 | + if ($payment->getCreditCard()->getHolder()->getDocuments() != null) { |
|
213 | + $documents = $payment->getCreditCard()->getHolder()->getDocuments(); |
|
214 | + $data['creditCardHolderCPF'] = $documents->getValue(); |
|
215 | + } |
|
216 | + if ($holder->getBirthDate() != null) { |
|
217 | + $data['creditCardHolderBirthDate'] = $holder->getBirthDate(); |
|
218 | + } |
|
219 | + // phone |
|
220 | + if ($holder->getPhone() != null) { |
|
221 | + if ($holder->getPhone()->getAreaCode() != null) { |
|
222 | + $data['creditCardHolderAreaCode'] = $holder->getPhone()->getAreaCode(); |
|
223 | + } |
|
224 | + if ($holder->getPhone()->getNumber() != null) { |
|
225 | + $data['creditCardHolderPhone'] = $holder->getPhone()->getNumber(); |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + //Billing Address |
|
231 | + if ($payment->getCreditCard()->getBilling() != null) { |
|
232 | + $billingAddress = $payment->getCreditCard()->getBilling()->getAddress(); |
|
233 | + if ($billingAddress->getStreet() != null) { |
|
234 | + $data['billingAddressStreet'] = $billingAddress->getStreet(); |
|
235 | + } |
|
236 | + if ($billingAddress->getNumber() != null) { |
|
237 | + $data['billingAddressNumber'] = $billingAddress->getNumber(); |
|
238 | + } |
|
239 | + if ($billingAddress->getComplement() != null) { |
|
240 | + $data['billingAddressComplement'] = $billingAddress->getComplement(); |
|
241 | + } |
|
242 | + if ($billingAddress->getCity() != null) { |
|
243 | + $data['billingAddressCity'] = $billingAddress->getCity(); |
|
244 | + } |
|
245 | + if ($billingAddress->getState() != null) { |
|
246 | + $data['billingAddressState'] = $billingAddress->getState(); |
|
247 | + } |
|
248 | + if ($billingAddress->getDistrict() != null) { |
|
249 | + $data['billingAddressDistrict'] = $billingAddress->getDistrict(); |
|
250 | + } |
|
251 | + if ($billingAddress->getPostalCode() != null) { |
|
252 | + $data['billingAddressPostalCode'] = $billingAddress->getPostalCode(); |
|
253 | + } |
|
254 | + if ($billingAddress->getCountry() != null) { |
|
255 | + $data['billingAddressCountry'] = $billingAddress->getCountry(); |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + } |
|
260 | + |
|
261 | + // maxAge |
|
262 | + if ($payment->getMaxAge() != null) { |
|
263 | + $data['maxAge'] = $payment->getMaxAge(); |
|
264 | + } |
|
265 | + // maxUses |
|
266 | + if ($payment->getMaxUses() != null) { |
|
267 | + $data['maxUses'] = $payment->getMaxUses(); |
|
268 | + } |
|
269 | + |
|
270 | + // redirectURL |
|
271 | + if ($payment->getRedirectURL() != null) { |
|
272 | + $data['redirectURL'] = $payment->getRedirectURL(); |
|
273 | + } |
|
274 | + |
|
275 | + // notificationURL |
|
276 | + if ($payment->getNotificationURL() != null) { |
|
277 | + $data['notificationURL'] = $payment->getNotificationURL(); |
|
278 | + } |
|
279 | + |
|
280 | + // metadata |
|
281 | + if (count($payment->getMetaData()->getItems()) > 0) { |
|
282 | + $i = 0; |
|
283 | + foreach ($payment->getMetaData()->getItems() as $item) { |
|
284 | + if ($item instanceof PagSeguroMetaDataItem) { |
|
285 | + if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
286 | + $i++; |
|
287 | + $data['metadataItemKey' . $i] = $item->getKey(); |
|
288 | + $data['metadataItemValue' . $i] = $item->getValue(); |
|
289 | + |
|
290 | + if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
291 | + $data['metadataItemGroup' . $i] = $item->getGroup(); |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + // parameter |
|
299 | + if (count($payment->getParameter()->getItems()) > 0) { |
|
300 | + foreach ($payment->getParameter()->getItems() as $item) { |
|
301 | + if ($item instanceof PagSeguroParameterItem) { |
|
302 | + if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
303 | + if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
304 | + $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
305 | + } else { |
|
306 | + $data[$item->getKey()] = $item->getValue(); |
|
307 | + } |
|
308 | + } |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | + return $data; |
|
313 | + } |
|
314 | + |
|
315 | + /*** |
|
316 | 316 | * @param $str_xml |
317 | 317 | * @return PagSeguroDirectPaymentData Success |
318 | 318 | */ |
319 | - public static function readSuccessXml($str_xml) |
|
320 | - { |
|
321 | - $parser = new PagSeguroXmlParser($str_xml); |
|
322 | - $data = $parser->getResult('checkout'); |
|
323 | - $PaymentParserData = new PagSeguroPaymentParserData(); |
|
324 | - $PaymentParserData->setCode($data['code']); |
|
325 | - $PaymentParserData->setRegistrationDate($data['date']); |
|
326 | - return $PaymentParserData; |
|
327 | - } |
|
328 | - |
|
329 | - /*** |
|
319 | + public static function readSuccessXml($str_xml) |
|
320 | + { |
|
321 | + $parser = new PagSeguroXmlParser($str_xml); |
|
322 | + $data = $parser->getResult('checkout'); |
|
323 | + $PaymentParserData = new PagSeguroPaymentParserData(); |
|
324 | + $PaymentParserData->setCode($data['code']); |
|
325 | + $PaymentParserData->setRegistrationDate($data['date']); |
|
326 | + return $PaymentParserData; |
|
327 | + } |
|
328 | + |
|
329 | + /*** |
|
330 | 330 | * @param $str_xml |
331 | 331 | * @return parsed credit card brand |
332 | 332 | */ |
333 | - public static function readCCBRandXml($str_xml) |
|
334 | - { |
|
335 | - $parser = new PagSeguroXmlParser($str_xml); |
|
336 | - $PaymentParserData = new PagSeguroPaymentParserData(); |
|
337 | - $PaymentParserData->setCode($data['code']); |
|
338 | - $PaymentParserData->setRegistrationDate($data['date']); |
|
339 | - return $PaymentParserData; |
|
340 | - } |
|
341 | - |
|
342 | - /*** |
|
333 | + public static function readCCBRandXml($str_xml) |
|
334 | + { |
|
335 | + $parser = new PagSeguroXmlParser($str_xml); |
|
336 | + $PaymentParserData = new PagSeguroPaymentParserData(); |
|
337 | + $PaymentParserData->setCode($data['code']); |
|
338 | + $PaymentParserData->setRegistrationDate($data['date']); |
|
339 | + return $PaymentParserData; |
|
340 | + } |
|
341 | + |
|
342 | + /*** |
|
343 | 343 | * @param $str_xml |
344 | 344 | * @return parsed transaction |
345 | 345 | */ |
346 | - public static function readTransactionXml($str_xml) |
|
347 | - { |
|
348 | - $parser = new PagSeguroXmlParser($str_xml); |
|
349 | - $data = $parser->getResult('transaction'); |
|
350 | - $PaymentParserData = new PagSeguroPaymentParserData(); |
|
351 | - $PaymentParserData->setCode($data['code']); |
|
352 | - $PaymentParserData->setRegistrationDate($data['date']); |
|
353 | - return $PaymentParserData; |
|
354 | - } |
|
346 | + public static function readTransactionXml($str_xml) |
|
347 | + { |
|
348 | + $parser = new PagSeguroXmlParser($str_xml); |
|
349 | + $data = $parser->getResult('transaction'); |
|
350 | + $PaymentParserData = new PagSeguroPaymentParserData(); |
|
351 | + $PaymentParserData->setCode($data['code']); |
|
352 | + $PaymentParserData->setRegistrationDate($data['date']); |
|
353 | + return $PaymentParserData; |
|
354 | + } |
|
355 | 355 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $documents = $payment->getSender()->getDocuments(); |
88 | 88 | if (is_array($documents) && count($documents) == 1) { |
89 | 89 | foreach ($documents as $document) { |
90 | - if (!is_null($document)) { |
|
90 | + if ( ! is_null($document)) { |
|
91 | 91 | $data['senderCPF'] = $document->getValue(); |
92 | 92 | } |
93 | 93 | } |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | $i = 0; |
283 | 283 | foreach ($payment->getMetaData()->getItems() as $item) { |
284 | 284 | if ($item instanceof PagSeguroMetaDataItem) { |
285 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
285 | + if ( ! PagSeguroHelper::isEmpty($item->getKey()) && ! PagSeguroHelper::isEmpty($item->getValue())) { |
|
286 | 286 | $i++; |
287 | - $data['metadataItemKey' . $i] = $item->getKey(); |
|
288 | - $data['metadataItemValue' . $i] = $item->getValue(); |
|
287 | + $data['metadataItemKey'.$i] = $item->getKey(); |
|
288 | + $data['metadataItemValue'.$i] = $item->getValue(); |
|
289 | 289 | |
290 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
291 | - $data['metadataItemGroup' . $i] = $item->getGroup(); |
|
290 | + if ( ! PagSeguroHelper::isEmpty($item->getGroup())) { |
|
291 | + $data['metadataItemGroup'.$i] = $item->getGroup(); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | } |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | if (count($payment->getParameter()->getItems()) > 0) { |
300 | 300 | foreach ($payment->getParameter()->getItems() as $item) { |
301 | 301 | if ($item instanceof PagSeguroParameterItem) { |
302 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
303 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
304 | - $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
302 | + if ( ! PagSeguroHelper::isEmpty($item->getKey()) && ! PagSeguroHelper::isEmpty($item->getValue())) { |
|
303 | + if ( ! PagSeguroHelper::isEmpty($item->getGroup())) { |
|
304 | + $data[$item->getKey().''.$item->getGroup()] = $item->getValue(); |
|
305 | 305 | } else { |
306 | 306 | $data[$item->getKey()] = $item->getValue(); |
307 | 307 | } |
@@ -31,6 +31,10 @@ |
||
31 | 31 | * @param $payment PagSeguroPaymentRequest |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | + |
|
35 | + /** |
|
36 | + * @param PagSeguroPaymentRequest $payment |
|
37 | + */ |
|
34 | 38 | public static function getData($payment) |
35 | 39 | { |
36 | 40 |
@@ -27,246 +27,246 @@ |
||
27 | 27 | class PagSeguroPaymentParser extends PagSeguroServiceParser |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * @param $payment PagSeguroPaymentRequest |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | - public static function getData($payment) |
|
35 | - { |
|
34 | + public static function getData($payment) |
|
35 | + { |
|
36 | 36 | |
37 | - $data = null; |
|
37 | + $data = null; |
|
38 | 38 | |
39 | - // reference |
|
40 | - if ($payment->getReference() != null) { |
|
41 | - $data["reference"] = $payment->getReference(); |
|
42 | - } |
|
39 | + // reference |
|
40 | + if ($payment->getReference() != null) { |
|
41 | + $data["reference"] = $payment->getReference(); |
|
42 | + } |
|
43 | 43 | |
44 | - // sender |
|
45 | - if ($payment->getSender() != null) { |
|
44 | + // sender |
|
45 | + if ($payment->getSender() != null) { |
|
46 | 46 | |
47 | - if ($payment->getSender()->getName() != null) { |
|
48 | - $data['senderName'] = $payment->getSender()->getName(); |
|
49 | - } |
|
50 | - if ($payment->getSender()->getEmail() != null) { |
|
51 | - $data['senderEmail'] = $payment->getSender()->getEmail(); |
|
52 | - } |
|
47 | + if ($payment->getSender()->getName() != null) { |
|
48 | + $data['senderName'] = $payment->getSender()->getName(); |
|
49 | + } |
|
50 | + if ($payment->getSender()->getEmail() != null) { |
|
51 | + $data['senderEmail'] = $payment->getSender()->getEmail(); |
|
52 | + } |
|
53 | 53 | |
54 | - // phone |
|
55 | - if ($payment->getSender()->getPhone() != null) { |
|
56 | - if ($payment->getSender()->getPhone()->getAreaCode() != null) { |
|
57 | - $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode(); |
|
58 | - } |
|
59 | - if ($payment->getSender()->getPhone()->getNumber() != null) { |
|
60 | - $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber(); |
|
61 | - } |
|
62 | - } |
|
54 | + // phone |
|
55 | + if ($payment->getSender()->getPhone() != null) { |
|
56 | + if ($payment->getSender()->getPhone()->getAreaCode() != null) { |
|
57 | + $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode(); |
|
58 | + } |
|
59 | + if ($payment->getSender()->getPhone()->getNumber() != null) { |
|
60 | + $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - // documents |
|
65 | - /*** @var $document PagSeguroDocument */ |
|
66 | - if ($payment->getSender()->getDocuments() != null) { |
|
67 | - $documents = $payment->getSender()->getDocuments(); |
|
68 | - if (is_array($documents) && count($documents) == 1) { |
|
69 | - foreach ($documents as $document) { |
|
70 | - if (!is_null($document)) { |
|
71 | - $data['senderCPF'] = $document->getValue(); |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
75 | - } |
|
64 | + // documents |
|
65 | + /*** @var $document PagSeguroDocument */ |
|
66 | + if ($payment->getSender()->getDocuments() != null) { |
|
67 | + $documents = $payment->getSender()->getDocuments(); |
|
68 | + if (is_array($documents) && count($documents) == 1) { |
|
69 | + foreach ($documents as $document) { |
|
70 | + if (!is_null($document)) { |
|
71 | + $data['senderCPF'] = $document->getValue(); |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - if ($payment->getSender()->getIP() != null) { |
|
78 | - $data['ip'] = $payment->getSender()->getIP(); |
|
79 | - } |
|
80 | - } |
|
77 | + if ($payment->getSender()->getIP() != null) { |
|
78 | + $data['ip'] = $payment->getSender()->getIP(); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - // currency |
|
83 | - if ($payment->getCurrency() != null) { |
|
84 | - $data['currency'] = $payment->getCurrency(); |
|
85 | - } |
|
82 | + // currency |
|
83 | + if ($payment->getCurrency() != null) { |
|
84 | + $data['currency'] = $payment->getCurrency(); |
|
85 | + } |
|
86 | 86 | |
87 | - // items |
|
88 | - $items = $payment->getItems(); |
|
89 | - if (count($items) > 0) { |
|
87 | + // items |
|
88 | + $items = $payment->getItems(); |
|
89 | + if (count($items) > 0) { |
|
90 | 90 | |
91 | - $i = 0; |
|
91 | + $i = 0; |
|
92 | 92 | |
93 | - foreach ($items as $key => $value) { |
|
94 | - $i++; |
|
95 | - if ($items[$key]->getId() != null) { |
|
96 | - $data["itemId$i"] = $items[$key]->getId(); |
|
97 | - } |
|
98 | - if ($items[$key]->getDescription() != null) { |
|
99 | - $data["itemDescription$i"] = $items[$key]->getDescription(); |
|
100 | - } |
|
101 | - if ($items[$key]->getQuantity() != null) { |
|
102 | - $data["itemQuantity$i"] = $items[$key]->getQuantity(); |
|
103 | - } |
|
104 | - if ($items[$key]->getAmount() != null) { |
|
105 | - $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount()); |
|
106 | - $data["itemAmount$i"] = $amount; |
|
107 | - } |
|
108 | - if ($items[$key]->getWeight() != null) { |
|
109 | - $data["itemWeight$i"] = $items[$key]->getWeight(); |
|
110 | - } |
|
111 | - if ($items[$key]->getShippingCost() != null) { |
|
112 | - $data["itemShippingCost$i"] = PagSeguroHelper::decimalFormat($items[$key]->getShippingCost()); |
|
113 | - } |
|
114 | - } |
|
115 | - } |
|
93 | + foreach ($items as $key => $value) { |
|
94 | + $i++; |
|
95 | + if ($items[$key]->getId() != null) { |
|
96 | + $data["itemId$i"] = $items[$key]->getId(); |
|
97 | + } |
|
98 | + if ($items[$key]->getDescription() != null) { |
|
99 | + $data["itemDescription$i"] = $items[$key]->getDescription(); |
|
100 | + } |
|
101 | + if ($items[$key]->getQuantity() != null) { |
|
102 | + $data["itemQuantity$i"] = $items[$key]->getQuantity(); |
|
103 | + } |
|
104 | + if ($items[$key]->getAmount() != null) { |
|
105 | + $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount()); |
|
106 | + $data["itemAmount$i"] = $amount; |
|
107 | + } |
|
108 | + if ($items[$key]->getWeight() != null) { |
|
109 | + $data["itemWeight$i"] = $items[$key]->getWeight(); |
|
110 | + } |
|
111 | + if ($items[$key]->getShippingCost() != null) { |
|
112 | + $data["itemShippingCost$i"] = PagSeguroHelper::decimalFormat($items[$key]->getShippingCost()); |
|
113 | + } |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - // extraAmount |
|
118 | - if ($payment->getExtraAmount() != null) { |
|
119 | - $data['extraAmount'] = PagSeguroHelper::decimalFormat($payment->getExtraAmount()); |
|
120 | - } |
|
117 | + // extraAmount |
|
118 | + if ($payment->getExtraAmount() != null) { |
|
119 | + $data['extraAmount'] = PagSeguroHelper::decimalFormat($payment->getExtraAmount()); |
|
120 | + } |
|
121 | 121 | |
122 | - // shipping |
|
123 | - if ($payment->getShipping() != null) { |
|
122 | + // shipping |
|
123 | + if ($payment->getShipping() != null) { |
|
124 | 124 | |
125 | - if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) { |
|
126 | - $data['shippingType'] = $payment->getShipping()->getType()->getValue(); |
|
127 | - } |
|
125 | + if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) { |
|
126 | + $data['shippingType'] = $payment->getShipping()->getType()->getValue(); |
|
127 | + } |
|
128 | 128 | |
129 | - if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) { |
|
130 | - $data['shippingCost'] = PagSeguroHelper::decimalFormat($payment->getShipping()->getCost()); |
|
131 | - } |
|
129 | + if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) { |
|
130 | + $data['shippingCost'] = PagSeguroHelper::decimalFormat($payment->getShipping()->getCost()); |
|
131 | + } |
|
132 | 132 | |
133 | - // address |
|
134 | - if ($payment->getShipping()->getAddress() != null) { |
|
135 | - if ($payment->getShipping()->getAddress()->getStreet() != null) { |
|
136 | - $data['shippingAddressStreet'] = $payment->getShipping()->getAddress()->getStreet(); |
|
137 | - } |
|
138 | - if ($payment->getShipping()->getAddress()->getNumber() != null) { |
|
139 | - $data['shippingAddressNumber'] = $payment->getShipping()->getAddress()->getNumber(); |
|
140 | - } |
|
141 | - if ($payment->getShipping()->getAddress()->getComplement() != null) { |
|
142 | - $data['shippingAddressComplement'] = $payment->getShipping()->getAddress()->getComplement(); |
|
143 | - } |
|
144 | - if ($payment->getShipping()->getAddress()->getCity() != null) { |
|
145 | - $data['shippingAddressCity'] = $payment->getShipping()->getAddress()->getCity(); |
|
146 | - } |
|
147 | - if ($payment->getShipping()->getAddress()->getState() != null) { |
|
148 | - $data['shippingAddressState'] = $payment->getShipping()->getAddress()->getState(); |
|
149 | - } |
|
150 | - if ($payment->getShipping()->getAddress()->getDistrict() != null) { |
|
151 | - $data['shippingAddressDistrict'] = $payment->getShipping()->getAddress()->getDistrict(); |
|
152 | - } |
|
153 | - if ($payment->getShipping()->getAddress()->getPostalCode() != null) { |
|
154 | - $data['shippingAddressPostalCode'] = $payment->getShipping()->getAddress()->getPostalCode(); |
|
155 | - } |
|
156 | - if ($payment->getShipping()->getAddress()->getCountry() != null) { |
|
157 | - $data['shippingAddressCountry'] = $payment->getShipping()->getAddress()->getCountry(); |
|
158 | - } |
|
159 | - } |
|
160 | - } |
|
161 | - // maxAge |
|
162 | - if ($payment->getMaxAge() != null) { |
|
163 | - $data['maxAge'] = $payment->getMaxAge(); |
|
164 | - } |
|
165 | - // maxUses |
|
166 | - if ($payment->getMaxUses() != null) { |
|
167 | - $data['maxUses'] = $payment->getMaxUses(); |
|
168 | - } |
|
133 | + // address |
|
134 | + if ($payment->getShipping()->getAddress() != null) { |
|
135 | + if ($payment->getShipping()->getAddress()->getStreet() != null) { |
|
136 | + $data['shippingAddressStreet'] = $payment->getShipping()->getAddress()->getStreet(); |
|
137 | + } |
|
138 | + if ($payment->getShipping()->getAddress()->getNumber() != null) { |
|
139 | + $data['shippingAddressNumber'] = $payment->getShipping()->getAddress()->getNumber(); |
|
140 | + } |
|
141 | + if ($payment->getShipping()->getAddress()->getComplement() != null) { |
|
142 | + $data['shippingAddressComplement'] = $payment->getShipping()->getAddress()->getComplement(); |
|
143 | + } |
|
144 | + if ($payment->getShipping()->getAddress()->getCity() != null) { |
|
145 | + $data['shippingAddressCity'] = $payment->getShipping()->getAddress()->getCity(); |
|
146 | + } |
|
147 | + if ($payment->getShipping()->getAddress()->getState() != null) { |
|
148 | + $data['shippingAddressState'] = $payment->getShipping()->getAddress()->getState(); |
|
149 | + } |
|
150 | + if ($payment->getShipping()->getAddress()->getDistrict() != null) { |
|
151 | + $data['shippingAddressDistrict'] = $payment->getShipping()->getAddress()->getDistrict(); |
|
152 | + } |
|
153 | + if ($payment->getShipping()->getAddress()->getPostalCode() != null) { |
|
154 | + $data['shippingAddressPostalCode'] = $payment->getShipping()->getAddress()->getPostalCode(); |
|
155 | + } |
|
156 | + if ($payment->getShipping()->getAddress()->getCountry() != null) { |
|
157 | + $data['shippingAddressCountry'] = $payment->getShipping()->getAddress()->getCountry(); |
|
158 | + } |
|
159 | + } |
|
160 | + } |
|
161 | + // maxAge |
|
162 | + if ($payment->getMaxAge() != null) { |
|
163 | + $data['maxAge'] = $payment->getMaxAge(); |
|
164 | + } |
|
165 | + // maxUses |
|
166 | + if ($payment->getMaxUses() != null) { |
|
167 | + $data['maxUses'] = $payment->getMaxUses(); |
|
168 | + } |
|
169 | 169 | |
170 | - // redirectURL |
|
171 | - if ($payment->getRedirectURL() != null) { |
|
172 | - $data['redirectURL'] = $payment->getRedirectURL(); |
|
173 | - } |
|
170 | + // redirectURL |
|
171 | + if ($payment->getRedirectURL() != null) { |
|
172 | + $data['redirectURL'] = $payment->getRedirectURL(); |
|
173 | + } |
|
174 | 174 | |
175 | - // notificationURL |
|
176 | - if ($payment->getNotificationURL() != null) { |
|
177 | - $data['notificationURL'] = $payment->getNotificationURL(); |
|
178 | - } |
|
175 | + // notificationURL |
|
176 | + if ($payment->getNotificationURL() != null) { |
|
177 | + $data['notificationURL'] = $payment->getNotificationURL(); |
|
178 | + } |
|
179 | 179 | |
180 | - // metadata |
|
181 | - if (count($payment->getMetaData()->getItems()) > 0) { |
|
182 | - $i = 0; |
|
183 | - foreach ($payment->getMetaData()->getItems() as $item) { |
|
184 | - if ($item instanceof PagSeguroMetaDataItem) { |
|
185 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
186 | - $i++; |
|
187 | - $data['metadataItemKey' . $i] = $item->getKey(); |
|
188 | - $data['metadataItemValue' . $i] = $item->getValue(); |
|
180 | + // metadata |
|
181 | + if (count($payment->getMetaData()->getItems()) > 0) { |
|
182 | + $i = 0; |
|
183 | + foreach ($payment->getMetaData()->getItems() as $item) { |
|
184 | + if ($item instanceof PagSeguroMetaDataItem) { |
|
185 | + if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
186 | + $i++; |
|
187 | + $data['metadataItemKey' . $i] = $item->getKey(); |
|
188 | + $data['metadataItemValue' . $i] = $item->getValue(); |
|
189 | 189 | |
190 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
191 | - $data['metadataItemGroup' . $i] = $item->getGroup(); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
190 | + if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
191 | + $data['metadataItemGroup' . $i] = $item->getGroup(); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | 197 | |
198 | - // paymentMethodConfig |
|
199 | - if (count($payment->getPaymentMethodConfig()->getConfig()) > 0) { |
|
200 | - $i = 0; |
|
201 | - foreach ($payment->getPaymentMethodConfig()->getConfig() as $config) { |
|
202 | - if ($config instanceof PagSeguroPaymentMethodConfigItem) { |
|
203 | - if (!PagSeguroHelper::isEmpty($config->getKey()) && !PagSeguroHelper::isEmpty($config->getValue())) { |
|
204 | - $i++; |
|
205 | - if (!PagSeguroHelper::isEmpty($config->getGroup())) { |
|
206 | - $data['paymentMethodGroup' . $i] = $config->getGroup(); |
|
207 | - } |
|
208 | - $data['paymentMethodConfigKey' . $i . "_1"] = $config->getKey(); |
|
209 | - $data['paymentMethodConfigValue' . $i . "_1"] = $config->getValue(); |
|
210 | - } |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
198 | + // paymentMethodConfig |
|
199 | + if (count($payment->getPaymentMethodConfig()->getConfig()) > 0) { |
|
200 | + $i = 0; |
|
201 | + foreach ($payment->getPaymentMethodConfig()->getConfig() as $config) { |
|
202 | + if ($config instanceof PagSeguroPaymentMethodConfigItem) { |
|
203 | + if (!PagSeguroHelper::isEmpty($config->getKey()) && !PagSeguroHelper::isEmpty($config->getValue())) { |
|
204 | + $i++; |
|
205 | + if (!PagSeguroHelper::isEmpty($config->getGroup())) { |
|
206 | + $data['paymentMethodGroup' . $i] = $config->getGroup(); |
|
207 | + } |
|
208 | + $data['paymentMethodConfigKey' . $i . "_1"] = $config->getKey(); |
|
209 | + $data['paymentMethodConfigValue' . $i . "_1"] = $config->getValue(); |
|
210 | + } |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | - // parameter |
|
216 | - if (count($payment->getParameter()->getItems()) > 0) { |
|
217 | - foreach ($payment->getParameter()->getItems() as $item) { |
|
218 | - if ($item instanceof PagSeguroParameterItem) { |
|
219 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
220 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
221 | - $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
222 | - } else { |
|
223 | - $data[$item->getKey()] = $item->getValue(); |
|
224 | - } |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - return $data; |
|
230 | - } |
|
215 | + // parameter |
|
216 | + if (count($payment->getParameter()->getItems()) > 0) { |
|
217 | + foreach ($payment->getParameter()->getItems() as $item) { |
|
218 | + if ($item instanceof PagSeguroParameterItem) { |
|
219 | + if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
220 | + if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
221 | + $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
222 | + } else { |
|
223 | + $data[$item->getKey()] = $item->getValue(); |
|
224 | + } |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + return $data; |
|
230 | + } |
|
231 | 231 | |
232 | - /*** |
|
232 | + /*** |
|
233 | 233 | * @param $str_xml |
234 | 234 | * @return PagSeguroPaymentParserData Success |
235 | 235 | */ |
236 | - public static function readSuccessXml($str_xml) |
|
237 | - { |
|
238 | - $parser = new PagSeguroXmlParser($str_xml); |
|
239 | - $data = $parser->getResult('checkout'); |
|
240 | - $PaymentParserData = new PagSeguroPaymentParserData(); |
|
241 | - $PaymentParserData->setCode($data['code']); |
|
242 | - $PaymentParserData->setRegistrationDate($data['date']); |
|
243 | - return $PaymentParserData; |
|
244 | - } |
|
236 | + public static function readSuccessXml($str_xml) |
|
237 | + { |
|
238 | + $parser = new PagSeguroXmlParser($str_xml); |
|
239 | + $data = $parser->getResult('checkout'); |
|
240 | + $PaymentParserData = new PagSeguroPaymentParserData(); |
|
241 | + $PaymentParserData->setCode($data['code']); |
|
242 | + $PaymentParserData->setRegistrationDate($data['date']); |
|
243 | + return $PaymentParserData; |
|
244 | + } |
|
245 | 245 | |
246 | - /*** |
|
246 | + /*** |
|
247 | 247 | * @param $str_xml |
248 | 248 | * @return parsed credit card brand |
249 | 249 | */ |
250 | - public static function readCCBRandXml($str_xml) |
|
251 | - { |
|
252 | - $parser = new PagSeguroXmlParser($str_xml); |
|
253 | - $PaymentParserData = new PagSeguroPaymentParserData(); |
|
254 | - $PaymentParserData->setCode($data['code']); |
|
255 | - $PaymentParserData->setRegistrationDate($data['date']); |
|
256 | - return $PaymentParserData; |
|
257 | - } |
|
250 | + public static function readCCBRandXml($str_xml) |
|
251 | + { |
|
252 | + $parser = new PagSeguroXmlParser($str_xml); |
|
253 | + $PaymentParserData = new PagSeguroPaymentParserData(); |
|
254 | + $PaymentParserData->setCode($data['code']); |
|
255 | + $PaymentParserData->setRegistrationDate($data['date']); |
|
256 | + return $PaymentParserData; |
|
257 | + } |
|
258 | 258 | |
259 | - /*** |
|
259 | + /*** |
|
260 | 260 | * @param $str_xml |
261 | 261 | * @return parsed transaction |
262 | 262 | */ |
263 | - public static function readTransactionXml($str_xml) |
|
264 | - { |
|
265 | - $parser = new PagSeguroXmlParser($str_xml); |
|
266 | - $data = $parser->getResult('transaction'); |
|
267 | - $PaymentParserData = new PagSeguroPaymentParserData(); |
|
268 | - $PaymentParserData->setCode($data['code']); |
|
269 | - $PaymentParserData->setRegistrationDate($data['date']); |
|
270 | - return $PaymentParserData; |
|
271 | - } |
|
263 | + public static function readTransactionXml($str_xml) |
|
264 | + { |
|
265 | + $parser = new PagSeguroXmlParser($str_xml); |
|
266 | + $data = $parser->getResult('transaction'); |
|
267 | + $PaymentParserData = new PagSeguroPaymentParserData(); |
|
268 | + $PaymentParserData->setCode($data['code']); |
|
269 | + $PaymentParserData->setRegistrationDate($data['date']); |
|
270 | + return $PaymentParserData; |
|
271 | + } |
|
272 | 272 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $documents = $payment->getSender()->getDocuments(); |
68 | 68 | if (is_array($documents) && count($documents) == 1) { |
69 | 69 | foreach ($documents as $document) { |
70 | - if (!is_null($document)) { |
|
70 | + if ( ! is_null($document)) { |
|
71 | 71 | $data['senderCPF'] = $document->getValue(); |
72 | 72 | } |
73 | 73 | } |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | $i = 0; |
183 | 183 | foreach ($payment->getMetaData()->getItems() as $item) { |
184 | 184 | if ($item instanceof PagSeguroMetaDataItem) { |
185 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
185 | + if ( ! PagSeguroHelper::isEmpty($item->getKey()) && ! PagSeguroHelper::isEmpty($item->getValue())) { |
|
186 | 186 | $i++; |
187 | - $data['metadataItemKey' . $i] = $item->getKey(); |
|
188 | - $data['metadataItemValue' . $i] = $item->getValue(); |
|
187 | + $data['metadataItemKey'.$i] = $item->getKey(); |
|
188 | + $data['metadataItemValue'.$i] = $item->getValue(); |
|
189 | 189 | |
190 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
191 | - $data['metadataItemGroup' . $i] = $item->getGroup(); |
|
190 | + if ( ! PagSeguroHelper::isEmpty($item->getGroup())) { |
|
191 | + $data['metadataItemGroup'.$i] = $item->getGroup(); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | $i = 0; |
201 | 201 | foreach ($payment->getPaymentMethodConfig()->getConfig() as $config) { |
202 | 202 | if ($config instanceof PagSeguroPaymentMethodConfigItem) { |
203 | - if (!PagSeguroHelper::isEmpty($config->getKey()) && !PagSeguroHelper::isEmpty($config->getValue())) { |
|
203 | + if ( ! PagSeguroHelper::isEmpty($config->getKey()) && ! PagSeguroHelper::isEmpty($config->getValue())) { |
|
204 | 204 | $i++; |
205 | - if (!PagSeguroHelper::isEmpty($config->getGroup())) { |
|
206 | - $data['paymentMethodGroup' . $i] = $config->getGroup(); |
|
205 | + if ( ! PagSeguroHelper::isEmpty($config->getGroup())) { |
|
206 | + $data['paymentMethodGroup'.$i] = $config->getGroup(); |
|
207 | 207 | } |
208 | - $data['paymentMethodConfigKey' . $i . "_1"] = $config->getKey(); |
|
209 | - $data['paymentMethodConfigValue' . $i . "_1"] = $config->getValue(); |
|
208 | + $data['paymentMethodConfigKey'.$i."_1"] = $config->getKey(); |
|
209 | + $data['paymentMethodConfigValue'.$i."_1"] = $config->getValue(); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | if (count($payment->getParameter()->getItems()) > 0) { |
217 | 217 | foreach ($payment->getParameter()->getItems() as $item) { |
218 | 218 | if ($item instanceof PagSeguroParameterItem) { |
219 | - if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) { |
|
220 | - if (!PagSeguroHelper::isEmpty($item->getGroup())) { |
|
221 | - $data[$item->getKey() . '' . $item->getGroup()] = $item->getValue(); |
|
219 | + if ( ! PagSeguroHelper::isEmpty($item->getKey()) && ! PagSeguroHelper::isEmpty($item->getValue())) { |
|
220 | + if ( ! PagSeguroHelper::isEmpty($item->getGroup())) { |
|
221 | + $data[$item->getKey().''.$item->getGroup()] = $item->getValue(); |
|
222 | 222 | } else { |
223 | 223 | $data[$item->getKey()] = $item->getValue(); |
224 | 224 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @param PagSeguroConnectionData $connectionData |
40 | - * @param $authorizationCode |
|
40 | + * @param string $authorizationCode |
|
41 | 41 | * @return string |
42 | 42 | */ |
43 | 43 | private static function buildSearchUrlByCode(PagSeguroConnectionData $connectionData, $authorizationCode) |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * @param PagSeguroConnectionData $connectionData |
50 | - * @param $notificationCode |
|
50 | + * @param string $notificationCode |
|
51 | 51 | * @return string |
52 | 52 | */ |
53 | 53 | private static function buildSearchUrlByNotification(PagSeguroConnectionData $connectionData, $notificationCode) |
@@ -186,6 +186,10 @@ discard block |
||
186 | 186 | * @throws PagSeguroServiceException |
187 | 187 | * @throws Exception |
188 | 188 | */ |
189 | + |
|
190 | + /** |
|
191 | + * @param string $reference |
|
192 | + */ |
|
189 | 193 | public static function searchByReference(PagSeguroCredentials $credentials, $reference) |
190 | 194 | { |
191 | 195 | LogPagSeguro::info("PagSeguroAuthorizationSearchService.SearchByReference($reference) - begin"); |
@@ -213,7 +217,7 @@ discard block |
||
213 | 217 | |
214 | 218 | /** |
215 | 219 | * @param PagSeguroHttpConnection $connection |
216 | - * @param string $authorizationCode |
|
220 | + * @param string $code |
|
217 | 221 | * @return bool|mixed|string |
218 | 222 | * @throws PagSeguroServiceException |
219 | 223 | */ |
@@ -25,62 +25,62 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class PagSeguroAuthorizationSearchService |
27 | 27 | { |
28 | - /** |
|
29 | - * |
|
30 | - */ |
|
31 | - const SERVICE_NAME = 'authorizationService'; |
|
28 | + /** |
|
29 | + * |
|
30 | + */ |
|
31 | + const SERVICE_NAME = 'authorizationService'; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var information about the log service |
|
35 | - */ |
|
36 | - private static $logService; |
|
33 | + /** |
|
34 | + * @var information about the log service |
|
35 | + */ |
|
36 | + private static $logService; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param PagSeguroConnectionData $connectionData |
|
40 | - * @param $authorizationCode |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - private static function buildSearchUrlByCode(PagSeguroConnectionData $connectionData, $authorizationCode) |
|
44 | - { |
|
45 | - $url = $connectionData->getServiceUrl(); |
|
46 | - return "{$url}/{$authorizationCode}/?" . $connectionData->getCredentialsUrlQuery(); |
|
47 | - } |
|
48 | - /** |
|
49 | - * @param PagSeguroConnectionData $connectionData |
|
50 | - * @param $notificationCode |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - private static function buildSearchUrlByNotification(PagSeguroConnectionData $connectionData, $notificationCode) |
|
54 | - { |
|
55 | - $url = $connectionData->getServiceUrl(); |
|
56 | - return "{$url}/notifications/{$notificationCode}/?" . $connectionData->getCredentialsUrlQuery(); |
|
57 | - } |
|
58 | - /** |
|
59 | - * @param PagSeguroConnectionData $connectionData |
|
60 | - * @param null|array $options |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - private static function buildSearchUrl(PagSeguroConnectionData $connectionData, $options = null) |
|
64 | - { |
|
65 | - if (!is_null($options)) { |
|
66 | - $options = http_build_query($options, '', '&'); |
|
67 | - return $connectionData->getServiceUrl() . "/?" . $connectionData->getCredentialsUrlQuery() . "&" . $options; |
|
68 | - } |
|
69 | - return $connectionData->getServiceUrl() . "/?" . $connectionData->getCredentialsUrlQuery(); |
|
70 | - } |
|
38 | + /** |
|
39 | + * @param PagSeguroConnectionData $connectionData |
|
40 | + * @param $authorizationCode |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + private static function buildSearchUrlByCode(PagSeguroConnectionData $connectionData, $authorizationCode) |
|
44 | + { |
|
45 | + $url = $connectionData->getServiceUrl(); |
|
46 | + return "{$url}/{$authorizationCode}/?" . $connectionData->getCredentialsUrlQuery(); |
|
47 | + } |
|
48 | + /** |
|
49 | + * @param PagSeguroConnectionData $connectionData |
|
50 | + * @param $notificationCode |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + private static function buildSearchUrlByNotification(PagSeguroConnectionData $connectionData, $notificationCode) |
|
54 | + { |
|
55 | + $url = $connectionData->getServiceUrl(); |
|
56 | + return "{$url}/notifications/{$notificationCode}/?" . $connectionData->getCredentialsUrlQuery(); |
|
57 | + } |
|
58 | + /** |
|
59 | + * @param PagSeguroConnectionData $connectionData |
|
60 | + * @param null|array $options |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + private static function buildSearchUrl(PagSeguroConnectionData $connectionData, $options = null) |
|
64 | + { |
|
65 | + if (!is_null($options)) { |
|
66 | + $options = http_build_query($options, '', '&'); |
|
67 | + return $connectionData->getServiceUrl() . "/?" . $connectionData->getCredentialsUrlQuery() . "&" . $options; |
|
68 | + } |
|
69 | + return $connectionData->getServiceUrl() . "/?" . $connectionData->getCredentialsUrlQuery(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param PagSeguroConnectionData $connectionData |
|
74 | - * @param $reference |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - private static function buildSearchUrlByReference(PagSeguroConnectionData $connectionData, $reference) |
|
78 | - { |
|
79 | - $url = $connectionData->getServiceUrl(); |
|
80 | - return "{$url}?" . $connectionData->getCredentialsUrlQuery() . '&reference='.$reference; |
|
81 | - } |
|
72 | + /** |
|
73 | + * @param PagSeguroConnectionData $connectionData |
|
74 | + * @param $reference |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + private static function buildSearchUrlByReference(PagSeguroConnectionData $connectionData, $reference) |
|
78 | + { |
|
79 | + $url = $connectionData->getServiceUrl(); |
|
80 | + return "{$url}?" . $connectionData->getCredentialsUrlQuery() . '&reference='.$reference; |
|
81 | + } |
|
82 | 82 | |
83 | - /*** |
|
83 | + /*** |
|
84 | 84 | * Finds a authorization with a matching authorization code |
85 | 85 | * |
86 | 86 | * @param PagSeguroCredentials $credentials |
@@ -90,31 +90,31 @@ discard block |
||
90 | 90 | * @throws PagSeguroServiceException |
91 | 91 | * @throws Exception |
92 | 92 | */ |
93 | - public static function searchByCode(PagSeguroCredentials $credentials, $authorizationCode) |
|
94 | - { |
|
95 | - LogPagSeguro::info("PagSeguroAuthorizationSearchService.SearchByCode($authorizationCode) - begin"); |
|
96 | - $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
97 | - try { |
|
98 | - $connection = new PagSeguroHttpConnection(); |
|
99 | - $connection->get( |
|
100 | - self::buildSearchUrlByCode($connectionData, $authorizationCode), |
|
101 | - $connectionData->getServiceTimeout(), |
|
102 | - $connectionData->getCharset() |
|
103 | - ); |
|
93 | + public static function searchByCode(PagSeguroCredentials $credentials, $authorizationCode) |
|
94 | + { |
|
95 | + LogPagSeguro::info("PagSeguroAuthorizationSearchService.SearchByCode($authorizationCode) - begin"); |
|
96 | + $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
97 | + try { |
|
98 | + $connection = new PagSeguroHttpConnection(); |
|
99 | + $connection->get( |
|
100 | + self::buildSearchUrlByCode($connectionData, $authorizationCode), |
|
101 | + $connectionData->getServiceTimeout(), |
|
102 | + $connectionData->getCharset() |
|
103 | + ); |
|
104 | 104 | |
105 | - self::$logService = "SearchByCode"; |
|
106 | - return self::searchReturn($connection, $authorizationCode); |
|
105 | + self::$logService = "SearchByCode"; |
|
106 | + return self::searchReturn($connection, $authorizationCode); |
|
107 | 107 | |
108 | - } catch (PagSeguroServiceException $err) { |
|
109 | - throw $err; |
|
110 | - } |
|
111 | - catch (Exception $err) { |
|
112 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
113 | - throw $err; |
|
114 | - } |
|
115 | - } |
|
108 | + } catch (PagSeguroServiceException $err) { |
|
109 | + throw $err; |
|
110 | + } |
|
111 | + catch (Exception $err) { |
|
112 | + LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
113 | + throw $err; |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - /*** |
|
117 | + /*** |
|
118 | 118 | * Finds a authorization with a matching notification code |
119 | 119 | * |
120 | 120 | * @param PagSeguroCredentials $credentials |
@@ -124,29 +124,29 @@ discard block |
||
124 | 124 | * @throws PagSeguroServiceException |
125 | 125 | * @throws Exception |
126 | 126 | */ |
127 | - public static function searchByNotificationCode(PagSeguroCredentials $credentials, $notificationCode) |
|
128 | - { |
|
129 | - LogPagSeguro::info("PagSeguroAuthorizationSearchService.searchByNotificationCode($notificationCode) - begin"); |
|
130 | - $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
131 | - try { |
|
132 | - $connection = new PagSeguroHttpConnection(); |
|
133 | - $connection->get( |
|
134 | - self::buildSearchUrlByNotification($connectionData, $notificationCode), |
|
135 | - $connectionData->getServiceTimeout(), |
|
136 | - $connectionData->getCharset() |
|
137 | - ); |
|
127 | + public static function searchByNotificationCode(PagSeguroCredentials $credentials, $notificationCode) |
|
128 | + { |
|
129 | + LogPagSeguro::info("PagSeguroAuthorizationSearchService.searchByNotificationCode($notificationCode) - begin"); |
|
130 | + $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
131 | + try { |
|
132 | + $connection = new PagSeguroHttpConnection(); |
|
133 | + $connection->get( |
|
134 | + self::buildSearchUrlByNotification($connectionData, $notificationCode), |
|
135 | + $connectionData->getServiceTimeout(), |
|
136 | + $connectionData->getCharset() |
|
137 | + ); |
|
138 | 138 | |
139 | - self::$logService = "SearchByNotificationCode"; |
|
140 | - return self::searchReturn($connection, $notificationCode); |
|
139 | + self::$logService = "SearchByNotificationCode"; |
|
140 | + return self::searchReturn($connection, $notificationCode); |
|
141 | 141 | |
142 | - } catch (PagSeguroServiceException $err) { |
|
143 | - throw $err; |
|
144 | - } catch (Exception $err) { |
|
145 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
146 | - throw $err; |
|
147 | - } |
|
148 | - } |
|
149 | - /*** |
|
142 | + } catch (PagSeguroServiceException $err) { |
|
143 | + throw $err; |
|
144 | + } catch (Exception $err) { |
|
145 | + LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
146 | + throw $err; |
|
147 | + } |
|
148 | + } |
|
149 | + /*** |
|
150 | 150 | * Finds a authorization with a matching authorization credentials |
151 | 151 | * |
152 | 152 | * @param PagSeguroCredentials $credentials |
@@ -156,27 +156,27 @@ discard block |
||
156 | 156 | * @throws PagSeguroServiceException |
157 | 157 | * @throws Exception |
158 | 158 | */ |
159 | - public static function searchAuthorizations(PagSeguroCredentials $credentials, array $options = null) |
|
160 | - { |
|
161 | - LogPagSeguro::info("PagSeguroAuthorizationSearchService.searchAuthorizations() - begin"); |
|
162 | - $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
163 | - try { |
|
164 | - $connection = new PagSeguroHttpConnection(); |
|
165 | - $connection->get( |
|
166 | - self::buildSearchUrl($connectionData, $options), |
|
167 | - $connectionData->getServiceTimeout(), |
|
168 | - $connectionData->getCharset() |
|
169 | - ); |
|
170 | - return self::searchAuthorizationsReturn($connection); |
|
171 | - } catch (PagSeguroServiceException $err) { |
|
172 | - throw $err; |
|
173 | - } catch (Exception $err) { |
|
174 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
175 | - throw $err; |
|
176 | - } |
|
177 | - } |
|
159 | + public static function searchAuthorizations(PagSeguroCredentials $credentials, array $options = null) |
|
160 | + { |
|
161 | + LogPagSeguro::info("PagSeguroAuthorizationSearchService.searchAuthorizations() - begin"); |
|
162 | + $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
163 | + try { |
|
164 | + $connection = new PagSeguroHttpConnection(); |
|
165 | + $connection->get( |
|
166 | + self::buildSearchUrl($connectionData, $options), |
|
167 | + $connectionData->getServiceTimeout(), |
|
168 | + $connectionData->getCharset() |
|
169 | + ); |
|
170 | + return self::searchAuthorizationsReturn($connection); |
|
171 | + } catch (PagSeguroServiceException $err) { |
|
172 | + throw $err; |
|
173 | + } catch (Exception $err) { |
|
174 | + LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
175 | + throw $err; |
|
176 | + } |
|
177 | + } |
|
178 | 178 | |
179 | - /*** |
|
179 | + /*** |
|
180 | 180 | * Finds a authorization with a matching authorization code |
181 | 181 | * |
182 | 182 | * @param PagSeguroCredentials $credentials |
@@ -186,104 +186,104 @@ discard block |
||
186 | 186 | * @throws PagSeguroServiceException |
187 | 187 | * @throws Exception |
188 | 188 | */ |
189 | - public static function searchByReference(PagSeguroCredentials $credentials, $reference) |
|
190 | - { |
|
191 | - LogPagSeguro::info("PagSeguroAuthorizationSearchService.SearchByReference($reference) - begin"); |
|
192 | - $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
189 | + public static function searchByReference(PagSeguroCredentials $credentials, $reference) |
|
190 | + { |
|
191 | + LogPagSeguro::info("PagSeguroAuthorizationSearchService.SearchByReference($reference) - begin"); |
|
192 | + $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
193 | 193 | |
194 | - try { |
|
195 | - $connection = new PagSeguroHttpConnection(); |
|
196 | - $connection->get( |
|
197 | - self::buildSearchUrlByReference($connectionData, $reference), |
|
198 | - $connectionData->getServiceTimeout(), |
|
199 | - $connectionData->getCharset() |
|
200 | - ); |
|
194 | + try { |
|
195 | + $connection = new PagSeguroHttpConnection(); |
|
196 | + $connection->get( |
|
197 | + self::buildSearchUrlByReference($connectionData, $reference), |
|
198 | + $connectionData->getServiceTimeout(), |
|
199 | + $connectionData->getCharset() |
|
200 | + ); |
|
201 | 201 | |
202 | - self::$logService = "SearchByReference"; |
|
203 | - return self::searchAuthorizationsReturn($connection, $reference); |
|
202 | + self::$logService = "SearchByReference"; |
|
203 | + return self::searchAuthorizationsReturn($connection, $reference); |
|
204 | 204 | |
205 | - } catch (PagSeguroServiceException $err) { |
|
206 | - throw $err; |
|
207 | - } |
|
208 | - catch (Exception $err) { |
|
209 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
210 | - throw $err; |
|
211 | - } |
|
212 | - } |
|
205 | + } catch (PagSeguroServiceException $err) { |
|
206 | + throw $err; |
|
207 | + } |
|
208 | + catch (Exception $err) { |
|
209 | + LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
210 | + throw $err; |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * @param PagSeguroHttpConnection $connection |
|
216 | - * @param string $authorizationCode |
|
217 | - * @return bool|mixed|string |
|
218 | - * @throws PagSeguroServiceException |
|
219 | - */ |
|
220 | - private function searchReturn($connection, $code) |
|
221 | - { |
|
222 | - $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
223 | - switch ($httpStatus->getType()) { |
|
224 | - case 'OK': |
|
225 | - $authorization = PagSeguroAuthorizationParser::readAuthorization($connection->getResponse()); |
|
226 | - LogPagSeguro::info( |
|
227 | - sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - end ", self::$logService) . |
|
228 | - $authorization->toString() |
|
229 | - ); |
|
230 | - break; |
|
231 | - case 'BAD_REQUEST': |
|
232 | - $errors = PagSeguroAuthorizationParser::readErrors($connection->getResponse()); |
|
233 | - $err = new PagSeguroServiceException($httpStatus, $errors); |
|
234 | - LogPagSeguro::error( |
|
235 | - sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService) . |
|
236 | - $err->getOneLineMessage() |
|
237 | - ); |
|
238 | - throw $err; |
|
239 | - break; |
|
240 | - default: |
|
241 | - $err = new PagSeguroServiceException($httpStatus); |
|
242 | - LogPagSeguro::error( |
|
243 | - sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService) . |
|
244 | - $err->getOneLineMessage() |
|
245 | - ); |
|
246 | - throw $err; |
|
247 | - break; |
|
248 | - } |
|
249 | - return isset($authorization) ? $authorization : false; |
|
250 | - } |
|
214 | + /** |
|
215 | + * @param PagSeguroHttpConnection $connection |
|
216 | + * @param string $authorizationCode |
|
217 | + * @return bool|mixed|string |
|
218 | + * @throws PagSeguroServiceException |
|
219 | + */ |
|
220 | + private function searchReturn($connection, $code) |
|
221 | + { |
|
222 | + $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
223 | + switch ($httpStatus->getType()) { |
|
224 | + case 'OK': |
|
225 | + $authorization = PagSeguroAuthorizationParser::readAuthorization($connection->getResponse()); |
|
226 | + LogPagSeguro::info( |
|
227 | + sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - end ", self::$logService) . |
|
228 | + $authorization->toString() |
|
229 | + ); |
|
230 | + break; |
|
231 | + case 'BAD_REQUEST': |
|
232 | + $errors = PagSeguroAuthorizationParser::readErrors($connection->getResponse()); |
|
233 | + $err = new PagSeguroServiceException($httpStatus, $errors); |
|
234 | + LogPagSeguro::error( |
|
235 | + sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService) . |
|
236 | + $err->getOneLineMessage() |
|
237 | + ); |
|
238 | + throw $err; |
|
239 | + break; |
|
240 | + default: |
|
241 | + $err = new PagSeguroServiceException($httpStatus); |
|
242 | + LogPagSeguro::error( |
|
243 | + sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService) . |
|
244 | + $err->getOneLineMessage() |
|
245 | + ); |
|
246 | + throw $err; |
|
247 | + break; |
|
248 | + } |
|
249 | + return isset($authorization) ? $authorization : false; |
|
250 | + } |
|
251 | 251 | |
252 | - /** |
|
253 | - * @param PagSeguroHttpConnection $connection |
|
254 | - * @return bool|mixed|string |
|
255 | - * @throws PagSeguroServiceException |
|
256 | - */ |
|
257 | - private function searchAuthorizationsReturn($connection) |
|
258 | - { |
|
259 | - $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
260 | - switch ($httpStatus->getType()) { |
|
261 | - case 'OK': |
|
262 | - $authorization = PagSeguroAuthorizationParser::readSearchResult($connection->getResponse()); |
|
252 | + /** |
|
253 | + * @param PagSeguroHttpConnection $connection |
|
254 | + * @return bool|mixed|string |
|
255 | + * @throws PagSeguroServiceException |
|
256 | + */ |
|
257 | + private function searchAuthorizationsReturn($connection) |
|
258 | + { |
|
259 | + $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
260 | + switch ($httpStatus->getType()) { |
|
261 | + case 'OK': |
|
262 | + $authorization = PagSeguroAuthorizationParser::readSearchResult($connection->getResponse()); |
|
263 | 263 | |
264 | - LogPagSeguro::info( |
|
265 | - "PagSeguroAuthorizationSearchService.searchAuthorizations() - end " . |
|
266 | - $authorization->toString() |
|
267 | - ); |
|
268 | - break; |
|
269 | - case 'BAD_REQUEST': |
|
270 | - $errors = PagSeguroAuthorizationParser::readErrors($connection->getResponse()); |
|
271 | - $err = new PagSeguroServiceException($httpStatus, $errors); |
|
272 | - LogPagSeguro::error( |
|
273 | - "PagSeguroAuthorizationSearchService.searchAuthorizations() - error " . |
|
274 | - $err->getOneLineMessage() |
|
275 | - ); |
|
276 | - throw $err; |
|
277 | - break; |
|
278 | - default: |
|
279 | - $err = new PagSeguroServiceException($httpStatus); |
|
280 | - LogPagSeguro::error( |
|
281 | - "PagSeguroAuthorizationSearchService.searchAuthorizations() - error " . |
|
282 | - $err->getOneLineMessage() |
|
283 | - ); |
|
284 | - throw $err; |
|
285 | - break; |
|
286 | - } |
|
287 | - return isset($authorization) ? $authorization : false; |
|
288 | - } |
|
264 | + LogPagSeguro::info( |
|
265 | + "PagSeguroAuthorizationSearchService.searchAuthorizations() - end " . |
|
266 | + $authorization->toString() |
|
267 | + ); |
|
268 | + break; |
|
269 | + case 'BAD_REQUEST': |
|
270 | + $errors = PagSeguroAuthorizationParser::readErrors($connection->getResponse()); |
|
271 | + $err = new PagSeguroServiceException($httpStatus, $errors); |
|
272 | + LogPagSeguro::error( |
|
273 | + "PagSeguroAuthorizationSearchService.searchAuthorizations() - error " . |
|
274 | + $err->getOneLineMessage() |
|
275 | + ); |
|
276 | + throw $err; |
|
277 | + break; |
|
278 | + default: |
|
279 | + $err = new PagSeguroServiceException($httpStatus); |
|
280 | + LogPagSeguro::error( |
|
281 | + "PagSeguroAuthorizationSearchService.searchAuthorizations() - error " . |
|
282 | + $err->getOneLineMessage() |
|
283 | + ); |
|
284 | + throw $err; |
|
285 | + break; |
|
286 | + } |
|
287 | + return isset($authorization) ? $authorization : false; |
|
288 | + } |
|
289 | 289 | } |
290 | 290 | \ No newline at end of file |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | private static function buildSearchUrlByCode(PagSeguroConnectionData $connectionData, $authorizationCode) |
44 | 44 | { |
45 | 45 | $url = $connectionData->getServiceUrl(); |
46 | - return "{$url}/{$authorizationCode}/?" . $connectionData->getCredentialsUrlQuery(); |
|
46 | + return "{$url}/{$authorizationCode}/?".$connectionData->getCredentialsUrlQuery(); |
|
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * @param PagSeguroConnectionData $connectionData |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | private static function buildSearchUrlByNotification(PagSeguroConnectionData $connectionData, $notificationCode) |
54 | 54 | { |
55 | 55 | $url = $connectionData->getServiceUrl(); |
56 | - return "{$url}/notifications/{$notificationCode}/?" . $connectionData->getCredentialsUrlQuery(); |
|
56 | + return "{$url}/notifications/{$notificationCode}/?".$connectionData->getCredentialsUrlQuery(); |
|
57 | 57 | } |
58 | 58 | /** |
59 | 59 | * @param PagSeguroConnectionData $connectionData |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | */ |
63 | 63 | private static function buildSearchUrl(PagSeguroConnectionData $connectionData, $options = null) |
64 | 64 | { |
65 | - if (!is_null($options)) { |
|
65 | + if ( ! is_null($options)) { |
|
66 | 66 | $options = http_build_query($options, '', '&'); |
67 | - return $connectionData->getServiceUrl() . "/?" . $connectionData->getCredentialsUrlQuery() . "&" . $options; |
|
67 | + return $connectionData->getServiceUrl()."/?".$connectionData->getCredentialsUrlQuery()."&".$options; |
|
68 | 68 | } |
69 | - return $connectionData->getServiceUrl() . "/?" . $connectionData->getCredentialsUrlQuery(); |
|
69 | + return $connectionData->getServiceUrl()."/?".$connectionData->getCredentialsUrlQuery(); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | private static function buildSearchUrlByReference(PagSeguroConnectionData $connectionData, $reference) |
78 | 78 | { |
79 | 79 | $url = $connectionData->getServiceUrl(); |
80 | - return "{$url}?" . $connectionData->getCredentialsUrlQuery() . '&reference='.$reference; |
|
80 | + return "{$url}?".$connectionData->getCredentialsUrlQuery().'&reference='.$reference; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /*** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | throw $err; |
110 | 110 | } |
111 | 111 | catch (Exception $err) { |
112 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
112 | + LogPagSeguro::error("Exception: ".$err->getMessage()); |
|
113 | 113 | throw $err; |
114 | 114 | } |
115 | 115 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } catch (PagSeguroServiceException $err) { |
143 | 143 | throw $err; |
144 | 144 | } catch (Exception $err) { |
145 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
145 | + LogPagSeguro::error("Exception: ".$err->getMessage()); |
|
146 | 146 | throw $err; |
147 | 147 | } |
148 | 148 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } catch (PagSeguroServiceException $err) { |
172 | 172 | throw $err; |
173 | 173 | } catch (Exception $err) { |
174 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
174 | + LogPagSeguro::error("Exception: ".$err->getMessage()); |
|
175 | 175 | throw $err; |
176 | 176 | } |
177 | 177 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | throw $err; |
207 | 207 | } |
208 | 208 | catch (Exception $err) { |
209 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
209 | + LogPagSeguro::error("Exception: ".$err->getMessage()); |
|
210 | 210 | throw $err; |
211 | 211 | } |
212 | 212 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | case 'OK': |
225 | 225 | $authorization = PagSeguroAuthorizationParser::readAuthorization($connection->getResponse()); |
226 | 226 | LogPagSeguro::info( |
227 | - sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - end ", self::$logService) . |
|
227 | + sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - end ", self::$logService). |
|
228 | 228 | $authorization->toString() |
229 | 229 | ); |
230 | 230 | break; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $errors = PagSeguroAuthorizationParser::readErrors($connection->getResponse()); |
233 | 233 | $err = new PagSeguroServiceException($httpStatus, $errors); |
234 | 234 | LogPagSeguro::error( |
235 | - sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService) . |
|
235 | + sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService). |
|
236 | 236 | $err->getOneLineMessage() |
237 | 237 | ); |
238 | 238 | throw $err; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | default: |
241 | 241 | $err = new PagSeguroServiceException($httpStatus); |
242 | 242 | LogPagSeguro::error( |
243 | - sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService) . |
|
243 | + sprintf("PagSeguroAuthorizationSearchService.%s(code=$code) - error ", self::$logService). |
|
244 | 244 | $err->getOneLineMessage() |
245 | 245 | ); |
246 | 246 | throw $err; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $authorization = PagSeguroAuthorizationParser::readSearchResult($connection->getResponse()); |
263 | 263 | |
264 | 264 | LogPagSeguro::info( |
265 | - "PagSeguroAuthorizationSearchService.searchAuthorizations() - end " . |
|
265 | + "PagSeguroAuthorizationSearchService.searchAuthorizations() - end ". |
|
266 | 266 | $authorization->toString() |
267 | 267 | ); |
268 | 268 | break; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $errors = PagSeguroAuthorizationParser::readErrors($connection->getResponse()); |
271 | 271 | $err = new PagSeguroServiceException($httpStatus, $errors); |
272 | 272 | LogPagSeguro::error( |
273 | - "PagSeguroAuthorizationSearchService.searchAuthorizations() - error " . |
|
273 | + "PagSeguroAuthorizationSearchService.searchAuthorizations() - error ". |
|
274 | 274 | $err->getOneLineMessage() |
275 | 275 | ); |
276 | 276 | throw $err; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | default: |
279 | 279 | $err = new PagSeguroServiceException($httpStatus); |
280 | 280 | LogPagSeguro::error( |
281 | - "PagSeguroAuthorizationSearchService.searchAuthorizations() - error " . |
|
281 | + "PagSeguroAuthorizationSearchService.searchAuthorizations() - error ". |
|
282 | 282 | $err->getOneLineMessage() |
283 | 283 | ); |
284 | 284 | throw $err; |
@@ -107,8 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | } catch (PagSeguroServiceException $err) { |
109 | 109 | throw $err; |
110 | - } |
|
111 | - catch (Exception $err) { |
|
110 | + } catch (Exception $err) { |
|
112 | 111 | LogPagSeguro::error("Exception: " . $err->getMessage()); |
113 | 112 | throw $err; |
114 | 113 | } |
@@ -204,8 +203,7 @@ discard block |
||
204 | 203 | |
205 | 204 | } catch (PagSeguroServiceException $err) { |
206 | 205 | throw $err; |
207 | - } |
|
208 | - catch (Exception $err) { |
|
206 | + } catch (Exception $err) { |
|
209 | 207 | LogPagSeguro::error("Exception: " . $err->getMessage()); |
210 | 208 | throw $err; |
211 | 209 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @param PagSeguroHttpConnection $connection |
95 | 95 | * @param PagSeguroAuthorizationRequest $authorizationRequest |
96 | 96 | * @param PagSeguroConnectionData $connectionData |
97 | - * @param null $onlyAuthorizationCode |
|
97 | + * @param boolean $onlyAuthorizationCode |
|
98 | 98 | * @return bool|mixed|string |
99 | 99 | * @throws PagSeguroServiceException |
100 | 100 | */ |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | - * |
|
5 | - * NOTICE OF LICENSE |
|
6 | - * |
|
7 | - *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | - *you may not use this file except in compliance with the License. |
|
9 | - *You may obtain a copy of the License at |
|
10 | - * |
|
11 | - *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | - * |
|
13 | - *Unless required by applicable law or agreed to in writing, software |
|
14 | - *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | - *See the License for the specific language governing permissions and |
|
17 | - *limitations under the License. |
|
18 | - * |
|
19 | - * @author PagSeguro Internet Ltda. |
|
20 | - * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | - */ |
|
3 | + * 2007-2014 [PagSeguro Internet Ltda.] |
|
4 | + * |
|
5 | + * NOTICE OF LICENSE |
|
6 | + * |
|
7 | + *Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | + *you may not use this file except in compliance with the License. |
|
9 | + *You may obtain a copy of the License at |
|
10 | + * |
|
11 | + *http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | + * |
|
13 | + *Unless required by applicable law or agreed to in writing, software |
|
14 | + *distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | + *See the License for the specific language governing permissions and |
|
17 | + *limitations under the License. |
|
18 | + * |
|
19 | + * @author PagSeguro Internet Ltda. |
|
20 | + * @copyright 2007-2014 PagSeguro Internet Ltda. |
|
21 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
|
22 | + */ |
|
23 | 23 | |
24 | 24 | /*** |
25 | 25 | * Encapsulates web service calls regarding PagSeguro authorization request |
@@ -27,123 +27,123 @@ discard block |
||
27 | 27 | class PagSeguroAuthorizationService |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * |
32 | 32 | */ |
33 | - const SERVICE_NAME = 'authorizationService'; |
|
33 | + const SERVICE_NAME = 'authorizationService'; |
|
34 | 34 | |
35 | - /*** |
|
35 | + /*** |
|
36 | 36 | * @param PagSeguroConnectionData $connectionData |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - private static function buildAuthorizationUrl(PagSeguroConnectionData $connectionData) |
|
40 | - { |
|
41 | - return $connectionData->getServiceUrl() . $connectionData->getResource('requestUrl') . '?'; |
|
42 | - } |
|
39 | + private static function buildAuthorizationUrl(PagSeguroConnectionData $connectionData) |
|
40 | + { |
|
41 | + return $connectionData->getServiceUrl() . $connectionData->getResource('requestUrl') . '?'; |
|
42 | + } |
|
43 | 43 | |
44 | - /*** |
|
44 | + /*** |
|
45 | 45 | * @param PagSeguroConnectionData $connectionData |
46 | 46 | * @param string $code |
47 | 47 | * @return string |
48 | 48 | */ |
49 | - private static function buildAuthorizationApprovalUrl(PagSeguroConnectionData $connectionData, $code) |
|
50 | - { |
|
51 | - return $connectionData->getBaseUrl() . $connectionData->getResource('approvalUrl') . '?code=' . $code; |
|
52 | - } |
|
49 | + private static function buildAuthorizationApprovalUrl(PagSeguroConnectionData $connectionData, $code) |
|
50 | + { |
|
51 | + return $connectionData->getBaseUrl() . $connectionData->getResource('approvalUrl') . '?code=' . $code; |
|
52 | + } |
|
53 | 53 | |
54 | - /*** |
|
54 | + /*** |
|
55 | 55 | * @param PagSeguroCredentials $credentials |
56 | 56 | * @param PagSeguroAuthorizationRequest $authorizationRequest |
57 | 57 | * @param bool $onlyAuthorizationCode |
58 | 58 | * @return bool|string |
59 | 59 | * @throws Exception |
60 | 60 | */ |
61 | - public static function createAuthorizationRequest( |
|
62 | - PagSeguroCredentials $credentials, |
|
63 | - PagSeguroAuthorizationRequest $authorizationRequest, |
|
64 | - $onlyAuthorizationCode |
|
65 | - ){ |
|
66 | - |
|
67 | - LogPagSeguro::info("PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - begin"); |
|
68 | - |
|
69 | - $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
70 | - |
|
71 | - try { |
|
72 | - |
|
73 | - $connection = new PagSeguroHttpConnection(); |
|
74 | - $connection->post( |
|
75 | - self::buildAuthorizationUrl($connectionData), |
|
76 | - PagSeguroAuthorizationParser::getData($authorizationRequest, $credentials), |
|
77 | - $connectionData->getServiceTimeout(), |
|
78 | - $connectionData->getCharset() |
|
79 | - ); |
|
80 | - |
|
81 | - return self::authorizationReturn( |
|
82 | - $connection, $authorizationRequest, $connectionData, $onlyAuthorizationCode); |
|
83 | - |
|
84 | - } catch (PagSeguroServiceException $err) { |
|
85 | - throw $err; |
|
86 | - } |
|
87 | - catch (Exception $err) { |
|
88 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
89 | - throw $err; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param PagSeguroHttpConnection $connection |
|
95 | - * @param PagSeguroAuthorizationRequest $authorizationRequest |
|
96 | - * @param PagSeguroConnectionData $connectionData |
|
97 | - * @param null $onlyAuthorizationCode |
|
98 | - * @return bool|mixed|string |
|
99 | - * @throws PagSeguroServiceException |
|
100 | - */ |
|
101 | - private static function authorizationReturn( |
|
102 | - PagSeguroHttpConnection $connection, |
|
103 | - PagSeguroAuthorizationRequest $authorizationRequest, |
|
104 | - PagSeguroConnectionData $connectionData, |
|
105 | - $onlyAuthorizationCode = null |
|
106 | - ) |
|
107 | - { |
|
108 | - $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
109 | - |
|
110 | - switch ($httpStatus->getType()) { |
|
111 | - |
|
112 | - case 'OK': |
|
113 | - $authorization = PagSeguroAuthorizationParser::readSuccessXml($connection->getResponse()); |
|
114 | - |
|
115 | - if ($onlyAuthorizationCode) { |
|
116 | - $authorizationReturn = $authorization->getCode(); |
|
117 | - } else { |
|
118 | - $authorizationReturn = self::buildAuthorizationApprovalUrl($connectionData, |
|
119 | - $authorization->getCode()); |
|
120 | - } |
|
121 | - LogPagSeguro::info( |
|
122 | - "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - end {1}" . |
|
123 | - $authorization->getCode() |
|
124 | - ); |
|
125 | - break; |
|
126 | - |
|
127 | - case 'BAD_REQUEST': |
|
128 | - $errors = PagSeguroPaymentParser::readErrors($connection->getResponse()); |
|
129 | - $err = new PagSeguroServiceException($httpStatus, $errors); |
|
130 | - LogPagSeguro::error( |
|
131 | - "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - error " . |
|
132 | - $err->getOneLineMessage() |
|
133 | - ); |
|
134 | - throw $err; |
|
135 | - break; |
|
136 | - |
|
137 | - default: |
|
138 | - $err = new PagSeguroServiceException($httpStatus); |
|
139 | - LogPagSeguro::error( |
|
140 | - "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - error " . |
|
141 | - $err->getOneLineMessage() |
|
142 | - ); |
|
143 | - throw $err; |
|
144 | - break; |
|
145 | - |
|
146 | - } |
|
147 | - return (isset($authorizationReturn) ? $authorizationReturn : false); |
|
148 | - } |
|
61 | + public static function createAuthorizationRequest( |
|
62 | + PagSeguroCredentials $credentials, |
|
63 | + PagSeguroAuthorizationRequest $authorizationRequest, |
|
64 | + $onlyAuthorizationCode |
|
65 | + ){ |
|
66 | + |
|
67 | + LogPagSeguro::info("PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - begin"); |
|
68 | + |
|
69 | + $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
70 | + |
|
71 | + try { |
|
72 | + |
|
73 | + $connection = new PagSeguroHttpConnection(); |
|
74 | + $connection->post( |
|
75 | + self::buildAuthorizationUrl($connectionData), |
|
76 | + PagSeguroAuthorizationParser::getData($authorizationRequest, $credentials), |
|
77 | + $connectionData->getServiceTimeout(), |
|
78 | + $connectionData->getCharset() |
|
79 | + ); |
|
80 | + |
|
81 | + return self::authorizationReturn( |
|
82 | + $connection, $authorizationRequest, $connectionData, $onlyAuthorizationCode); |
|
83 | + |
|
84 | + } catch (PagSeguroServiceException $err) { |
|
85 | + throw $err; |
|
86 | + } |
|
87 | + catch (Exception $err) { |
|
88 | + LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
89 | + throw $err; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param PagSeguroHttpConnection $connection |
|
95 | + * @param PagSeguroAuthorizationRequest $authorizationRequest |
|
96 | + * @param PagSeguroConnectionData $connectionData |
|
97 | + * @param null $onlyAuthorizationCode |
|
98 | + * @return bool|mixed|string |
|
99 | + * @throws PagSeguroServiceException |
|
100 | + */ |
|
101 | + private static function authorizationReturn( |
|
102 | + PagSeguroHttpConnection $connection, |
|
103 | + PagSeguroAuthorizationRequest $authorizationRequest, |
|
104 | + PagSeguroConnectionData $connectionData, |
|
105 | + $onlyAuthorizationCode = null |
|
106 | + ) |
|
107 | + { |
|
108 | + $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
109 | + |
|
110 | + switch ($httpStatus->getType()) { |
|
111 | + |
|
112 | + case 'OK': |
|
113 | + $authorization = PagSeguroAuthorizationParser::readSuccessXml($connection->getResponse()); |
|
114 | + |
|
115 | + if ($onlyAuthorizationCode) { |
|
116 | + $authorizationReturn = $authorization->getCode(); |
|
117 | + } else { |
|
118 | + $authorizationReturn = self::buildAuthorizationApprovalUrl($connectionData, |
|
119 | + $authorization->getCode()); |
|
120 | + } |
|
121 | + LogPagSeguro::info( |
|
122 | + "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - end {1}" . |
|
123 | + $authorization->getCode() |
|
124 | + ); |
|
125 | + break; |
|
126 | + |
|
127 | + case 'BAD_REQUEST': |
|
128 | + $errors = PagSeguroPaymentParser::readErrors($connection->getResponse()); |
|
129 | + $err = new PagSeguroServiceException($httpStatus, $errors); |
|
130 | + LogPagSeguro::error( |
|
131 | + "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - error " . |
|
132 | + $err->getOneLineMessage() |
|
133 | + ); |
|
134 | + throw $err; |
|
135 | + break; |
|
136 | + |
|
137 | + default: |
|
138 | + $err = new PagSeguroServiceException($httpStatus); |
|
139 | + LogPagSeguro::error( |
|
140 | + "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - error " . |
|
141 | + $err->getOneLineMessage() |
|
142 | + ); |
|
143 | + throw $err; |
|
144 | + break; |
|
145 | + |
|
146 | + } |
|
147 | + return (isset($authorizationReturn) ? $authorizationReturn : false); |
|
148 | + } |
|
149 | 149 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | private static function buildAuthorizationUrl(PagSeguroConnectionData $connectionData) |
40 | 40 | { |
41 | - return $connectionData->getServiceUrl() . $connectionData->getResource('requestUrl') . '?'; |
|
41 | + return $connectionData->getServiceUrl().$connectionData->getResource('requestUrl').'?'; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /*** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private static function buildAuthorizationApprovalUrl(PagSeguroConnectionData $connectionData, $code) |
50 | 50 | { |
51 | - return $connectionData->getBaseUrl() . $connectionData->getResource('approvalUrl') . '?code=' . $code; |
|
51 | + return $connectionData->getBaseUrl().$connectionData->getResource('approvalUrl').'?code='.$code; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /*** |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | PagSeguroCredentials $credentials, |
63 | 63 | PagSeguroAuthorizationRequest $authorizationRequest, |
64 | 64 | $onlyAuthorizationCode |
65 | - ){ |
|
65 | + ) { |
|
66 | 66 | |
67 | - LogPagSeguro::info("PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - begin"); |
|
67 | + LogPagSeguro::info("PagSeguroAuthorizationService.Register(".$authorizationRequest->toString().") - begin"); |
|
68 | 68 | |
69 | 69 | $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
70 | 70 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | throw $err; |
86 | 86 | } |
87 | 87 | catch (Exception $err) { |
88 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
88 | + LogPagSeguro::error("Exception: ".$err->getMessage()); |
|
89 | 89 | throw $err; |
90 | 90 | } |
91 | 91 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $authorization->getCode()); |
120 | 120 | } |
121 | 121 | LogPagSeguro::info( |
122 | - "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - end {1}" . |
|
122 | + "PagSeguroAuthorizationService.Register(".$authorizationRequest->toString().") - end {1}". |
|
123 | 123 | $authorization->getCode() |
124 | 124 | ); |
125 | 125 | break; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $errors = PagSeguroPaymentParser::readErrors($connection->getResponse()); |
129 | 129 | $err = new PagSeguroServiceException($httpStatus, $errors); |
130 | 130 | LogPagSeguro::error( |
131 | - "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - error " . |
|
131 | + "PagSeguroAuthorizationService.Register(".$authorizationRequest->toString().") - error ". |
|
132 | 132 | $err->getOneLineMessage() |
133 | 133 | ); |
134 | 134 | throw $err; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | default: |
138 | 138 | $err = new PagSeguroServiceException($httpStatus); |
139 | 139 | LogPagSeguro::error( |
140 | - "PagSeguroAuthorizationService.Register(" . $authorizationRequest->toString() . ") - error " . |
|
140 | + "PagSeguroAuthorizationService.Register(".$authorizationRequest->toString().") - error ". |
|
141 | 141 | $err->getOneLineMessage() |
142 | 142 | ); |
143 | 143 | throw $err; |
@@ -83,8 +83,7 @@ |
||
83 | 83 | |
84 | 84 | } catch (PagSeguroServiceException $err) { |
85 | 85 | throw $err; |
86 | - } |
|
87 | - catch (Exception $err) { |
|
86 | + } catch (Exception $err) { |
|
88 | 87 | LogPagSeguro::error("Exception: " . $err->getMessage()); |
89 | 88 | throw $err; |
90 | 89 | } |