From 33a982107f68ddd9af14ea4d4bd74bbc66d6ea48 Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Tue, 30 Jan 2018 19:32:19 -0600 Subject: [PATCH 1/2] Fix bug with discount --- monero/include/monero_payments.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 7942e57..d4e9dc4 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -523,11 +523,20 @@ class Monero_Gateway extends WC_Payment_Gateway { $xmr_live_price = $this->retriveprice($currency); $live_for_storing = $xmr_live_price * 100; //This will remove the decimal so that it can easily be stored as an integer - $new_amount = $amount / $xmr_live_price; - $rounded_amount = round($new_amount, 12); - $wpdb->query("INSERT INTO $payment_id (rate) - VALUES ($live_for_storing)"); + $wpdb->query("INSERT INTO $payment_id (rate) VALUES ($live_for_storing)"); + if(isset($this->discount)) + { + $new_amount = $amount / $xmr_live_price; + $discount = $new_amount * $this->discount / 100; + $discounted_price = $new_amount - $discount; + $rounded_amount = round($discounted_price, 12); + } + else + { + $new_amount = $amount / $xmr_live_price; + $rounded_amount = round($new_amount, 12); + } } return $rounded_amount; From 19a2b2cfe167c3fba7157cfb57750e6043a4510c Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Tue, 30 Jan 2018 19:35:14 -0600 Subject: [PATCH 2/2] Only use integrated address w RPC --- monero/include/monero_payments.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index d4e9dc4..d3a1a1f 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -400,11 +400,7 @@ class Monero_Gateway extends WC_Payment_Gateway $payment_id = $this->set_paymentid_cookie(8); $currency = $order->get_currency(); $amount_xmr2 = $this->changeto($amount, $currency, $payment_id); - $address = $this->address; - if (!isset($address)) { - // If there isn't address (merchant missed that field!), $address will be the Monero address for donating :) - $address = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; - } + $uri = "monero:$address?amount=$amount?payment_id=$payment_id"; $array_integrated_address = $this->monero_daemon->make_integrated_address($payment_id); if (!isset($array_integrated_address)) {