Skip to content

Commit a717a87

Browse files
author
arianoangelo
committed
v4.7.3
- Minor fixes
1 parent bdafb80 commit a717a87

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

CryptAPI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
Plugin Name: CryptAPI Payment Gateway for WooCommerce
44
Plugin URI: https://github.com/cryptapi/woocommerce-cryptapi
55
Description: Accept cryptocurrency payments on your WooCommerce website
6-
Version: 4.7.2
6+
Version: 4.7.3
77
Requires at least: 5
88
Tested up to: 6.1.1
99
WC requires at least: 5.8
10-
WC tested up to: 7.2.2
10+
WC tested up to: 7.4
1111
Requires PHP: 7.2
1212
Author: cryptapi
1313
Author URI: https://cryptapi.io/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
312312
#### 4.7.2
313313
* Minor fixes
314314

315+
#### 4.7.3
316+
* Minor fixes
317+
315318
### Upgrade Notice
316319
#### 4.3
317320
* Please be sure to enable the PHP extension BCMath before upgrading to this version.

controllers/CryptAPI.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,10 @@ function order_status() {
602602

603603
$history = json_decode( $order->get_meta( 'cryptapi_history' ), true );
604604

605-
$calc = $this->calc_order( $history, $order->get_meta( 'cryptapi_total' ), $order->get_meta( 'cryptapi_total_fiat' ) );
605+
$cryptapi_total = $order->get_meta( 'cryptapi_total' );
606+
$order_total = $order->get_total( 'edit' );
607+
608+
$calc = $this->calc_order( $history, $cryptapi_total, $order_total );
606609

607610
$already_paid = $calc['already_paid'];
608611
$already_paid_fiat = $calc['already_paid_fiat'];
@@ -1143,7 +1146,10 @@ function ca_cronjob($force = false, $order_id = '') {
11431146

11441147
$min_tx = (float) $order->get_meta( 'cryptapi_min' );
11451148

1146-
$calc = $this->calc_order( $history, $order->get_meta( 'cryptapi_total' ), $order->get_meta( 'cryptapi_total_fiat' ) );
1149+
$cryptapi_total = $order->get_meta( 'cryptapi_total' );
1150+
$order_total = $order->get_total( 'edit' );
1151+
1152+
$calc = $this->calc_order( $history, $cryptapi_total, $order_total);
11471153

11481154
$remaining = $calc['remaining'];
11491155
$remaining_pending = $calc['remaining_pending'];
@@ -1155,10 +1161,11 @@ function ca_cronjob($force = false, $order_id = '') {
11551161
if ( ($remaining === $remaining_pending && $remaining_pending > 0) || ((int)$order_id === $order->get_id() && $force && $remaining === $remaining_pending && $remaining_pending > 0)) {
11561162
$cryptapi_coin = $order->get_meta( 'cryptapi_currency' );
11571163

1158-
$crypto_total = CryptAPI\Helper::sig_fig( CryptAPI\Helper::get_conversion( $woocommerce_currency, $cryptapi_coin, $order->get_total( 'edit' ), $this->disable_conversion ), 6 );
1164+
$crypto_conversion = (float) CryptAPI\Helper::get_conversion( $woocommerce_currency, $cryptapi_coin, $order_total, $this->disable_conversion );
1165+
$crypto_total = CryptAPI\Helper::sig_fig($crypto_conversion, 6 );
11591166
$order->update_meta_data( 'cryptapi_total', $crypto_total );
11601167

1161-
$calc_cron = $this->calc_order( $history, $order->get_meta( 'cryptapi_total' ), $order->get_meta( 'cryptapi_total_fiat' ) );
1168+
$calc_cron = $this->calc_order( $history, $crypto_total, $order_total );
11621169
$crypto_remaining_total = $calc_cron['remaining_pending'];
11631170

11641171
if ( $remaining_pending <= $min_tx && ! $remaining_pending <= 0 ) {
@@ -1171,7 +1178,7 @@ function ca_cronjob($force = false, $order_id = '') {
11711178
}
11721179

11731180
$order->update_meta_data( 'cryptapi_last_price_update', time() );
1174-
$order->save();
1181+
$order->save_meta_data();
11751182
}
11761183

11771184
if ( $order_timeout !== 0 && ( $order_timestamp + $order_timeout ) <= time() && $already_paid <= 0 && (int) $order->get_meta( 'cryptapi_cancelled' ) === 0 ) {

define.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

3-
define('CRYPTAPI_PLUGIN_VERSION', '4.7.1');
3+
define('CRYPTAPI_PLUGIN_VERSION', '4.7.3');
44
define('CRYPTAPI_PLUGIN_PATH', plugin_dir_path(__FILE__));
55
define('CRYPTAPI_PLUGIN_URL', plugin_dir_url(__FILE__));

readme.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Contributors: cryptapi
33
Tags: crypto payments, woocommerce, payment gateway, crypto, payment, pay with crypto, payment request, bitcoin, bnb, usdt, ethereum, monero, litecoin, bitcoin cash, shib, doge
44
Requires at least: 5
55
Tested up to: 6.1.1
6-
Stable tag: 4.7.2
6+
Stable tag: 4.7.3
77
Requires PHP: 7.2
88
WC requires at least: 5.8
9-
WC tested up to: 7.2.2
9+
WC tested up to: 7.4
1010
License: MIT
1111

1212
Accept cryptocurrency payments on your WooCommerce website
@@ -321,6 +321,9 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
321321
= 4.7.2 =
322322
* Minor fixes
323323

324+
= 4.7.3 =
325+
* Minor fixes
326+
324327
== Upgrade Notice ==
325328

326329
= 4.3 =

utils/helper.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ public static function get_estimate($coin)
214214
$response = Helper::_request($coin, 'estimate', $params);
215215

216216
if ($response->status == 'success') {
217-
218217
return $response->estimated_cost_currency;
219218
}
220219

@@ -267,7 +266,6 @@ public static function sig_fig($value, $digits)
267266
private static function _request($coin, $endpoint, $params = [], $assoc = false)
268267
{
269268
$base_url = Helper::$base_url;
270-
271269
if (!empty($params['apikey']) && $endpoint !== 'info') {
272270
$base_url = Helper::$pro_url;
273271
}
@@ -287,14 +285,18 @@ private static function _request($coin, $endpoint, $params = [], $assoc = false)
287285
$url .= "?{$data}";
288286
}
289287

290-
$response = wp_remote_retrieve_body(wp_remote_get($url));
288+
for ($y = 0; $y < 5; $y++) {
289+
try {
290+
$response = json_decode(wp_remote_retrieve_body(wp_remote_get($url)), $assoc);
291291

292-
// $ch = curl_init();
293-
// curl_setopt($ch, CURLOPT_URL, $url);
294-
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
295-
// $response = curl_exec($ch);
296-
// curl_close($ch);
292+
if ($response->status == 'success') {
293+
return $response;
294+
}
295+
} catch (Exception $e) {
296+
//
297+
}
298+
}
297299

298-
return json_decode($response, $assoc);
300+
return json_decode('{"status": "error"}', $assoc);
299301
}
300302
}

0 commit comments

Comments
 (0)