From a2db5787ddfd6343ec28f38da4d5a24847bb5bfe Mon Sep 17 00:00:00 2001 From: JKacicM Date: Wed, 14 Aug 2024 12:15:03 -0400 Subject: [PATCH] Log Version --- composer.json | 5 -- composer.lock | 68 -------------------------- includes/abstract-wc-gateway-khipu.php | 36 +++++++++----- readme.txt | 4 +- woocommerce-gateway-khipu.php | 2 +- 5 files changed, 28 insertions(+), 87 deletions(-) delete mode 100644 composer.json delete mode 100644 composer.lock diff --git a/composer.json b/composer.json deleted file mode 100644 index 8ae629e..0000000 --- a/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "khipu/khipu-api-client": "3.0.0.x-dev" - } -} diff --git a/composer.lock b/composer.lock deleted file mode 100644 index d9aaa04..0000000 --- a/composer.lock +++ /dev/null @@ -1,68 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "f81092061f974ec7afff284b8735422d", - "packages": [ - { - "name": "khipu/khipu-api-client", - "version": "2.9.1", - "source": { - "type": "git", - "url": "https://github.com/khipu/khipu-api-php-client.git", - "reference": "bef36baf4026884b45e5849a7875f6b5e9c462a5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/khipu/khipu-api-php-client/zipball/bef36baf4026884b45e5849a7875f6b5e9c462a5", - "reference": "bef36baf4026884b45e5849a7875f6b5e9c462a5", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0.1", - "satooshi/php-coveralls": "~0.6.1", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Khipu\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "khipu", - "homepage": "https://github.com/khipu/khipu-api-php-client" - } - ], - "homepage": "https://github.com/khipu/khipu-api-php-client", - "keywords": [ - "api", - "khipu", - "php", - "sdk" - ], - "time": "2019-05-27T14:21:10+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/includes/abstract-wc-gateway-khipu.php b/includes/abstract-wc-gateway-khipu.php index e6c0622..fd2d2e3 100644 --- a/includes/abstract-wc-gateway-khipu.php +++ b/includes/abstract-wc-gateway-khipu.php @@ -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) @@ -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(); diff --git a/readme.txt b/readme.txt index 7a71962..dc0b036 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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 diff --git a/woocommerce-gateway-khipu.php b/woocommerce-gateway-khipu.php index a51d94b..513dc46 100644 --- a/woocommerce-gateway-khipu.php +++ b/woocommerce-gateway-khipu.php @@ -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 */