Skip to content

Commit

Permalink
Log Version
Browse files Browse the repository at this point in the history
  • Loading branch information
JKacicM committed Aug 14, 2024
1 parent 24d9a04 commit a2db578
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 87 deletions.
5 changes: 0 additions & 5 deletions composer.json

This file was deleted.

68 changes: 0 additions & 68 deletions composer.lock

This file was deleted.

36 changes: 25 additions & 11 deletions includes/abstract-wc-gateway-khipu.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

abstract class WC_Gateway_khipu_abstract extends WC_Payment_Gateway
{
const PLUGIN_VERSION = '4.0.1';
const PLUGIN_VERSION = '4.0.2';
const API_VERSION = '3.0';

function comm_error($exception = null)
Expand Down Expand Up @@ -236,28 +236,42 @@ function get_payment_methods()

if (!$response || !$response['ts'] || (time() - (int)$response['ts']) > 30) {
unset($response);
$headers = [
'x-api-key' => $this->api_key,
'User-Agent' => 'khipu-api-php-client/' . self::API_VERSION . '|woocommerce-khipu/' . self::PLUGIN_VERSION,
'Content-Type' => 'application/json'
];

$payments_url = 'https://payment-api.khipu.com/v3/merchants/' . $this->receiver_id . '/paymentMethods';

$response = wp_remote_get($payments_url, [
'headers' => $headers
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $payments_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-api-key: ' . $this->api_key,
'User-Agent: khipu-api-php-client/' . self::API_VERSION . '|woocommerce-khipu/' . self::PLUGIN_VERSION,
'Content-Type: application/json'
]);

if (!is_wp_error($response)) {
$paymentsMethodsResponse = json_decode(wp_remote_retrieve_body($response));
$curl_response = curl_exec($ch);

if (curl_errno($ch)) {
error_log('cURL error: ' . curl_error($ch));
curl_close($ch);
return null;
}

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code === 200) {
$paymentsMethodsResponse = json_decode($curl_response);
$response['methods'] = $paymentsMethodsResponse;
$response['ts'] = time();
update_option('woocommerce_gateway_khipu_payment_methods', $response);
} else {
error_log('Error en la solicitud a Khipu API: HTTP code ' . $http_code);
return null;
}
}
return $response['methods'];
}


function get_payment_method_icon($id)
{
$methods = $this->get_payment_methods();
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link:
Tags: payment gateway, khipu, woocommerce, chile
Requires at least: 6.0
Tested up to: 6.6.1
Stable tag: 4.0.1
Stable tag: 4.0.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -38,7 +38,7 @@ No hay preguntas aún.
3. https://s3.amazonaws.com/static.khipu.com/id-cobrador.png

== Changelog ==
4.0.1 Log de Versión
4.0.2 Log de Versión
4.0 Actualización a API 3.0 Khipu
3.6 Compatible con PHP8
3.5 Incluye detalle de compra en el comprobante de pago
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-gateway-khipu.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: WooCommerce khipu Gateway
* Plugin URI: https://khipu.com/page/woocommerce
* Description: Acepte pagos con transferencia procesadas por khipu
* Version: 4.0.1
* Version: 4.0.2
* Author: khipu
* Author URI: https://khipu.com
*/
Expand Down

0 comments on commit a2db578

Please sign in to comment.