Skip to content

Commit b55d8a7

Browse files
committed
fix:
* added CURL verification checks and render * disable HNB conversion if is curl not available
1 parent cd88ac2 commit b55d8a7

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Most recent latest changes is defined on every major, minor and bug fixes.
66

77
## Versions
88

9+
### 1.6.1
10+
11+
* Curl module load checks
12+
913
### 1.6
1014

1115
* IntlCurrency and IntAmount added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Removed
3838

3939
API 2.0:
4040

41-
* Version [1.6](https://github.com/marinsagovac/woocommerce-tcom-payway/archive/refs/tags/1.6.zip) September/2022
41+
* Version [1.6.1](https://github.com/marinsagovac/woocommerce-tcom-payway/releases/tags/1.6.1.zip) September/2022
4242
* Version [1.5](https://github.com/marinsagovac/woocommerce-tcom-payway/releases/tags/1.5.zip) November/2021
4343
* Version [1.4](https://github.com/marinsagovac/woocommerce-tcom-payway/releases/tags/1.4.zip) June/2021
4444

classes/class-wc-tpayway.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public function __construct()
1818
$this->method_title = 'PayWay Hrvatski Telekom Woocommerce Payment Gateway';
1919
$this->has_fields = false;
2020

21+
$this->curlExtension = extension_loaded('curl');
22+
2123
$this->ratehrkfixed = 7.53450;
2224
$this->tecajnaHnbApi = "https://api.hnb.hr/tecajn/v2";
2325

@@ -141,6 +143,10 @@ function receipt_page($order)
141143

142144
private function get_hnb_currency()
143145
{
146+
if (!$this->curlExtension) {
147+
return "CURL extension is missing. Conversion is disabled.";
148+
}
149+
144150
$ch = curl_init();
145151

146152
curl_setopt($ch, CURLOPT_URL, $this->tecajnaHnbApi);
@@ -185,6 +191,10 @@ private function get_last_modified_hnb_file()
185191
{
186192
$file = __DIR__ . '/tecajnv2.json';
187193

194+
if (!$this->curlExtension) {
195+
return "HNB conversion is disabled due of missing CURL extension.";
196+
}
197+
188198
if (file_exists($file)) {
189199
return date("d.m.Y H:i:s", filemtime($file));
190200
}
@@ -348,7 +358,9 @@ public function generate_ipg_form($order_id)
348358
$order_total = $woocommerce->cart->total * $this->ratehrkfixed;
349359

350360
} else {
351-
$order_total = $woocommerce->cart->total * $this->fetch_hnb_currency($curr_symbole);
361+
if ($this->curlExtension) {
362+
$order_total = $woocommerce->cart->total * $this->fetch_hnb_currency($curr_symbole);
363+
}
352364
}
353365
} else {
354366
$order_total = $woocommerce->cart->total;

0 commit comments

Comments
 (0)