diff --git a/CHANGELOG.md b/CHANGELOG.md index ef054f6..50ebb8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + + +### 1.3.5 12-04-2019 +* Se actualiza la URL base para creación de tokens. + + ### 1.3.4 10-10-2018 * Se agrega recurso de Orders diff --git a/VERSION b/VERSION index d0149fe..80e78df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.4 +1.3.5 diff --git a/lib/Culqi/Client.php b/lib/Culqi/Client.php index e8f6453..e7cafa9 100644 --- a/lib/Culqi/Client.php +++ b/lib/Culqi/Client.php @@ -9,17 +9,22 @@ * @package Culqi */ class Client { - public function request($method, $url, $api_key, $data = NULL) { + public function request($method, $url, $api_key, $data = NULL, $secure_url = false) { try { $url_params = is_array($data) ? '?' . http_build_query($data) : ''; $headers= array("Authorization" => "Bearer ".$api_key, "Content-Type" => "application/json", "Accept" => "application/json"); $options = array( 'timeout' => 120 - ); + ); + + // Check URL + if($secure_url) $base_url = Culqi::SECURE_BASE_URL; + else $base_url = Culqi::BASE_URL; + if($method == "GET") { $response = \Requests::get(Culqi::BASE_URL. $url . $url_params, $headers, $options); } else if($method == "POST") { - $response = \Requests::post(Culqi::BASE_URL . $url, $headers, json_encode($data), $options); + $response = \Requests::post($base_url . $url, $headers, json_encode($data), $options); } else if($method == "PATCH") { $response = \Requests::patch(Culqi::BASE_URL . $url, $headers, json_encode($data), $options); } else if($method == "DELETE") { diff --git a/lib/Culqi/Culqi.php b/lib/Culqi/Culqi.php index 34542c5..5328c7c 100644 --- a/lib/Culqi/Culqi.php +++ b/lib/Culqi/Culqi.php @@ -18,7 +18,13 @@ class Culqi /** * La URL Base por defecto */ - const BASE_URL = "https://api.culqi.com/v2"; + const BASE_URL = "https://api.culqi.com/v2"; + + /** + * URL alternativa (segura) + */ + const SECURE_BASE_URL = "https://secure.culqi.com/v2"; + /** * Constructor. * diff --git a/lib/Culqi/Tokens.php b/lib/Culqi/Tokens.php index 1cdf8ec..ca88e7f 100644 --- a/lib/Culqi/Tokens.php +++ b/lib/Culqi/Tokens.php @@ -26,7 +26,7 @@ public function all($options = NULL) { * @return create Token response. */ public function create($options = NULL) { - return $this->request("POST", self::URL_TOKENS, $api_key = $this->culqi->api_key, $options); + return $this->request("POST", self::URL_TOKENS, $api_key = $this->culqi->api_key, $options, true); } /** diff --git a/lib/culqi.php b/lib/culqi.php index b1a3335..91fcb30 100644 --- a/lib/culqi.php +++ b/lib/culqi.php @@ -4,7 +4,7 @@ * * Init, cargamos todos los archivos necesarios * - * @version 1.3.0 + * @version 1.3.5 * @package Culqi * @copyright Copyright (c) 2015-2017 Culqi * @license MIT