@@ -31,4 +31,4 @@ |
||
31 | 31 | /** |
32 | 32 | * Custom InvalidInputException. |
33 | 33 | */ |
34 | -class InvalidInputException extends \Exception{} |
|
34 | +class InvalidInputException extends \Exception {} |
@@ -31,4 +31,4 @@ |
||
31 | 31 | /** |
32 | 32 | * Custom ValidationException. |
33 | 33 | */ |
34 | -class ValidationException extends \Exception{} |
|
34 | +class ValidationException extends \Exception {} |
@@ -31,4 +31,4 @@ |
||
31 | 31 | /** |
32 | 32 | * Custom BankRejectException. |
33 | 33 | */ |
34 | -class BankRejectException extends \Exception{} |
|
34 | +class BankRejectException extends \Exception {} |
@@ -31,4 +31,4 @@ |
||
31 | 31 | /** |
32 | 32 | * Custom AuthException. |
33 | 33 | */ |
34 | -class AuthException extends \Exception{} |
|
34 | +class AuthException extends \Exception {} |
@@ -31,4 +31,4 @@ |
||
31 | 31 | /** |
32 | 32 | * Custom TimeoutException. |
33 | 33 | */ |
34 | -class TimeoutException extends \Exception{} |
|
34 | +class TimeoutException extends \Exception {} |
@@ -31,4 +31,4 @@ |
||
31 | 31 | /** |
32 | 32 | * Custom InstapagoException. |
33 | 33 | */ |
34 | -class InstapagoException extends \Exception{} |
|
34 | +class InstapagoException extends \Exception {} |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function release(){ |
|
54 | + public function release() { |
|
55 | 55 | $this->validations = [ |
56 | 56 | 'amount' => [FILTER_VALIDATE_FLOAT], |
57 | 57 | 'id' => [FILTER_VALIDATE_REGEXP, '/^([0-9a-f]{8})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{12})$/'], |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | return $this; |
60 | 60 | } |
61 | 61 | |
62 | - public function query(){ |
|
62 | + public function query() { |
|
63 | 63 | $this->validations = [ |
64 | 64 | 'id' => [FILTER_VALIDATE_REGEXP, '/^([0-9a-f]{8})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{12})$/'], |
65 | 65 | ]; |
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
69 | - public function validate($fields){ |
|
69 | + public function validate($fields) { |
|
70 | 70 | foreach ($this->validations as $key => $filters) { |
71 | - if ( !$this->_validation($fields[$key], $filters) ){ |
|
71 | + if ( ! $this->_validation($fields[$key], $filters)) { |
|
72 | 72 | throw new Exceptions\ValidationException("Error {$key}: {$fields[$key]}"); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | - private function _validation ($value, $filters) |
|
78 | + private function _validation($value, $filters) |
|
79 | 79 | { |
80 | 80 | $filter = $filters[0]; |
81 | 81 | $flags = []; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * Requeridas. |
48 | 48 | */ |
49 | 49 | public function __construct($keyId, $publicKeyId) { |
50 | - if ( empty($keyId) || empty($publicKeyId) ) { |
|
50 | + if (empty($keyId) || empty($publicKeyId)) { |
|
51 | 51 | throw new Exceptions\InstapagoException('Los parámetros "keyId" y "publicKeyId" son requeridos para procesar la petición.'); |
52 | 52 | } |
53 | 53 | $this->publicKeyId = $publicKeyId; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return \ArrayObject<string, string> Respuesta de Instapago |
129 | 129 | * @throws Exceptions\InstapagoException |
130 | 130 | */ |
131 | - public function continuePayment($fields){ |
|
131 | + public function continuePayment($fields) { |
|
132 | 132 | (new Validator())->release()->validate($fields); |
133 | 133 | $fields = [ |
134 | 134 | 'KeyID' => $this->keyId, //required |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | $args = [ |
214 | 214 | 'query' => $fields |
215 | 215 | ]; |
216 | - }else if ($method == 'POST' || $method == 'DELETE') { |
|
216 | + } else if ($method == 'POST' || $method == 'DELETE') { |
|
217 | 217 | $args = [ |
218 | 218 | 'form_params' => $fields |
219 | 219 | ]; |
220 | - }else{ |
|
220 | + } else { |
|
221 | 221 | throw new Exception("Not implemented yet", 1); |
222 | 222 | } |
223 | 223 | |
@@ -246,24 +246,24 @@ discard block |
||
246 | 246 | throw new Exceptions\InvalidInputException( |
247 | 247 | 'Error al validar los datos enviados.' |
248 | 248 | ); |
249 | - }else if ($code == 401) { |
|
249 | + } else if ($code == 401) { |
|
250 | 250 | throw new Exceptions\AuthException( |
251 | 251 | 'Error de autenticación, ha ocurrido un error' |
252 | 252 | . ' con las llaves utilizadas.'); |
253 | - }else if ($code == 403) { |
|
253 | + } else if ($code == 403) { |
|
254 | 254 | throw new Exceptions\BankRejectException( |
255 | 255 | 'Pago Rechazado por el banco.' |
256 | 256 | ); |
257 | - }else if ($code == 500) { |
|
257 | + } else if ($code == 500) { |
|
258 | 258 | throw new Exceptions\InstapagoException( |
259 | 259 | 'Ha Ocurrido un error interno dentro del servidor.' |
260 | 260 | ); |
261 | - }else if ($code == 503) { |
|
261 | + } else if ($code == 503) { |
|
262 | 262 | throw new Exceptions\InstapagoException( |
263 | 263 | 'Ha Ocurrido un error al procesar los parámetros de entrada.' |
264 | 264 | . ' Revise los datos enviados y vuelva a intentarlo.' |
265 | 265 | ); |
266 | - }else if ($code == 201) { |
|
266 | + } else if ($code == 201) { |
|
267 | 267 | return [ |
268 | 268 | 'code' => $code, |
269 | 269 | 'msg_banco' => $obj->message, |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | 'id_pago' => $obj->id, |
272 | 272 | 'reference' => $obj->reference, |
273 | 273 | ]; |
274 | - }else { |
|
274 | + } else { |
|
275 | 275 | throw new \Exception('Not implemented yet'); |
276 | 276 | } |
277 | 277 | } |