Skip to content

Commit

Permalink
Actualización, cambio de URL para recurso Tokens
Browse files Browse the repository at this point in the history
De api.culqi.com a secure.culqi.com
  • Loading branch information
Brayan Cruces committed Apr 12, 2019
1 parent fe7e274 commit 8933bc7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.4
1.3.5
11 changes: 8 additions & 3 deletions lib/Culqi/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
8 changes: 7 additions & 1 deletion lib/Culqi/Culqi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Culqi/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/culqi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8933bc7

Please sign in to comment.