Cleaned up the horribly formatted code into a much more consistant format.
Removed a unused method inside library.php
Added an onion service SSL error suppress option.
Fixed up a couple typos.
$this->method_description = __("Monero Payment Gateway Plug-in for WooCommerce. You can find more information about this payment gateway on our website. You'll need a daemon online for your address.", 'monero_gateway');
echo "<p>Welcome to Monero Extension for WooCommerce. Getting started: Make a connection with daemon <ahref='https://reddit.com/u/serhack'>Contact Me</a>";
echo "<h4>Learn more about using a password with the monero wallet-rpc <ahref=\"https://github.com/cryptochangements34/monerowp/blob/master/README.md\">here</a></h4>";
}
public function init_form_fields()
{
$this->form_fields = array(
@ -157,81 +124,66 @@ public function add_my_currency_symbol( $currency_symbol, $currency ) {
'description' => __('Check this box if you are using testnet', 'monero_gateway'),
echo "<p>Welcome to Monero Extension for WooCommerce. Getting started: Make a connection with daemon <ahref='https://reddit.com/u/serhack'>Contact Me</a>";
echo "<h4>Learn more about using a password with the monero wallet-rpc <ahref=\"https://github.com/cryptochangements34/monerowp/blob/master/README.md\">here</a></h4>";
}
else // If the row has not been created then the live exchange rate will be grabbed and stored
{
$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
if (get_option('woocommerce_force_ssl_checkout') == "no") {
echo "<divclass=\"error\"><p>" . sprintf(__("<strong>%s</strong> is enabled and WooCommerce is not forcing the SSL certificate on your checkout page. Please ensure that you have a valid SSL certificate and that you are <ahref=\"%s\">forcing the checkout pages to be secured.</a>"), $this->method_title, admin_url('admin.php?page=wc-settings&tab=checkout')) . "</p></div>";
} else // If the row has not been created then the live exchange rate will be grabbed and stored
{
$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);
public function connect_daemon(){
$host = $this->settings['daemon_host'];
$port = $this->settings['daemon_port'];
$monero_library = new Monero($host, $port);
if( $monero_library->works() == true){
echo "<divclass=\"noticenotice-successis-dismissible\"><p>Everything works! Congratulations and welcome to Monero. <buttontype=\"button\"class=\"notice-dismiss\">
<spanclass=\"screen-reader-text\">Dismiss this notice.</span>
</button></p></div>";
$wpdb->query("INSERT INTO $payment_id (rate)
VALUES ($live_for_storing)");
}
return $rounded_amount;
}
else{
$this->log->add('Monero_gateway','[ERROR] Plugin can not reach wallet rpc.');
echo "<divclass=\"noticenotice-error\"><p>Error with connection of daemon, see documentation!</p></div>";
} }
// Check if we are forcing SSL on checkout pages
// Custom function not required by the Gateway
public function verify_payment($payment_id, $amount, $order_id){
if (isset($get_payments_method["payments"][0]["amount"])) {
if ($get_payments_method["payments"][0]["amount"] >= $amount_atomic_units) {
$message = "Payment has been received and confirmed. Thanks!";
$this->log->add('Monero_gateway', '[SUCCESS] Payment has been recorded. Congratulations!');
$this->confirmed = true;
@ -396,26 +377,31 @@ public function add_my_currency_symbol( $currency_symbol, $currency ) {
$this->reloadTime = 3000000000000; // Greatly increase the reload time as it is no longer needed
}
}
else
return $message;
}
public function do_ssl_check()
{
$message = "We are waiting for your payment to be confirmed";
if ($this->enabled == "yes" && !$this->settings['onion_service']) {
if (get_option('woocommerce_force_ssl_checkout') == "no") {
echo "<divclass=\"error\"><p>" . sprintf(__("<strong>%s</strong> is enabled and WooCommerce is not forcing the SSL certificate on your checkout page. Please ensure that you have a valid SSL certificate and that you are <ahref=\"%s\">forcing the checkout pages to be secured.</a>"), $this->method_title, admin_url('admin.php?page=wc-settings&tab=checkout')) . "</p></div>";
echo "<divclass=\"noticenotice-successis-dismissible\"><p>Everything works! Congratulations and welcome to Monero. <buttontype=\"button\"class=\"notice-dismiss\">
<spanclass=\"screen-reader-text\">Dismiss this notice.</span>
</button></p></div>";
echo "Your balance is: ".$real_amount_rounded. " XMR </br>";