Completed
Pull Request — master (#15)
by angel
02:04
created
Instapago/InstapagoGateway/Exceptions/InstapagoException.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@
 block discarded – undo
35 35
  */
36 36
 class InstapagoException extends Exception
37 37
 {
38
-    public function __construct($message = null)
39
-    {
40
-        parent::__construct($message);
41
-    }
38
+	public function __construct($message = null)
39
+	{
40
+		parent::__construct($message);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Instapago/autoload.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
  */
29 29
 
30 30
 spl_autoload_register(function ($class) {
31
-    $file = dirname(__DIR__).DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
31
+	$file = dirname(__DIR__).DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
32 32
 
33
-    return (!is_file($file)) ?: require $file;
33
+	return (!is_file($file)) ?: require $file;
34 34
 });
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
  * @copyright 2016 Angel Cruz
28 28
  */
29 29
 
30
-spl_autoload_register(function ($class) {
31
-    $file = dirname(__DIR__).DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
30
+spl_autoload_register(function($class) {
31
+    $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
32 32
 
33
-    return (!is_file($file)) ?: require $file;
33
+    return ( ! is_file($file)) ?: require $file;
34 34
 });
Please login to merge, or discard this patch.
Instapago/InstapagoGateway/InstapagoPayment.php 2 patches
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -35,291 +35,291 @@
 block discarded – undo
35 35
  */
36 36
 class InstapagoPayment
37 37
 {
38
-    protected $keyId;
39
-    protected $publicKeyId;
40
-    public $cardHolder;
41
-    public $cardHolderId;
42
-    public $cardNumber;
43
-    public $cvc;
44
-    public $expirationDate;
45
-    public $amount;
46
-    public $description;
47
-    public $statusId;
48
-    public $ipAddres;
49
-    public $idPago;
50
-    public $root = 'https://api.instapago.com/';
51
-
52
-    /**
53
-     * Crear un nuevo objeto de Instapago.
54
-     *
55
-     * @param string $keyId       llave privada
56
-     * @param string $publicKeyId llave publica
57
-     *                            Requeridas.
58
-     */
59
-    public function __construct($keyId, $publicKeyId)
60
-    {
61
-        try {
62
-            if (empty($keyId) && empty($publicKeyId)) {
63
-                throw new InstapagoException('Los parámetros "keyId" y "publicKeyId" son requeridos para procesar la petición.');
64
-            }
65
-
66
-            if (empty($keyId)) {
67
-                throw new InstapagoException('El parámetro "keyId" es requerido para procesar la petición. ');
68
-            }
69
-
70
-            if (empty($publicKeyId)) {
71
-                throw new InstapagoException('El parámetro "publicKeyId" es requerido para procesar la petición.');
72
-            }
73
-
74
-            $this->publicKeyId = $publicKeyId;
75
-            $this->keyId = $keyId;
76
-        } catch (InstapagoException $e) {
77
-            echo $e->getMessage();
78
-        } // end try/catch
79
-    }
38
+	protected $keyId;
39
+	protected $publicKeyId;
40
+	public $cardHolder;
41
+	public $cardHolderId;
42
+	public $cardNumber;
43
+	public $cvc;
44
+	public $expirationDate;
45
+	public $amount;
46
+	public $description;
47
+	public $statusId;
48
+	public $ipAddres;
49
+	public $idPago;
50
+	public $root = 'https://api.instapago.com/';
51
+
52
+	/**
53
+	 * Crear un nuevo objeto de Instapago.
54
+	 *
55
+	 * @param string $keyId       llave privada
56
+	 * @param string $publicKeyId llave publica
57
+	 *                            Requeridas.
58
+	 */
59
+	public function __construct($keyId, $publicKeyId)
60
+	{
61
+		try {
62
+			if (empty($keyId) && empty($publicKeyId)) {
63
+				throw new InstapagoException('Los parámetros "keyId" y "publicKeyId" son requeridos para procesar la petición.');
64
+			}
65
+
66
+			if (empty($keyId)) {
67
+				throw new InstapagoException('El parámetro "keyId" es requerido para procesar la petición. ');
68
+			}
69
+
70
+			if (empty($publicKeyId)) {
71
+				throw new InstapagoException('El parámetro "publicKeyId" es requerido para procesar la petición.');
72
+			}
73
+
74
+			$this->publicKeyId = $publicKeyId;
75
+			$this->keyId = $keyId;
76
+		} catch (InstapagoException $e) {
77
+			echo $e->getMessage();
78
+		} // end try/catch
79
+	}
80 80
 
81 81
  // end construct
82 82
 
83
-    /**
84
-     * Crear un pago
85
-     * Efectúa un pago con tarjeta de crédito, una vez procesado retornar una respuesta.
86
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#crear-un-pago.
87
-     */
88
-    public function payment($amount, $description, $cardHolder, $cardHolderId, $cardNumber, $cvc, $expirationDate, $statusId, $ipAddres)
89
-    {
90
-        try {
91
-            $params = [$amount, $description, $cardHolder, $cardHolderId, $cardNumber, $cvc, $expirationDate, $statusId, $ipAddres];
92
-            $this->checkRequiredParams($params);
93
-
94
-            $this->amount = $amount;
95
-            $this->description = $description;
96
-            $this->cardHolder = $cardHolder;
97
-            $this->cardHolderId = $cardHolderId;
98
-            $this->cardNumber = $cardNumber;
99
-            $this->cvc = $cvc;
100
-            $this->expirationDate = $expirationDate;
101
-            $this->statusId = $statusId;
102
-            $this->ipAddres = $ipAddres;
103
-
104
-            $url = $this->root.'payment'; // endpoint
105
-
106
-            $fields = [
107
-                'KeyID'             => $this->keyId, //required
108
-                'PublicKeyId'       => $this->publicKeyId, //required
109
-                'amount'            => $this->amount, //required
110
-                'description'       => $this->description, //required
111
-                'cardHolder'        => $this->cardHolder, //required
112
-                'cardHolderId'      => $this->cardHolderId, //required
113
-                'cardNumber'        => $this->cardNumber, //required
114
-                'cvc'               => $this->cvc, //required
115
-                'expirationDate'    => $this->expirationDate, //required
116
-                'statusId'          => $this->statusId, //required
117
-                'IP'                => $this->ipAddres, //required
118
-            ];
119
-
120
-            $obj = $this->curlTransaccion($url, $fields);
121
-            $result = $this->checkResponseCode($obj);
122
-
123
-            return $result;
124
-        } catch (InstapagoException $e) {
125
-            echo $e->getMessage();
126
-        } // end try/catch
127
-    }
83
+	/**
84
+	 * Crear un pago
85
+	 * Efectúa un pago con tarjeta de crédito, una vez procesado retornar una respuesta.
86
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#crear-un-pago.
87
+	 */
88
+	public function payment($amount, $description, $cardHolder, $cardHolderId, $cardNumber, $cvc, $expirationDate, $statusId, $ipAddres)
89
+	{
90
+		try {
91
+			$params = [$amount, $description, $cardHolder, $cardHolderId, $cardNumber, $cvc, $expirationDate, $statusId, $ipAddres];
92
+			$this->checkRequiredParams($params);
93
+
94
+			$this->amount = $amount;
95
+			$this->description = $description;
96
+			$this->cardHolder = $cardHolder;
97
+			$this->cardHolderId = $cardHolderId;
98
+			$this->cardNumber = $cardNumber;
99
+			$this->cvc = $cvc;
100
+			$this->expirationDate = $expirationDate;
101
+			$this->statusId = $statusId;
102
+			$this->ipAddres = $ipAddres;
103
+
104
+			$url = $this->root.'payment'; // endpoint
105
+
106
+			$fields = [
107
+				'KeyID'             => $this->keyId, //required
108
+				'PublicKeyId'       => $this->publicKeyId, //required
109
+				'amount'            => $this->amount, //required
110
+				'description'       => $this->description, //required
111
+				'cardHolder'        => $this->cardHolder, //required
112
+				'cardHolderId'      => $this->cardHolderId, //required
113
+				'cardNumber'        => $this->cardNumber, //required
114
+				'cvc'               => $this->cvc, //required
115
+				'expirationDate'    => $this->expirationDate, //required
116
+				'statusId'          => $this->statusId, //required
117
+				'IP'                => $this->ipAddres, //required
118
+			];
119
+
120
+			$obj = $this->curlTransaccion($url, $fields);
121
+			$result = $this->checkResponseCode($obj);
122
+
123
+			return $result;
124
+		} catch (InstapagoException $e) {
125
+			echo $e->getMessage();
126
+		} // end try/catch
127
+	}
128 128
 
129 129
  // end payment
130 130
 
131
-    /**
132
-     * Completar Pago
133
-     * Este método funciona para procesar un bloqueo o pre-autorización
134
-     * para así procesarla y hacer el cobro respectivo.
135
-     * Para usar este método es necesario configurar en `payment()` el parametro statusId a 1
136
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#completar-pago.
137
-     */
138
-
139
-    public function continuePayment($idPago, $amount)
140
-    {
141
-        try {
142
-            $params = [$idPago, $amount];
143
-            $this->checkRequiredParams($params);
144
-
145
-            $this->idPago = $idPago;
146
-            $this->amount = $amount;
147
-
148
-            $url = $this->root.'complete'; // endpoint
149
-
150
-            $fields = [
151
-                'KeyID'             => $this->keyId, //required
152
-                'PublicKeyId'       => $this->publicKeyId, //required
153
-                'id'                => $this->idPago, //required
154
-                'amount'            => $this->amount, //required
155
-            ];
156
-
157
-            $obj = $this->curlTransaccion($url, $fields);
158
-            $result = $this->checkResponseCode($obj);
159
-
160
-            return $result;
161
-        } catch (InstapagoException $e) {
162
-            echo $e->getMessage();
163
-        } // end try/catch
164
-    }
131
+	/**
132
+	 * Completar Pago
133
+	 * Este método funciona para procesar un bloqueo o pre-autorización
134
+	 * para así procesarla y hacer el cobro respectivo.
135
+	 * Para usar este método es necesario configurar en `payment()` el parametro statusId a 1
136
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#completar-pago.
137
+	 */
138
+
139
+	public function continuePayment($idPago, $amount)
140
+	{
141
+		try {
142
+			$params = [$idPago, $amount];
143
+			$this->checkRequiredParams($params);
144
+
145
+			$this->idPago = $idPago;
146
+			$this->amount = $amount;
147
+
148
+			$url = $this->root.'complete'; // endpoint
149
+
150
+			$fields = [
151
+				'KeyID'             => $this->keyId, //required
152
+				'PublicKeyId'       => $this->publicKeyId, //required
153
+				'id'                => $this->idPago, //required
154
+				'amount'            => $this->amount, //required
155
+			];
156
+
157
+			$obj = $this->curlTransaccion($url, $fields);
158
+			$result = $this->checkResponseCode($obj);
159
+
160
+			return $result;
161
+		} catch (InstapagoException $e) {
162
+			echo $e->getMessage();
163
+		} // end try/catch
164
+	}
165 165
 
166 166
  // continuePayment
167 167
 
168
-    /**
169
-     * Anular Pago
170
-     * Este método funciona para procesar una anulación de un pago o un bloqueo.
171
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#anular-pago.
172
-     */
173
-    public function cancelPayment($idPago)
174
-    {
175
-        try {
176
-            $params = [$idPago];
177
-
178
-            $this->checkRequiredParams($params);
179
-
180
-            $this->idPago = $idPago;
181
-
182
-            $url = $this->root.'payment'; // endpoint
183
-
184
-            $myCurl = curl_init();
185
-            curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);
186
-            curl_setopt($myCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
187
-            curl_setopt($myCurl, CURLOPT_URL, $url.'?'.'KeyID='.$this->keyId.'&PublicKeyId='.$this->publicKeyId.'&id='.$this->idPago);
188
-            $server_output = curl_exec($myCurl);
189
-            curl_close($myCurl);
190
-            $obj = json_decode($server_output);
191
-            $result = $this->checkResponseCode($obj);
192
-
193
-            return $result;
194
-        } catch (InstapagoException $e) {
195
-            echo $e->getMessage();
196
-        } // end try/catch
197
-    }
168
+	/**
169
+	 * Anular Pago
170
+	 * Este método funciona para procesar una anulación de un pago o un bloqueo.
171
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#anular-pago.
172
+	 */
173
+	public function cancelPayment($idPago)
174
+	{
175
+		try {
176
+			$params = [$idPago];
177
+
178
+			$this->checkRequiredParams($params);
179
+
180
+			$this->idPago = $idPago;
181
+
182
+			$url = $this->root.'payment'; // endpoint
183
+
184
+			$myCurl = curl_init();
185
+			curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);
186
+			curl_setopt($myCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
187
+			curl_setopt($myCurl, CURLOPT_URL, $url.'?'.'KeyID='.$this->keyId.'&PublicKeyId='.$this->publicKeyId.'&id='.$this->idPago);
188
+			$server_output = curl_exec($myCurl);
189
+			curl_close($myCurl);
190
+			$obj = json_decode($server_output);
191
+			$result = $this->checkResponseCode($obj);
192
+
193
+			return $result;
194
+		} catch (InstapagoException $e) {
195
+			echo $e->getMessage();
196
+		} // end try/catch
197
+	}
198 198
 
199 199
  // cancelPayment
200 200
 
201
-    /**
202
-     * Información del Pago
203
-     * Consulta información sobre un pago generado anteriormente.
204
-     * Requiere como parámetro el `id` que es el código de referencia de la transacción
205
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#información-del-pago.
206
-     */
207
-    public function paymentInfo($idPago)
208
-    {
209
-        try {
210
-            $params = [$idPago];
201
+	/**
202
+	 * Información del Pago
203
+	 * Consulta información sobre un pago generado anteriormente.
204
+	 * Requiere como parámetro el `id` que es el código de referencia de la transacción
205
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#información-del-pago.
206
+	 */
207
+	public function paymentInfo($idPago)
208
+	{
209
+		try {
210
+			$params = [$idPago];
211 211
 
212
-            $this->checkRequiredParams($params);
212
+			$this->checkRequiredParams($params);
213 213
 
214
-            $url = $this->root.'payment'; // endpoint
214
+			$url = $this->root.'payment'; // endpoint
215 215
 
216
-            $obj = $this->curlTransaccionInfo($url, $idPago);
217
-            $result = $this->checkResponseCode($obj);
216
+			$obj = $this->curlTransaccionInfo($url, $idPago);
217
+			$result = $this->checkResponseCode($obj);
218 218
             
219
-            return $result;
220
-        } catch (InstapagoException $e) {
221
-            echo $e->getMessage();
222
-        } // end try/catch
223
-    }
219
+			return $result;
220
+		} catch (InstapagoException $e) {
221
+			echo $e->getMessage();
222
+		} // end try/catch
223
+	}
224 224
 
225 225
  // paymentInfo
226 226
 
227
-    /**
228
-     * Realiza Transaccion
229
-     * Efectúa y retornar una respuesta a un metodo de pago.
230
-     *
231
-     *@param $url endpoint a consultar
232
-     *@param $fields datos para la consulta
233
-     *
234
-     *@return $obj array resultados de la transaccion
235
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
236
-     */
237
-    public function curlTransaccion($url, $fields)
238
-    {
239
-        $myCurl = curl_init();
240
-        curl_setopt($myCurl, CURLOPT_URL, $url);
241
-        curl_setopt($myCurl, CURLOPT_POST, 1);
242
-        curl_setopt($myCurl, CURLOPT_POSTFIELDS, http_build_query($fields));
243
-        curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, true);
244
-        $server_output = curl_exec($myCurl);
245
-        curl_close($myCurl);
246
-        $obj = json_decode($server_output);
247
-
248
-        return $obj;
249
-    }
250
-
251
-    /**
252
-     * Realiza Transaccion para los métodos `cancelPayment` y `paymentInfo`
253
-     *
254
-     *@param $url endpoint a consultar
255
-     *
256
-     *@return $obj array resultados de la transaccion
257
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
258
-     */
259
-    public function curlTransaccionInfo($url, $idPago)
260
-    {
261
-        $this->idPago = $idPago;
262
-
263
-        $myCurl = curl_init();
264
-        curl_setopt($myCurl, CURLOPT_URL, $url.'?'.'KeyID='.$this->keyId.'&PublicKeyId='.$this->publicKeyId.'&id='.$this->idPago);
265
-        curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);
266
-        $server_output = curl_exec($myCurl);
267
-        curl_close($myCurl);
268
-        $obj = json_decode($server_output);
269
-
270
-        return $obj;
271
-    }
272
-
273
-
274
-    /**
275
-     * Verifica Codigo de Estado de transaccion
276
-     * Verifica y retornar el resultado de la transaccion.
277
-     *
278
-     *@param $obj datos de la consulta
279
-     *
280
-     *@return $result array datos de transaccion
281
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
282
-     */
283
-    public function checkResponseCode($obj)
284
-    {
285
-        $code = $obj->code;
286
-
287
-        if ($code == 400) {
288
-            throw new InstapagoException('Error al validar los datos enviados.');
289
-        } elseif ($code == 401) {
290
-            throw new InstapagoException('Error de autenticación, ha ocurrido un error con las llaves utilizadas.');
291
-        } elseif ($code == 403) {
292
-            throw new InstapagoException('Pago Rechazado por el banco.');
293
-        } elseif ($code == 500) {
294
-            throw new InstapagoException('Ha Ocurrido un error interno dentro del servidor.');
295
-        } elseif ($code == 503) {
296
-            throw new InstapagoException('Ha Ocurrido un error al procesar los parámetros de entrada. Revise los datos enviados y vuelva a intentarlo.');
297
-        } elseif ($code == 201) {
298
-            return [
299
-            'code'         => $code,
300
-            'msg_banco'    => $obj->message,
301
-            'voucher'      => html_entity_decode($obj->voucher),
302
-            'id_pago'      => $obj->id,
303
-            'reference'    => $obj->reference,
304
-        ];
305
-        }
306
-    }
307
-
308
-    /**
309
-     * Verifica parametros para realizar operación
310
-     * Verifica y retorna exception si algun parametro esta vacio.
311
-     *
312
-     *@param $params Array con parametros a verificar
313
-     *
314
-     *@return new InstapagoException
315
-     * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
316
-     */
317
-    private function checkRequiredParams(array $params)
318
-    {
319
-        foreach ($params as $param) {
320
-            if (empty($param)) {
321
-                throw new InstapagoException('Parámetros faltantes para procesar el pago. Verifique la documentación.');
322
-            }
323
-        }
324
-    }
227
+	/**
228
+	 * Realiza Transaccion
229
+	 * Efectúa y retornar una respuesta a un metodo de pago.
230
+	 *
231
+	 *@param $url endpoint a consultar
232
+	 *@param $fields datos para la consulta
233
+	 *
234
+	 *@return $obj array resultados de la transaccion
235
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
236
+	 */
237
+	public function curlTransaccion($url, $fields)
238
+	{
239
+		$myCurl = curl_init();
240
+		curl_setopt($myCurl, CURLOPT_URL, $url);
241
+		curl_setopt($myCurl, CURLOPT_POST, 1);
242
+		curl_setopt($myCurl, CURLOPT_POSTFIELDS, http_build_query($fields));
243
+		curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, true);
244
+		$server_output = curl_exec($myCurl);
245
+		curl_close($myCurl);
246
+		$obj = json_decode($server_output);
247
+
248
+		return $obj;
249
+	}
250
+
251
+	/**
252
+	 * Realiza Transaccion para los métodos `cancelPayment` y `paymentInfo`
253
+	 *
254
+	 *@param $url endpoint a consultar
255
+	 *
256
+	 *@return $obj array resultados de la transaccion
257
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
258
+	 */
259
+	public function curlTransaccionInfo($url, $idPago)
260
+	{
261
+		$this->idPago = $idPago;
262
+
263
+		$myCurl = curl_init();
264
+		curl_setopt($myCurl, CURLOPT_URL, $url.'?'.'KeyID='.$this->keyId.'&PublicKeyId='.$this->publicKeyId.'&id='.$this->idPago);
265
+		curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);
266
+		$server_output = curl_exec($myCurl);
267
+		curl_close($myCurl);
268
+		$obj = json_decode($server_output);
269
+
270
+		return $obj;
271
+	}
272
+
273
+
274
+	/**
275
+	 * Verifica Codigo de Estado de transaccion
276
+	 * Verifica y retornar el resultado de la transaccion.
277
+	 *
278
+	 *@param $obj datos de la consulta
279
+	 *
280
+	 *@return $result array datos de transaccion
281
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
282
+	 */
283
+	public function checkResponseCode($obj)
284
+	{
285
+		$code = $obj->code;
286
+
287
+		if ($code == 400) {
288
+			throw new InstapagoException('Error al validar los datos enviados.');
289
+		} elseif ($code == 401) {
290
+			throw new InstapagoException('Error de autenticación, ha ocurrido un error con las llaves utilizadas.');
291
+		} elseif ($code == 403) {
292
+			throw new InstapagoException('Pago Rechazado por el banco.');
293
+		} elseif ($code == 500) {
294
+			throw new InstapagoException('Ha Ocurrido un error interno dentro del servidor.');
295
+		} elseif ($code == 503) {
296
+			throw new InstapagoException('Ha Ocurrido un error al procesar los parámetros de entrada. Revise los datos enviados y vuelva a intentarlo.');
297
+		} elseif ($code == 201) {
298
+			return [
299
+			'code'         => $code,
300
+			'msg_banco'    => $obj->message,
301
+			'voucher'      => html_entity_decode($obj->voucher),
302
+			'id_pago'      => $obj->id,
303
+			'reference'    => $obj->reference,
304
+		];
305
+		}
306
+	}
307
+
308
+	/**
309
+	 * Verifica parametros para realizar operación
310
+	 * Verifica y retorna exception si algun parametro esta vacio.
311
+	 *
312
+	 *@param $params Array con parametros a verificar
313
+	 *
314
+	 *@return new InstapagoException
315
+	 * https://github.com/abr4xas/php-instapago/blob/master/help/DOCUMENTACION.md#PENDIENTE
316
+	 */
317
+	private function checkRequiredParams(array $params)
318
+	{
319
+		foreach ($params as $param) {
320
+			if (empty($param)) {
321
+				throw new InstapagoException('Parámetros faltantes para procesar el pago. Verifique la documentación.');
322
+			}
323
+		}
324
+	}
325 325
 } // end class
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             $this->statusId = $statusId;
102 102
             $this->ipAddres = $ipAddres;
103 103
 
104
-            $url = $this->root.'payment'; // endpoint
104
+            $url = $this->root . 'payment'; // endpoint
105 105
 
106 106
             $fields = [
107 107
                 'KeyID'             => $this->keyId, //required
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
             $this->idPago = $idPago;
146 146
             $this->amount = $amount;
147 147
 
148
-            $url = $this->root.'complete'; // endpoint
148
+            $url = $this->root . 'complete'; // endpoint
149 149
 
150 150
             $fields = [
151 151
                 'KeyID'             => $this->keyId, //required
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 
180 180
             $this->idPago = $idPago;
181 181
 
182
-            $url = $this->root.'payment'; // endpoint
182
+            $url = $this->root . 'payment'; // endpoint
183 183
 
184 184
             $myCurl = curl_init();
185 185
             curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);
186 186
             curl_setopt($myCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
187
-            curl_setopt($myCurl, CURLOPT_URL, $url.'?'.'KeyID='.$this->keyId.'&PublicKeyId='.$this->publicKeyId.'&id='.$this->idPago);
187
+            curl_setopt($myCurl, CURLOPT_URL, $url . '?' . 'KeyID=' . $this->keyId . '&PublicKeyId=' . $this->publicKeyId . '&id=' . $this->idPago);
188 188
             $server_output = curl_exec($myCurl);
189 189
             curl_close($myCurl);
190 190
             $obj = json_decode($server_output);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
             $this->checkRequiredParams($params);
213 213
 
214
-            $url = $this->root.'payment'; // endpoint
214
+            $url = $this->root . 'payment'; // endpoint
215 215
 
216 216
             $obj = $this->curlTransaccionInfo($url, $idPago);
217 217
             $result = $this->checkResponseCode($obj);
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         $this->idPago = $idPago;
262 262
 
263 263
         $myCurl = curl_init();
264
-        curl_setopt($myCurl, CURLOPT_URL, $url.'?'.'KeyID='.$this->keyId.'&PublicKeyId='.$this->publicKeyId.'&id='.$this->idPago);
264
+        curl_setopt($myCurl, CURLOPT_URL, $url . '?' . 'KeyID=' . $this->keyId . '&PublicKeyId=' . $this->publicKeyId . '&id=' . $this->idPago);
265 265
         curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);
266 266
         $server_output = curl_exec($myCurl);
267 267
         curl_close($myCurl);
Please login to merge, or discard this patch.