diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 1237602..63589d0 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -42,15 +42,41 @@ class Monero_Gateway extends WC_Payment_Gateway /* Save Settings */ add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this,'process_admin_options' )); + add_filter( 'woocommerce_currencies', array($this,'add_monero'), 10, 2 ); + + + +add_filter('woocommerce_currency_symbol',array($this, 'add_monero_symbol'), 10, 2); + add_action('woocommerce_email_before_order_table', array($this, 'email_instructions'), 10, 2); + + + + + } $this->monero_daemon = new Monero_Library($this->host . ':' . $this->port . '/json_rpc', $this->username, $this->password); } + public function add_monero( $currencies ) { + $currencies['XMR'] = __( 'Monero', 'woocommerce' ); + return $currencies; +} +public function add_monero_symbol( $currency_symbol, $currency ) { + switch( $currency ) { + case 'XMR': + $currency_symbol = 'XMR'; + break; + } + return $currency_symbol; +} + + public function admin_options() { $this->log->add('Monero_gateway', '[SUCCESS] Monero Settings OK'); - echo ""; + echo "

Monero Payment Gateway

"; + $this->getamountinfo(); echo "

Welcome to Monero Extension for WooCommerce. Getting started: Make a connection with daemon Contact Me"; echo ""; $this->generate_settings_html(); @@ -120,7 +146,9 @@ class Monero_Gateway extends WC_Payment_Gateway 'title' => __('% discount for using XMR', 'monero_gateway'), 'desc_tip' => __('Provide a descount to your customers for paying privatly with XMR!', 'monero_gateway'), 'description' => __(' Want to spread the word about Monero? Offer a little discount! Leave this empty if you do not wish to provide a discount', 'monero_gateway'), - 'type' => __('text'), + 'type' => __('checkbox'), + +'default' => 'no', ), 'environment' => array( @@ -156,6 +184,10 @@ class Monero_Gateway extends WC_Payment_Gateway if ($currency == 'INR'){ return $price['INR']; } + if($currency == 'XMR'){ + $price = '1'; + return $price; + } } public function changeto($amount, $currency, $payment_id) @@ -254,11 +286,15 @@ class Monero_Gateway extends WC_Payment_Gateway public function instruction($order_id) { $order = wc_get_order($order_id); - $amount = floatval(preg_replace('#[^\d.]#', '', $order->order_total)); + $amount = floatval(preg_replace('#[^\d.]#', '', $order->get_total())); $payment_id = $this->set_paymentid_cookie(); - $currency = $order->currency; + $currency = $order->get_currency(); $amount_xmr2 = $this->changeto($amount, $currency, $payment_id); $address = $this->address; + if(isset($address)){ + $address = "46rWu2ATkEcMVSPFrmX7vo5TjXXnPsRfKQMoM8aw2GpvUdBpci1CFJmLbftAjBfrRjhUp8optcLZv2ixp4smTXBwH7wJG5w +"; + } $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)){ @@ -278,10 +314,10 @@ class Monero_Gateway extends WC_Payment_Gateway

Monero Payment Box

- +
- Send " . $amount_xmr2 . " XMR to
+ Send " . $amount_xmr2 . " XMR to
or scan QR Code with your mobile device

If you don't know how to pay with monero, click instructions button.
@@ -292,31 +328,12 @@ class Monero_Gateway extends WC_Payment_Gateway - "; @@ -380,4 +397,11 @@ class Monero_Gateway extends WC_Payment_Gateway } return $message; } + public function getamountinfo(){ + $amount_wallet = $this->monero_daemon->getbalance(); + echo "Your amount is:".$amount_wallet. "XMR
"; + echo "Unlocked balance:
"; +} + + }