@@ -18,6 +18,8 @@ public function __construct()
18
18
$ this ->method_title = 'PayWay Hrvatski Telekom Woocommerce Payment Gateway ' ;
19
19
$ this ->has_fields = false ;
20
20
21
+ $ this ->curlExtension = extension_loaded ('curl ' );
22
+
21
23
$ this ->ratehrkfixed = 7.53450 ;
22
24
$ this ->tecajnaHnbApi = "https://api.hnb.hr/tecajn/v2 " ;
23
25
@@ -141,6 +143,10 @@ function receipt_page($order)
141
143
142
144
private function get_hnb_currency ()
143
145
{
146
+ if (!$ this ->curlExtension ) {
147
+ return "CURL extension is missing. Conversion is disabled. " ;
148
+ }
149
+
144
150
$ ch = curl_init ();
145
151
146
152
curl_setopt ($ ch , CURLOPT_URL , $ this ->tecajnaHnbApi );
@@ -185,6 +191,10 @@ private function get_last_modified_hnb_file()
185
191
{
186
192
$ file = __DIR__ . '/tecajnv2.json ' ;
187
193
194
+ if (!$ this ->curlExtension ) {
195
+ return "HNB conversion is disabled due of missing CURL extension. " ;
196
+ }
197
+
188
198
if (file_exists ($ file )) {
189
199
return date ("d.m.Y H:i:s " , filemtime ($ file ));
190
200
}
@@ -348,7 +358,9 @@ public function generate_ipg_form($order_id)
348
358
$ order_total = $ woocommerce ->cart ->total * $ this ->ratehrkfixed ;
349
359
350
360
} 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
+ }
352
364
}
353
365
} else {
354
366
$ order_total = $ woocommerce ->cart ->total ;
0 commit comments