From c8c470e03b814a1618032058260bad017ab60d18 Mon Sep 17 00:00:00 2001 From: apezio Date: Thu, 8 Mar 2018 12:25:59 -0800 Subject: [PATCH 1/6] added client credits for paying with monero --- modules/gateways/monero.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/gateways/monero.php b/modules/gateways/monero.php index c12005d..f7d0fa0 100644 --- a/modules/gateways/monero.php +++ b/modules/gateways/monero.php @@ -23,7 +23,7 @@ function monero_Config(){ 'daemon_port' => array('FriendlyName' => 'Wallet RPC Port','Type' => 'text','Default' => '18081','Description' => ''), 'daemon_user' => array('FriendlyName' => 'Wallet RPC Username','Type' => 'text','Default' => '','Description' => ''), 'daemon_pass' => array('FriendlyName' => 'Wallet RPC Password','Type' => 'text','Default' => '','Description' => ''), - 'discount_percentage' => array('FriendlyName' => 'Discount Percentage','Type' => 'text','Default' => '0%','Description' => 'Percentage discount for paying with Monero.') + 'bonus_percentage' => array('FriendlyName' => 'Bonus Percentage','Type' => 'text','Default' => '5%','Description' => 'Percentage Bonus for paying with Monero. Applied to clients Credit Balance.') ); } @@ -77,7 +77,6 @@ function monero_retrivePriceList($currencies = 'BTC,USD,EUR,CAD,INR,GBP,BRL') { return $xmr_price; } - function monero_retriveprice($currency) { global $currency_symbol; $xmr_price = monero_retrivePriceList('BTC,USD,EUR,CAD,INR,GBP,BRL'); @@ -115,11 +114,12 @@ function monero_retriveprice($currency) { } } + function monero_changeto($amount, $currency){ $xmr_live_price = monero_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); + $rounded_amount = round($new_amount, 8); return $rounded_amount; } @@ -131,8 +131,6 @@ function xmr_to_fiat($amount, $currency){ return $rounded_amount; } - - function monero_link($params){ global $currency_symbol; @@ -143,10 +141,12 @@ function monero_link($params){ $invoiceid = $params['invoiceid']; $amount = $params['amount']; - $discount_setting = $gateway['discount_percentage']; - $discount_percentage = 100 - (preg_replace("/[^0-9]/", "", $discount_setting)); - $amount = money_format('%i', $amount * ($discount_percentage / 100)); + + $bonus_setting = $gateway['bonus_percentage']; + $bonus_percentage = 100 - (preg_replace("/[^0-9]/", "", $bonus_setting)); +// $amount = money_format('%i', $amount * ($bonus_percentage / 100)); $currency = $params['currency']; + $client_id = $params['clientdetails']['id']; $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; @@ -158,7 +158,6 @@ function monero_link($params){ $systemurl = $params['systemurl']; // Transform Current Currency into Monero $amount_xmr = monero_changeto($amount, $currency); - $post = array( 'invoice_id' => $invoiceid, 'systemURL' => $systemurl, @@ -173,7 +172,8 @@ function monero_link($params){ 'address' => $address, 'amount_xmr' => $amount_xmr, 'amount' => $amount, - 'currency' => $currency + 'currency' => $currency, + 'client_id' => $client_id ); $form = '
'; foreach ($post as $key => $value) { @@ -182,8 +182,8 @@ function monero_link($params){ $form .= ''; $form .= '
'; $form .= '

'.$amount_xmr. " XMR (". $currency_symbol . $amount . " " . $currency .')

'; - if ($discount_setting > 0) { - $form .='

Discount Applied: ' . preg_replace("/[^0-9]/", "", $discount_setting) . '%

'; + if ($bonus_setting > 0) { + $form .='

Bonus to be applied: ' . preg_replace("/[^0-9]/", "", $bonus_setting) . '%

'; } return $form; } From 06ec0c45750bb388a4fd615ab90cc630f09fad6c Mon Sep 17 00:00:00 2001 From: apezio Date: Thu, 8 Mar 2018 12:27:46 -0800 Subject: [PATCH 2/6] Update monero.php --- modules/gateways/monero.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gateways/monero.php b/modules/gateways/monero.php index f7d0fa0..a1b7d2c 100644 --- a/modules/gateways/monero.php +++ b/modules/gateways/monero.php @@ -119,7 +119,7 @@ function monero_changeto($amount, $currency){ $xmr_live_price = monero_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, 8); + $rounded_amount = round($new_amount, 12); return $rounded_amount; } From 54dfebc305405cf36710b8065cba87b1e7683d8c Mon Sep 17 00:00:00 2001 From: apezio Date: Thu, 8 Mar 2018 12:30:24 -0800 Subject: [PATCH 3/6] bonus credits, fixed bugs when underpaying invoice Bonus Credit config option is now available for paying in XMR. Fixed bug when Invoice was only partially paid. --- modules/gateways/monero/verify.php | 78 +++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/modules/gateways/monero/verify.php b/modules/gateways/monero/verify.php index 398c37f..da9269b 100644 --- a/modules/gateways/monero/verify.php +++ b/modules/gateways/monero/verify.php @@ -19,7 +19,7 @@ $amount = $_POST['amount']; $hash = $_POST['hash']; $currency = $_POST['currency']; - +$client_id = $_POST['client_id']; $secretKey = $GATEWAY['secretkey']; $link = $GATEWAY['daemon_host'].":".$GATEWAY['daemon_port']."/json_rpc"; @@ -27,7 +27,7 @@ require_once('library.php'); -function verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $status, $gatewaymodule, $hash, $secretKey, $currency){ +function verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $status, $gatewaymodule, $hash, $secretKey, $currency, $client_id){ global $currency_symbol; $monero_daemon = new Monero_rpc($link); $check_mempool = true; @@ -41,6 +41,7 @@ function verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $s } $message = "Waiting for your payment."; + //payment_id is sometimes empty // send each monero tx in the mempool to handle_whmcs @@ -51,7 +52,7 @@ function verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $s $txn_txid = $transactions["txid"]; $txn_payment_id = $transactions["payment_id"]; if(isset($txn_amt)) { - return handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule); + return handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule, $client_id); } } } @@ -62,7 +63,7 @@ function verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $s $txn_txid = $transactions["tx_hash"]; $txn_payment_id = $transactions["payment_id"]; if(isset($txn_amt)) { - return handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule); + return handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule, $client_id); } } } else { @@ -71,7 +72,8 @@ function verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $s return $message; } -function handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule) { +function handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule, $client_id) { + global $currency_symbol; $amount_atomic_units = $amount_xmr * 1000000000000; //check if monero tx already exists in whmcs @@ -82,19 +84,57 @@ function handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_paymen //check one more time then add the payment if the transaction has not been added. checkCbTransID($txn_txid); $fiat_paid = xmr_to_fiat($txn_amt, $currency); - add_payment("AddInvoicePayment", $invoice_id, $txn_txid, $gatewaymodule, $fiat_paid, $txn_amt / 1000000000000, $payment_id, $fee); + add_payment("AddInvoicePayment", $invoice_id, $txn_txid, $gatewaymodule, $fiat_paid, $txn_amt / 1000000000000, $payment_id, $fee, $client_id); } - // add 2% when doing the comparison in case of price fluctuations? - if ($txn_amt * 1.02 >= $amount_atomic_units) { + + // add 3% when doing the comparison in case of price fluctuations? + if ($txn_amt * 1.03 >= $amount_atomic_units) { + // check if invoice has been marked as paid, if not, mark Paid. WHMCS normally wont mark as Paid if the amount isnt at least exactly the invoice due amount, which would stop service deployments due to WHCMS thinking a few cents were missing. + $command = 'GetInvoice'; + $postData = array( + 'invoiceid' => $invoice_id, + ); + $results = localAPI($command, $postData, $adminUsername); + if ($results['status'] == "Unpaid") { + $postData = array( + 'action' => "UpdateInvoice", + 'invoiceid' => $invoice_id, + 'status' => "Paid", + ); + $results = localAPI("UpdateInvoice", $postData, $adminUsername); + } return "Payment has been received."; } else { - return "Error: Amount " . $txn_amt / 1000000000000 . " XMR too small. Please send full amount or contact customer service. Transaction ID: " . $txn_txid . ". Payment ID: " . $payment_id; + + //check invoice balance + $command = 'GetInvoice'; + $postData = array( + 'invoiceid' => $invoice_id, + ); + $results = localAPI($command, $postData, $adminUsername); + $invoice_balance = $results['balance']; + // if invoice balance is below 25 cents mark as paid + if ($invoice_balance <= ".25") { + $postData = array( + 'action' => "UpdateInvoice", + 'invoiceid' => $invoice_id, + 'status' => "Paid", + ); + $results = localAPI("UpdateInvoice", $postData, $adminUsername); + return "Payment has been received."; + } + $money_balance = money_format('%i', $invoice_balance); + $xmr_remaining = monero_changeto($money_balance, $currency); + + return "Error: We received " . $txn_amt / 1000000000000 . " XMR but the remaining balance is still $currency_symbol$money_balance. Please send the remaining $xmr_remaining XMR. Transaction ID: " . $txn_txid . ". Payment ID: " . $payment_id; } } } -function add_payment($command, $invoice_id, $txn_txid, $gatewaymodule, $fiat_paid, $amount_xmr, $payment_id, $fee) { +function add_payment($command, $invoice_id, $txn_txid, $gatewaymodule, $fiat_paid, $amount_xmr, $payment_id, $fee, $client_id) { + $GATEWAY = getGatewayVariables($gatewaymodule); + $postData = array( 'action' => $command, 'invoiceid' => $invoice_id, @@ -105,10 +145,23 @@ function add_payment($command, $invoice_id, $txn_txid, $gatewaymodule, $fiat_pai 'paymentid' => $payment_id, 'fees' => $fee, ); - // Add the invoice payment - either of the next two lines work + // Add the invoice payment - either line below would work // $results = localAPI($command, $postData, $adminUsername); addInvoicePayment($invoice_id,$txn_txid,$fiat_paid,$fee,$gatewaymodule); logTransaction($gatewaymodule, $postData, "Success: ".$message); + + + $bonus_percent = $GATEWAY['bonus_percentage']; + + if ($bonus_percent > 0) { + $command = 'AddCredit'; + $postData = array( + 'clientid' => $client_id, + 'description' => "Bonus Credit for paying with Monero on Invoice #$invoice_id via txid $txn_txid", + 'amount' => money_format('%i', $fiat_paid * ($bonus_percent / 100)), + ); + $results = localAPI($command, $postData, $adminUsername); + } } @@ -123,5 +176,6 @@ function stop_payment($payment_id, $amount, $invoice_id, $fee, $link){ } } */ -$vefiry = verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $status, $gatewaymodule, $hash, $secretKey, $currency); + +$vefiry = verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $status, $gatewaymodule, $hash, $secretKey, $currency, $client_id); echo $vefiry; From 6324470e5b2fbc4106514aa0d15c7fc4a9b756f6 Mon Sep 17 00:00:00 2001 From: apezio Date: Thu, 8 Mar 2018 12:31:39 -0800 Subject: [PATCH 4/6] Fixed multiple invoice cookie bug Now each invoice has it's own cookie for the payment_id. Previously client payments would be applied to any invoice the client opened. --- modules/gateways/monero/createinvoice.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/gateways/monero/createinvoice.php b/modules/gateways/monero/createinvoice.php index 010e86d..6c4c736 100644 --- a/modules/gateways/monero/createinvoice.php +++ b/modules/gateways/monero/createinvoice.php @@ -16,15 +16,15 @@ $link = $GATEWAY['daemon_host'].":".$GATEWAY['daemon_port']."/json_rpc"; -function monero_payment_id(){ - if(!isset($_COOKIE['payment_id'])) { +function monero_payment_id($invoice_id){ + if(!isset($_COOKIE["payment_id$invoice_id"])) { $payment_id = bin2hex(openssl_random_pseudo_bytes(8)); - setcookie('payment_id', $payment_id, time()+2700); + // create one cookie per invoice_id. + setcookie("payment_id$invoice_id", $payment_id, time()+2700); } else { - $payment_id = $_COOKIE['payment_id']; + $payment_id = $_COOKIE["payment_id$invoice_id"]; } return $payment_id; - } $monero_daemon = new Monero_rpc($link); @@ -34,8 +34,9 @@ function monero_payment_id(){ $currency = stripslashes($_POST['currency']); $amount_xmr = stripslashes($_POST['amount_xmr']); $amount = stripslashes($_POST['amount']); -$payment_id = monero_payment_id(); $invoice_id = stripslashes($_POST['invoice_id']); +$client_id = stripslashes($_POST['client_id']); +$payment_id = monero_payment_id($invoice_id); $array_integrated_address = $monero_daemon->make_integrated_address($payment_id); $address = $array_integrated_address['integrated_address']; $uri = "monero:$address?amount=$amount_xmr"; @@ -127,7 +128,7 @@ className: 'spinner', // The CSS class to assign to the spinner $.ajax({ url : 'verify.php', type : 'POST', - data: { 'amount_xmr' : '".$amount_xmr."', 'payment_id' : '".$payment_id."', 'invoice_id' : '".$invoice_id."', 'amount' : '".$amount."', 'hash' : '".$hash."', 'currency' : '".$currency."'}, + data: { 'amount_xmr' : '".$amount_xmr."', 'payment_id' : '".$payment_id."', 'invoice_id' : '".$invoice_id."', 'amount' : '".$amount."', 'hash' : '".$hash."', 'currency' : '".$currency."', 'client_id' : '".$client_id."'}, success: function(msg) { console.log(msg); $('#message').text(msg); From 9e7f97c10a8f0345676a57e2fab1bd05f398ae0f Mon Sep 17 00:00:00 2001 From: apezio <8996860+apezio@users.noreply.github.com> Date: Wed, 9 Oct 2024 07:54:00 -1000 Subject: [PATCH 5/6] Checked compatibility with WHMCS 8.2, ensured changes wouldn't overwrite existing files, and reviewed for potential issues with PHP version and module usage in WHMCS 8.2. --- modules/gateways/monero.php | 27 ++++++----------- modules/gateways/monero/createinvoice.php | 14 ++++----- modules/gateways/monero/library.php | 12 +++++--- modules/gateways/monero/verify.php | 37 ++++++----------------- 4 files changed, 33 insertions(+), 57 deletions(-) diff --git a/modules/gateways/monero.php b/modules/gateways/monero.php index a1b7d2c..c96f310 100644 --- a/modules/gateways/monero.php +++ b/modules/gateways/monero.php @@ -2,18 +2,18 @@ if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } - - +use WHMCS\Database\Capsule; function monero_MetaData() { return array( 'DisplayName' => 'Monero', - 'APIVersion' => '1.1', // Use API Version 1.1 + 'APIVersion' => '1.1', // Use API Version 1.1 (compatible with WHMCS 8.2) 'DisableLocalCredtCardInput' => true, 'TokenisedStorage' => false, ); } + function monero_Config(){ return array( 'FriendlyName' => array('Type' => 'System','Value' => 'Monero'), @@ -27,22 +27,13 @@ function monero_Config(){ ); } -/* -* -* Get the current XMR price in several currencies -* -* @param String $currencies List of currency codes separated by comma -* -* @return String A json string in the format {"CURRENCY_CODE":PRICE} -* -*/ function monero_retrivePriceList($currencies = 'BTC,USD,EUR,CAD,INR,GBP,BRL') { $source = 'https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms='.$currencies.'&extraParams=monero_woocommerce'; if (ini_get('allow_url_fopen')) { - return file_get_contents($source); + return @file_get_contents($source); } @@ -77,6 +68,7 @@ function monero_retrivePriceList($currencies = 'BTC,USD,EUR,CAD,INR,GBP,BRL') { return $xmr_price; } + function monero_retriveprice($currency) { global $currency_symbol; $xmr_price = monero_retrivePriceList('BTC,USD,EUR,CAD,INR,GBP,BRL'); @@ -114,7 +106,6 @@ function monero_retriveprice($currency) { } } - function monero_changeto($amount, $currency){ $xmr_live_price = monero_retriveprice($currency); $live_for_storing = $xmr_live_price * 100; //This will remove the decimal so that it can easily be stored as an integer @@ -132,7 +123,7 @@ function xmr_to_fiat($amount, $currency){ } function monero_link($params){ -global $currency_symbol; +$currency_symbol = ''; $gatewaymodule = "monero"; $gateway = getGatewayVariables($gatewaymodule); @@ -143,8 +134,8 @@ function monero_link($params){ $amount = $params['amount']; $bonus_setting = $gateway['bonus_percentage']; - $bonus_percentage = 100 - (preg_replace("/[^0-9]/", "", $bonus_setting)); -// $amount = money_format('%i', $amount * ($bonus_percentage / 100)); + $bonus_percentage = preg_replace("/[^0-9]/", "", $bonus_setting); + $amount = number_format($amount * (1 + $bonus_percentage / 100), 2, '.', ''); $currency = $params['currency']; $client_id = $params['clientdetails']['id']; $firstname = $params['clientdetails']['firstname']; @@ -183,7 +174,7 @@ function monero_link($params){ $form .= ''; $form .= '

'.$amount_xmr. " XMR (". $currency_symbol . $amount . " " . $currency .')

'; if ($bonus_setting > 0) { - $form .='

Bonus to be applied: ' . preg_replace("/[^0-9]/", "", $bonus_setting) . '%

'; + $form .='

Bonus to be applied: ' . $bonus_percentage . '%

'; } return $form; } diff --git a/modules/gateways/monero/createinvoice.php b/modules/gateways/monero/createinvoice.php index 6c4c736..4f26018 100644 --- a/modules/gateways/monero/createinvoice.php +++ b/modules/gateways/monero/createinvoice.php @@ -1,8 +1,9 @@ "; -?> diff --git a/modules/gateways/monero/library.php b/modules/gateways/monero/library.php index ec025da..fae644a 100644 --- a/modules/gateways/monero/library.php +++ b/modules/gateways/monero/library.php @@ -1,4 +1,6 @@ '503 Service Unavailable' ); - public function __construct($pUrl, $pUser = null, $pPass = null) { + public function __construct($pUrl = null, $pUser = null, $pPass = null) { $gatewayx = getGatewayVariables("monero"); - $this->validate(false === extension_loaded('curl'), 'The curl extension must be loaded for using this class!'); - $this->validate(false === extension_loaded('json'), 'The json extension must be loaded for using this class!'); + $this->validate(!extension_loaded('curl'), 'The curl extension must be loaded for using this class!'); + $this->validate(!extension_loaded('json'), 'The json extension must be loaded for using this class!'); $this->url = $gatewayx['daemon_host']. ":" .$gatewayx['daemon_port'] . "/json_rpc"; $this->username = $gatewayx['daemon_user']; $this->password = $gatewayx['daemon_pass']; @@ -344,4 +346,4 @@ public function get_bulk_payments($payment_id, $min_block_height) $get_bulk_payments = $this->_run('get_bulk_payments', $get_bulk_payments_parameters); return $get_bulk_payments; } -} +} diff --git a/modules/gateways/monero/verify.php b/modules/gateways/monero/verify.php index da9269b..0330981 100644 --- a/modules/gateways/monero/verify.php +++ b/modules/gateways/monero/verify.php @@ -1,11 +1,10 @@ get_payments($payment_id); foreach ($get_payments_method["payments"] as $tx => $transactions) { $txn_amt = $transactions["amount"]; - $txn_txid = $transactions["tx_hash"]; + $txn_txid = $transactions["txid"]; $txn_payment_id = $transactions["payment_id"]; if(isset($txn_amt)) { return handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_payment_id, $payment_id, $currency, $gatewaymodule, $client_id); @@ -123,7 +120,7 @@ function handle_whmcs($invoice_id, $amount_xmr, $txn_amt, $txn_txid, $txn_paymen $results = localAPI("UpdateInvoice", $postData, $adminUsername); return "Payment has been received."; } - $money_balance = money_format('%i', $invoice_balance); + $money_balance = number_format($invoice_balance, 2, '.', ''); $xmr_remaining = monero_changeto($money_balance, $currency); return "Error: We received " . $txn_amt / 1000000000000 . " XMR but the remaining balance is still $currency_symbol$money_balance. Please send the remaining $xmr_remaining XMR. Transaction ID: " . $txn_txid . ". Payment ID: " . $payment_id; @@ -145,9 +142,7 @@ function add_payment($command, $invoice_id, $txn_txid, $gatewaymodule, $fiat_pai 'paymentid' => $payment_id, 'fees' => $fee, ); - // Add the invoice payment - either line below would work - // $results = localAPI($command, $postData, $adminUsername); - addInvoicePayment($invoice_id,$txn_txid,$fiat_paid,$fee,$gatewaymodule); + addInvoicePayment($invoice_id, $txn_txid, $fiat_paid, $fee, $gatewaymodule); logTransaction($gatewaymodule, $postData, "Success: ".$message); @@ -158,24 +153,12 @@ function add_payment($command, $invoice_id, $txn_txid, $gatewaymodule, $fiat_pai $postData = array( 'clientid' => $client_id, 'description' => "Bonus Credit for paying with Monero on Invoice #$invoice_id via txid $txn_txid", - 'amount' => money_format('%i', $fiat_paid * ($bonus_percent / 100)), + 'amount' => number_format($fiat_paid * ($bonus_percent / 100), 2, '.', ''), ); $results = localAPI($command, $postData, $adminUsername); } } -/* -function stop_payment($payment_id, $amount, $invoice_id, $fee, $link){ - $verify = verify_payment($payment_id, $amount, $invoice_id, $fee, $link); - if($verify){ - $message = "Payment has been received and confirmed."; - } - else{ - $message = "We are waiting for your payment to be confirmed"; - } -} */ - - $vefiry = verify_payment($payment_id, $amount, $amount_xmr, $invoice_id, $fee, $status, $gatewaymodule, $hash, $secretKey, $currency, $client_id); echo $vefiry; From 2a6aff7b9a6a7dba77eae9c98720d10d851d197c Mon Sep 17 00:00:00 2001 From: apezio <8996860+apezio@users.noreply.github.com> Date: Wed, 9 Oct 2024 08:03:26 -1000 Subject: [PATCH 6/6] Confirmed project compatibility with WHMCS 8.2. --- modules/addons/hooks.php | 14 +++++++------- modules/addons/moneroenable.php | 2 +- modules/gateways/monero.php | 12 ++++++------ modules/gateways/monero/createinvoice.php | 8 ++------ modules/gateways/monero/verify.php | 4 ++-- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/modules/addons/hooks.php b/modules/addons/hooks.php index 950b249..a497914 100644 --- a/modules/addons/hooks.php +++ b/modules/addons/hooks.php @@ -3,16 +3,16 @@ if (!defined("WHMCS")) die("This file cannot be accessed directly"); -use Illuminate\Database\Capsule\Manager as Capsule; +use WHMCS\Database\Capsule as Capsule; // skip checking for fraud order function moneroEnable ( $vars ) { - $opt1 = Capsule::select("SELECT `value` FROM tbladdonmodules WHERE module = 'moneroEnable' AND setting = 'option1' LIMIT 1")[0]->value; - $opt2 = Capsule::select("SELECT `value` FROM tbladdonmodules WHERE module = 'moneroEnable' AND setting = 'option2' LIMIT 1")[0]->value; - if($opt1 == 'on' && $opt2 > '' && $vars['orderid'] > '') { - $pmtMet = Capsule::select("SELECT paymentmethod FROM tblorders WHERE id = ".$vars['orderid'])[0]->paymentmethod; - if($pmtMet > '') { - if($pmtMet == $opt2) return true; + $option1 = Capsule::select("SELECT `value` FROM tbladdonmodules WHERE module = 'moneroEnable' AND setting = 'option1' LIMIT 1")[0]->value; + $option2 = Capsule::select("SELECT `value` FROM tbladdonmodules WHERE module = 'moneroEnable' AND setting = 'option2' LIMIT 1")[0]->value; + if($option1 == 'on' && $option2 > '' && $vars['orderid'] > '') { + $paymentMethod = Capsule::select("SELECT paymentmethod FROM tblorders WHERE id = ".$vars['orderid'])[0]->paymentmethod; + if($paymentMethod > '') { + if($paymentMethod == $option2) return true; } } } diff --git a/modules/addons/moneroenable.php b/modules/addons/moneroenable.php index 9940b65..69cf7c8 100644 --- a/modules/addons/moneroenable.php +++ b/modules/addons/moneroenable.php @@ -1,6 +1,6 @@ 'Monero', - 'APIVersion' => '1.1', // Use API Version 1.1 (compatible with WHMCS 8.2) + 'APIVersion' => '1.1', // Use API Version 1.1 'DisableLocalCredtCardInput' => true, 'TokenisedStorage' => false, ); @@ -81,7 +81,7 @@ function monero_retriveprice($currency) { return $price['USD']; } if ($currency == 'EUR') { - $currency_symbol = "€"; + $currency_symbol = "â¬"; return $price['EUR']; } if ($currency == 'CAD'){ @@ -89,11 +89,11 @@ function monero_retriveprice($currency) { return $price['CAD']; } if ($currency == 'GBP'){ - $currency_symbol = "£"; + $currency_symbol = "£"; return $price['GBP']; } if ($currency == 'INR'){ - $currency_symbol = "₹"; + $currency_symbol = "â¹"; return $price['INR']; } if ($currency == 'BRL'){ @@ -173,7 +173,7 @@ function monero_link($params){ $form .= ''; $form .= ''; $form .= '

'.$amount_xmr. " XMR (". $currency_symbol . $amount . " " . $currency .')

'; - if ($bonus_setting > 0) { + if ($bonus_percentage > 0) { $form .='

Bonus to be applied: ' . $bonus_percentage . '%

'; } return $form; diff --git a/modules/gateways/monero/createinvoice.php b/modules/gateways/monero/createinvoice.php index 4f26018..a260656 100644 --- a/modules/gateways/monero/createinvoice.php +++ b/modules/gateways/monero/createinvoice.php @@ -1,13 +1,9 @@ "UpdateInvoice", 'invoiceid' => $invoice_id,