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