@@ -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])) { |
@@ -29,91 +29,91 @@ |
||
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() |
@@ -27,327 +27,327 @@ |
||
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 |
@@ -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 |
@@ -27,201 +27,201 @@ |
||
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 | } |
@@ -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 |
@@ -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 | } |
@@ -27,329 +27,329 @@ |
||
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 | } |
@@ -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 | */ |
@@ -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 | } |
@@ -27,123 +27,123 @@ |
||
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 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | const SERVICE_NAME = 'cancelService'; |
34 | 34 | |
35 | 35 | /** |
36 | - * @param $connectionData |
|
36 | + * @param PagSeguroConnectionData $connectionData |
|
37 | 37 | * @param $transactionCode |
38 | 38 | * @return string |
39 | 39 | */ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param PagSeguroCredentials $credentials |
48 | - * @param $transactionCode |
|
48 | + * @param string $transactionCode |
|
49 | 49 | * @throws Exception |
50 | 50 | * @throws PagSeguroServiceException |
51 | 51 | */ |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | */ |
40 | 40 | private static function buildCancelURL($connectionData, $transactionCode) |
41 | 41 | { |
42 | - return $connectionData->getServiceUrl() . '?' . $connectionData->getCredentialsUrlQuery() |
|
43 | - . "&transactionCode=" . $transactionCode; |
|
42 | + return $connectionData->getServiceUrl().'?'.$connectionData->getCredentialsUrlQuery() |
|
43 | + . "&transactionCode=".$transactionCode; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public static function createRequest( |
53 | 53 | PagSeguroCredentials $credentials, |
54 | 54 | $transactionCode |
55 | - ){ |
|
55 | + ) { |
|
56 | 56 | |
57 | 57 | LogPagSeguro::info("PagSeguroCancelService.Register(".$transactionCode.") - begin"); |
58 | 58 | $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $errors = PagSeguroCancelParser::readErrors($connection->getResponse()); |
82 | 82 | $err = new PagSeguroServiceException($httpStatus, $errors); |
83 | 83 | LogPagSeguro::error( |
84 | - "PagSeguroCancelService.createRequest() - error " . |
|
84 | + "PagSeguroCancelService.createRequest() - error ". |
|
85 | 85 | $err->getOneLineMessage() |
86 | 86 | ); |
87 | 87 | throw $err; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | default: |
90 | 90 | $err = new PagSeguroServiceException($httpStatus); |
91 | 91 | LogPagSeguro::error( |
92 | - "PagSeguroCancelService.createRequest() - error " . |
|
92 | + "PagSeguroCancelService.createRequest() - error ". |
|
93 | 93 | $err->getOneLineMessage() |
94 | 94 | ); |
95 | 95 | throw $err; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } catch (PagSeguroServiceException $err) { |
101 | 101 | throw $err; |
102 | 102 | } catch (Exception $err) { |
103 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
103 | + LogPagSeguro::error("Exception: ".$err->getMessage()); |
|
104 | 104 | throw $err; |
105 | 105 | } |
106 | 106 | } |
@@ -27,81 +27,81 @@ |
||
27 | 27 | class PagSeguroCancelService |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * |
|
32 | - */ |
|
33 | - const SERVICE_NAME = 'cancelService'; |
|
30 | + /** |
|
31 | + * |
|
32 | + */ |
|
33 | + const SERVICE_NAME = 'cancelService'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param $connectionData |
|
37 | - * @param $transactionCode |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - private static function buildCancelURL($connectionData, $transactionCode) |
|
41 | - { |
|
42 | - return $connectionData->getServiceUrl() . '?' . $connectionData->getCredentialsUrlQuery() |
|
43 | - . "&transactionCode=" . $transactionCode; |
|
44 | - } |
|
35 | + /** |
|
36 | + * @param $connectionData |
|
37 | + * @param $transactionCode |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + private static function buildCancelURL($connectionData, $transactionCode) |
|
41 | + { |
|
42 | + return $connectionData->getServiceUrl() . '?' . $connectionData->getCredentialsUrlQuery() |
|
43 | + . "&transactionCode=" . $transactionCode; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param PagSeguroCredentials $credentials |
|
48 | - * @param $transactionCode |
|
49 | - * @throws Exception |
|
50 | - * @throws PagSeguroServiceException |
|
51 | - */ |
|
52 | - public static function createRequest( |
|
53 | - PagSeguroCredentials $credentials, |
|
54 | - $transactionCode |
|
55 | - ){ |
|
46 | + /** |
|
47 | + * @param PagSeguroCredentials $credentials |
|
48 | + * @param $transactionCode |
|
49 | + * @throws Exception |
|
50 | + * @throws PagSeguroServiceException |
|
51 | + */ |
|
52 | + public static function createRequest( |
|
53 | + PagSeguroCredentials $credentials, |
|
54 | + $transactionCode |
|
55 | + ){ |
|
56 | 56 | |
57 | - LogPagSeguro::info("PagSeguroCancelService.Register(".$transactionCode.") - begin"); |
|
58 | - $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
57 | + LogPagSeguro::info("PagSeguroCancelService.Register(".$transactionCode.") - begin"); |
|
58 | + $connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME); |
|
59 | 59 | |
60 | - try { |
|
60 | + try { |
|
61 | 61 | |
62 | - $connection = new PagSeguroHttpConnection(); |
|
63 | - $connection->post( |
|
64 | - self::buildCancelURL($connectionData, $transactionCode), |
|
65 | - array(), |
|
66 | - $connectionData->getServiceTimeout(), |
|
67 | - $connectionData->getCharset() |
|
68 | - ); |
|
62 | + $connection = new PagSeguroHttpConnection(); |
|
63 | + $connection->post( |
|
64 | + self::buildCancelURL($connectionData, $transactionCode), |
|
65 | + array(), |
|
66 | + $connectionData->getServiceTimeout(), |
|
67 | + $connectionData->getCharset() |
|
68 | + ); |
|
69 | 69 | |
70 | - $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
70 | + $httpStatus = new PagSeguroHttpStatus($connection->getStatus()); |
|
71 | 71 | |
72 | - switch ($httpStatus->getType()) { |
|
73 | - case 'OK': |
|
72 | + switch ($httpStatus->getType()) { |
|
73 | + case 'OK': |
|
74 | 74 | |
75 | - $result = PagSeguroCancelParser::readSuccessXml($connection->getResponse()); |
|
76 | - LogPagSeguro::info( |
|
77 | - "PagSeguroCancelService.createRequest(".$result.") - end " |
|
78 | - ); |
|
79 | - break; |
|
80 | - case 'BAD_REQUEST': |
|
81 | - $errors = PagSeguroCancelParser::readErrors($connection->getResponse()); |
|
82 | - $err = new PagSeguroServiceException($httpStatus, $errors); |
|
83 | - LogPagSeguro::error( |
|
84 | - "PagSeguroCancelService.createRequest() - error " . |
|
85 | - $err->getOneLineMessage() |
|
86 | - ); |
|
87 | - throw $err; |
|
88 | - break; |
|
89 | - default: |
|
90 | - $err = new PagSeguroServiceException($httpStatus); |
|
91 | - LogPagSeguro::error( |
|
92 | - "PagSeguroCancelService.createRequest() - error " . |
|
93 | - $err->getOneLineMessage() |
|
94 | - ); |
|
95 | - throw $err; |
|
96 | - break; |
|
97 | - } |
|
98 | - return isset($result) ? $result : false; |
|
75 | + $result = PagSeguroCancelParser::readSuccessXml($connection->getResponse()); |
|
76 | + LogPagSeguro::info( |
|
77 | + "PagSeguroCancelService.createRequest(".$result.") - end " |
|
78 | + ); |
|
79 | + break; |
|
80 | + case 'BAD_REQUEST': |
|
81 | + $errors = PagSeguroCancelParser::readErrors($connection->getResponse()); |
|
82 | + $err = new PagSeguroServiceException($httpStatus, $errors); |
|
83 | + LogPagSeguro::error( |
|
84 | + "PagSeguroCancelService.createRequest() - error " . |
|
85 | + $err->getOneLineMessage() |
|
86 | + ); |
|
87 | + throw $err; |
|
88 | + break; |
|
89 | + default: |
|
90 | + $err = new PagSeguroServiceException($httpStatus); |
|
91 | + LogPagSeguro::error( |
|
92 | + "PagSeguroCancelService.createRequest() - error " . |
|
93 | + $err->getOneLineMessage() |
|
94 | + ); |
|
95 | + throw $err; |
|
96 | + break; |
|
97 | + } |
|
98 | + return isset($result) ? $result : false; |
|
99 | 99 | |
100 | - } catch (PagSeguroServiceException $err) { |
|
101 | - throw $err; |
|
102 | - } catch (Exception $err) { |
|
103 | - LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
104 | - throw $err; |
|
105 | - } |
|
106 | - } |
|
100 | + } catch (PagSeguroServiceException $err) { |
|
101 | + throw $err; |
|
102 | + } catch (Exception $err) { |
|
103 | + LogPagSeguro::error("Exception: " . $err->getMessage()); |
|
104 | + throw $err; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | } |
108 | 108 | \ No newline at end of file |
@@ -80,6 +80,10 @@ discard block |
||
80 | 80 | * @param PagSeguroCredentials $credentials |
81 | 81 | * @param $serviceName |
82 | 82 | */ |
83 | + |
|
84 | + /** |
|
85 | + * @param string $serviceName |
|
86 | + */ |
|
83 | 87 | public function __construct(PagSeguroCredentials $credentials, $serviceName) |
84 | 88 | { |
85 | 89 | |
@@ -298,6 +302,10 @@ discard block |
||
298 | 302 | * @param $resource |
299 | 303 | * @return mixed |
300 | 304 | */ |
305 | + |
|
306 | + /** |
|
307 | + * @param string $resource |
|
308 | + */ |
|
301 | 309 | public function getResource($resource) |
302 | 310 | { |
303 | 311 | return $this->resources[$resource]; |
@@ -288,9 +288,9 @@ |
||
288 | 288 | public function getServiceUrl($version = null) |
289 | 289 | { |
290 | 290 | if ($version) { |
291 | - return $this->getWebserviceUrl() . $this->getServicePath($version); |
|
291 | + return $this->getWebserviceUrl().$this->getServicePath($version); |
|
292 | 292 | } else { |
293 | - return $this->getWebserviceUrl() . $this->getServicePath(); |
|
293 | + return $this->getWebserviceUrl().$this->getServicePath(); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 |
@@ -27,297 +27,297 @@ |
||
27 | 27 | class PagSeguroConnectionData |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * @var |
32 | 32 | */ |
33 | - private $serviceName; |
|
34 | - /*** |
|
33 | + private $serviceName; |
|
34 | + /*** |
|
35 | 35 | * @var PagSeguroCredentials |
36 | 36 | */ |
37 | - private $credentials; |
|
38 | - /*** |
|
37 | + private $credentials; |
|
38 | + /*** |
|
39 | 39 | * @var |
40 | 40 | */ |
41 | - private $resources; |
|
42 | - /*** |
|
41 | + private $resources; |
|
42 | + /*** |
|
43 | 43 | * @var |
44 | 44 | */ |
45 | - private $environment; |
|
46 | - /*** |
|
45 | + private $environment; |
|
46 | + /*** |
|
47 | 47 | * @var |
48 | 48 | */ |
49 | - private $webserviceUrl; |
|
50 | - /*** |
|
49 | + private $webserviceUrl; |
|
50 | + /*** |
|
51 | 51 | * @var |
52 | 52 | */ |
53 | - private $paymentUrl; |
|
54 | - /*** |
|
53 | + private $paymentUrl; |
|
54 | + /*** |
|
55 | 55 | * @var |
56 | 56 | */ |
57 | - private $baseUrl; |
|
58 | - /*** |
|
57 | + private $baseUrl; |
|
58 | + /*** |
|
59 | 59 | * @var |
60 | 60 | */ |
61 | - private $installmentUrl; |
|
62 | - /*** |
|
61 | + private $installmentUrl; |
|
62 | + /*** |
|
63 | 63 | * @var |
64 | 64 | */ |
65 | - private $sessionUrl; |
|
66 | - /*** |
|
65 | + private $sessionUrl; |
|
66 | + /*** |
|
67 | 67 | * @var |
68 | 68 | */ |
69 | - private $servicePath; |
|
70 | - /*** |
|
69 | + private $servicePath; |
|
70 | + /*** |
|
71 | 71 | * @var |
72 | 72 | */ |
73 | - private $serviceTimeout; |
|
74 | - /*** |
|
73 | + private $serviceTimeout; |
|
74 | + /*** |
|
75 | 75 | * @var |
76 | 76 | */ |
77 | - private $charset; |
|
77 | + private $charset; |
|
78 | 78 | |
79 | - /*** |
|
79 | + /*** |
|
80 | 80 | * @param PagSeguroCredentials $credentials |
81 | 81 | * @param $serviceName |
82 | 82 | */ |
83 | - public function __construct(PagSeguroCredentials $credentials, $serviceName) |
|
84 | - { |
|
85 | - |
|
86 | - $this->credentials = $credentials; |
|
87 | - $this->serviceName = $serviceName; |
|
88 | - |
|
89 | - try { |
|
90 | - $this->setEnvironment(PagSeguroConfig::getEnvironment()); |
|
91 | - $this->setWebserviceUrl(PagSeguroResources::getWebserviceUrl($this->getEnvironment())); |
|
92 | - $this->setPaymentUrl(PagSeguroResources::getPaymentUrl($this->getEnvironment())); |
|
93 | - $this->setBaseUrl(PagSeguroResources::getBaseUrl($this->getEnvironment())); |
|
94 | - $this->setInstallmentUrl(PagSeguroResources::getInstallmentUrl()); |
|
95 | - $this->setAuthorizationUrl(PagSeguroResources::getAuthorizationUrl()); |
|
96 | - $this->setSessionUrl(PagSeguroResources::getSessionUrl()); |
|
97 | - $this->setCharset(PagSeguroConfig::getApplicationCharset()); |
|
98 | - |
|
99 | - $this->resources = PagSeguroResources::getData($this->serviceName); |
|
100 | - if (isset($this->resources['servicePath'])) { |
|
101 | - $this->setServicePath($this->resources['servicePath']); |
|
102 | - } |
|
103 | - if (isset($this->resources['serviceTimeout'])) { |
|
104 | - $this->setServiceTimeout($this->resources['serviceTimeout']); |
|
105 | - } |
|
106 | - } catch (Exception $e) { |
|
107 | - throw $e; |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - /*** |
|
83 | + public function __construct(PagSeguroCredentials $credentials, $serviceName) |
|
84 | + { |
|
85 | + |
|
86 | + $this->credentials = $credentials; |
|
87 | + $this->serviceName = $serviceName; |
|
88 | + |
|
89 | + try { |
|
90 | + $this->setEnvironment(PagSeguroConfig::getEnvironment()); |
|
91 | + $this->setWebserviceUrl(PagSeguroResources::getWebserviceUrl($this->getEnvironment())); |
|
92 | + $this->setPaymentUrl(PagSeguroResources::getPaymentUrl($this->getEnvironment())); |
|
93 | + $this->setBaseUrl(PagSeguroResources::getBaseUrl($this->getEnvironment())); |
|
94 | + $this->setInstallmentUrl(PagSeguroResources::getInstallmentUrl()); |
|
95 | + $this->setAuthorizationUrl(PagSeguroResources::getAuthorizationUrl()); |
|
96 | + $this->setSessionUrl(PagSeguroResources::getSessionUrl()); |
|
97 | + $this->setCharset(PagSeguroConfig::getApplicationCharset()); |
|
98 | + |
|
99 | + $this->resources = PagSeguroResources::getData($this->serviceName); |
|
100 | + if (isset($this->resources['servicePath'])) { |
|
101 | + $this->setServicePath($this->resources['servicePath']); |
|
102 | + } |
|
103 | + if (isset($this->resources['serviceTimeout'])) { |
|
104 | + $this->setServiceTimeout($this->resources['serviceTimeout']); |
|
105 | + } |
|
106 | + } catch (Exception $e) { |
|
107 | + throw $e; |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + /*** |
|
112 | 112 | * @return PagSeguroCredentials |
113 | 113 | */ |
114 | - public function getCredentials() |
|
115 | - { |
|
116 | - return $this->credentials; |
|
117 | - } |
|
114 | + public function getCredentials() |
|
115 | + { |
|
116 | + return $this->credentials; |
|
117 | + } |
|
118 | 118 | |
119 | - /*** |
|
119 | + /*** |
|
120 | 120 | * @param PagSeguroCredentials $credentials |
121 | 121 | */ |
122 | - public function setCredentials(PagSeguroCredentials $credentials) |
|
123 | - { |
|
124 | - $this->credentials = $credentials; |
|
125 | - } |
|
122 | + public function setCredentials(PagSeguroCredentials $credentials) |
|
123 | + { |
|
124 | + $this->credentials = $credentials; |
|
125 | + } |
|
126 | 126 | |
127 | - /*** |
|
127 | + /*** |
|
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public function getCredentialsUrlQuery() |
|
131 | - { |
|
132 | - return http_build_query($this->credentials->getAttributesMap(), '', '&'); |
|
133 | - } |
|
130 | + public function getCredentialsUrlQuery() |
|
131 | + { |
|
132 | + return http_build_query($this->credentials->getAttributesMap(), '', '&'); |
|
133 | + } |
|
134 | 134 | |
135 | - /*** |
|
135 | + /*** |
|
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | - public function getEnvironment() |
|
139 | - { |
|
140 | - return $this->environment; |
|
141 | - } |
|
138 | + public function getEnvironment() |
|
139 | + { |
|
140 | + return $this->environment; |
|
141 | + } |
|
142 | 142 | |
143 | - /*** |
|
143 | + /*** |
|
144 | 144 | * @param $environment |
145 | 145 | */ |
146 | - public function setEnvironment($environment) |
|
147 | - { |
|
148 | - $this->environment = $environment; |
|
149 | - } |
|
146 | + public function setEnvironment($environment) |
|
147 | + { |
|
148 | + $this->environment = $environment; |
|
149 | + } |
|
150 | 150 | |
151 | - /*** |
|
151 | + /*** |
|
152 | 152 | * @return mixed |
153 | 153 | */ |
154 | - public function getWebserviceUrl() |
|
155 | - { |
|
156 | - return $this->webserviceUrl; |
|
157 | - } |
|
154 | + public function getWebserviceUrl() |
|
155 | + { |
|
156 | + return $this->webserviceUrl; |
|
157 | + } |
|
158 | 158 | |
159 | - /*** |
|
159 | + /*** |
|
160 | 160 | * @param $webserviceUrl |
161 | 161 | */ |
162 | - public function setWebserviceUrl($webserviceUrl) |
|
163 | - { |
|
164 | - $this->webserviceUrl = $webserviceUrl; |
|
165 | - } |
|
162 | + public function setWebserviceUrl($webserviceUrl) |
|
163 | + { |
|
164 | + $this->webserviceUrl = $webserviceUrl; |
|
165 | + } |
|
166 | 166 | |
167 | - /*** |
|
167 | + /*** |
|
168 | 168 | * @return mixed |
169 | 169 | */ |
170 | - public function getPaymentUrl() |
|
171 | - { |
|
172 | - return $this->paymentUrl; |
|
173 | - } |
|
170 | + public function getPaymentUrl() |
|
171 | + { |
|
172 | + return $this->paymentUrl; |
|
173 | + } |
|
174 | 174 | |
175 | - /*** |
|
175 | + /*** |
|
176 | 176 | * @param $paymentUrl |
177 | 177 | */ |
178 | - public function setPaymentUrl($paymentUrl) |
|
179 | - { |
|
180 | - $this->paymentUrl = $paymentUrl; |
|
181 | - } |
|
178 | + public function setPaymentUrl($paymentUrl) |
|
179 | + { |
|
180 | + $this->paymentUrl = $paymentUrl; |
|
181 | + } |
|
182 | 182 | |
183 | - /*** |
|
183 | + /*** |
|
184 | 184 | * @return mixed |
185 | 185 | */ |
186 | - public function getBaseUrl() |
|
187 | - { |
|
188 | - return $this->baseUrl; |
|
189 | - } |
|
186 | + public function getBaseUrl() |
|
187 | + { |
|
188 | + return $this->baseUrl; |
|
189 | + } |
|
190 | 190 | |
191 | - /*** |
|
191 | + /*** |
|
192 | 192 | * @param $baseUrl |
193 | 193 | */ |
194 | - public function setBaseUrl($baseUrl) |
|
195 | - { |
|
196 | - $this->baseUrl = $baseUrl; |
|
197 | - } |
|
194 | + public function setBaseUrl($baseUrl) |
|
195 | + { |
|
196 | + $this->baseUrl = $baseUrl; |
|
197 | + } |
|
198 | 198 | |
199 | - /*** |
|
199 | + /*** |
|
200 | 200 | * @return mixed |
201 | 201 | */ |
202 | - public function getInstallmentUrl() |
|
203 | - { |
|
204 | - return $this->installmentUrl; |
|
205 | - } |
|
202 | + public function getInstallmentUrl() |
|
203 | + { |
|
204 | + return $this->installmentUrl; |
|
205 | + } |
|
206 | 206 | |
207 | - /*** |
|
207 | + /*** |
|
208 | 208 | * @param $installmentUrl |
209 | 209 | */ |
210 | - public function setInstallmentUrl($installmentUrl) |
|
211 | - { |
|
212 | - $this->installmentUrl = $installmentUrl; |
|
213 | - } |
|
210 | + public function setInstallmentUrl($installmentUrl) |
|
211 | + { |
|
212 | + $this->installmentUrl = $installmentUrl; |
|
213 | + } |
|
214 | 214 | |
215 | - /*** |
|
215 | + /*** |
|
216 | 216 | * @return mixed |
217 | 217 | */ |
218 | - public function getAuthorizationUrl() |
|
219 | - { |
|
220 | - return $this->authorizationUrl; |
|
221 | - } |
|
218 | + public function getAuthorizationUrl() |
|
219 | + { |
|
220 | + return $this->authorizationUrl; |
|
221 | + } |
|
222 | 222 | |
223 | - /*** |
|
223 | + /*** |
|
224 | 224 | * @param $installmentUrl |
225 | 225 | */ |
226 | - public function setAuthorizationUrl($authorizationUrl) |
|
227 | - { |
|
228 | - $this->authorizationUrl = $authorizationUrl; |
|
229 | - } |
|
226 | + public function setAuthorizationUrl($authorizationUrl) |
|
227 | + { |
|
228 | + $this->authorizationUrl = $authorizationUrl; |
|
229 | + } |
|
230 | 230 | |
231 | - /*** |
|
231 | + /*** |
|
232 | 232 | * @return mixed |
233 | 233 | */ |
234 | - public function getSessionUrl() |
|
235 | - { |
|
236 | - return $this->sessionUrl; |
|
237 | - } |
|
234 | + public function getSessionUrl() |
|
235 | + { |
|
236 | + return $this->sessionUrl; |
|
237 | + } |
|
238 | 238 | |
239 | - /*** |
|
239 | + /*** |
|
240 | 240 | * @param $installmentUrl |
241 | 241 | */ |
242 | - public function setSessionUrl($sessionUrl) |
|
243 | - { |
|
244 | - $this->sessionUrl = $sessionUrl; |
|
245 | - } |
|
242 | + public function setSessionUrl($sessionUrl) |
|
243 | + { |
|
244 | + $this->sessionUrl = $sessionUrl; |
|
245 | + } |
|
246 | 246 | |
247 | - /*** |
|
247 | + /*** |
|
248 | 248 | * @param mixed $version |
249 | 249 | * @return mixed |
250 | 250 | */ |
251 | - public function getServicePath($version = null) |
|
252 | - { |
|
253 | - if ($version) { |
|
254 | - return $this->servicePath[$version]; |
|
255 | - } else { |
|
256 | - return $this->servicePath; |
|
257 | - } |
|
258 | - } |
|
251 | + public function getServicePath($version = null) |
|
252 | + { |
|
253 | + if ($version) { |
|
254 | + return $this->servicePath[$version]; |
|
255 | + } else { |
|
256 | + return $this->servicePath; |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - /*** |
|
260 | + /*** |
|
261 | 261 | * @param $servicePath |
262 | 262 | */ |
263 | - public function setServicePath($servicePath) |
|
264 | - { |
|
265 | - $this->servicePath = $servicePath; |
|
266 | - } |
|
263 | + public function setServicePath($servicePath) |
|
264 | + { |
|
265 | + $this->servicePath = $servicePath; |
|
266 | + } |
|
267 | 267 | |
268 | - /*** |
|
268 | + /*** |
|
269 | 269 | * @return mixed |
270 | 270 | */ |
271 | - public function getServiceTimeout() |
|
272 | - { |
|
273 | - return $this->serviceTimeout; |
|
274 | - } |
|
271 | + public function getServiceTimeout() |
|
272 | + { |
|
273 | + return $this->serviceTimeout; |
|
274 | + } |
|
275 | 275 | |
276 | - /*** |
|
276 | + /*** |
|
277 | 277 | * @param $serviceTimeout |
278 | 278 | */ |
279 | - public function setServiceTimeout($serviceTimeout) |
|
280 | - { |
|
281 | - $this->serviceTimeout = $serviceTimeout; |
|
282 | - } |
|
279 | + public function setServiceTimeout($serviceTimeout) |
|
280 | + { |
|
281 | + $this->serviceTimeout = $serviceTimeout; |
|
282 | + } |
|
283 | 283 | |
284 | - /*** |
|
284 | + /*** |
|
285 | 285 | * @param mixed $version |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function getServiceUrl($version = null) |
|
289 | - { |
|
290 | - if ($version) { |
|
291 | - return $this->getWebserviceUrl() . $this->getServicePath($version); |
|
292 | - } else { |
|
293 | - return $this->getWebserviceUrl() . $this->getServicePath(); |
|
294 | - } |
|
295 | - } |
|
288 | + public function getServiceUrl($version = null) |
|
289 | + { |
|
290 | + if ($version) { |
|
291 | + return $this->getWebserviceUrl() . $this->getServicePath($version); |
|
292 | + } else { |
|
293 | + return $this->getWebserviceUrl() . $this->getServicePath(); |
|
294 | + } |
|
295 | + } |
|
296 | 296 | |
297 | - /*** |
|
297 | + /*** |
|
298 | 298 | * @param $resource |
299 | 299 | * @return mixed |
300 | 300 | */ |
301 | - public function getResource($resource) |
|
302 | - { |
|
303 | - return $this->resources[$resource]; |
|
304 | - } |
|
301 | + public function getResource($resource) |
|
302 | + { |
|
303 | + return $this->resources[$resource]; |
|
304 | + } |
|
305 | 305 | |
306 | - /*** |
|
306 | + /*** |
|
307 | 307 | * @return mixed |
308 | 308 | */ |
309 | - public function getCharset() |
|
310 | - { |
|
311 | - return $this->charset; |
|
312 | - } |
|
309 | + public function getCharset() |
|
310 | + { |
|
311 | + return $this->charset; |
|
312 | + } |
|
313 | 313 | |
314 | - /*** |
|
314 | + /*** |
|
315 | 315 | * @param $charset |
316 | 316 | */ |
317 | - public function setCharset($charset) |
|
318 | - { |
|
319 | - $this->charset = $charset; |
|
320 | - } |
|
317 | + public function setCharset($charset) |
|
318 | + { |
|
319 | + $this->charset = $charset; |
|
320 | + } |
|
321 | 321 | |
322 | 322 | |
323 | 323 | } |