Switching to Coingecko API, general bug fixing
This commit is contained in:
		
							parent
							
								
									572f04dfba
								
							
						
					
					
						commit
						bf9e24459f
					
				@ -35,7 +35,7 @@ class Monero_Gateway extends WC_Payment_Gateway
 | 
				
			|||||||
    private static $monero_explorer_tools;
 | 
					    private static $monero_explorer_tools;
 | 
				
			||||||
    private static $log;
 | 
					    private static $log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static $currencies = array('BTC','USD','EUR','CAD','INR','GBP','COP','SGD','JPY');
 | 
					    private static $currencies = array('AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTC', 'BTN', 'BWP', 'BYN', 'BYR', 'BZD', 'CAD', 'CDF', 'CHF', 'CLF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GGP', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'IMP', 'INR', 'IQD', 'IRR', 'ISK', 'JEP', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'STD', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XCD', 'XDR', 'XOF', 'XPF', 'YER', 'ZAR', 'ZMK', 'ZMW', 'ZWL');
 | 
				
			||||||
    private static $rates = array();
 | 
					    private static $rates = array();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static $payment_details = array();
 | 
					    private static $payment_details = array();
 | 
				
			||||||
@ -275,7 +275,7 @@ class Monero_Gateway extends WC_Payment_Gateway
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Get Live Price
 | 
					        // Get Live Price
 | 
				
			||||||
        $currencies = implode(',', self::$currencies);
 | 
					        $currencies = implode(',', self::$currencies);
 | 
				
			||||||
        $api_link = 'https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms='.$currencies.'&extraParams=monero_woocommerce';
 | 
					        $api_link = 'https://api.coingecko.com/api/v3/simple/price?ids=monero&vs_currencies='.$currencies;
 | 
				
			||||||
        $curl = curl_init();
 | 
					        $curl = curl_init();
 | 
				
			||||||
        curl_setopt_array($curl, array(
 | 
					        curl_setopt_array($curl, array(
 | 
				
			||||||
            CURLOPT_RETURNTRANSFER => 1,
 | 
					            CURLOPT_RETURNTRANSFER => 1,
 | 
				
			||||||
@ -285,23 +285,23 @@ class Monero_Gateway extends WC_Payment_Gateway
 | 
				
			|||||||
        curl_close($curl);
 | 
					        curl_close($curl);
 | 
				
			||||||
        $price = json_decode($resp, true);
 | 
					        $price = json_decode($resp, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!isset($price['Response']) || $price['Response'] != 'Error') {
 | 
					        if(isset($price)) {
 | 
				
			||||||
            $table_name = $wpdb->prefix.'monero_gateway_live_rates';
 | 
					            $table_name = $wpdb->prefix.'monero_gateway_live_rates';
 | 
				
			||||||
            foreach($price as $currency=>$rate) {
 | 
					            foreach($price['monero'] as $currency=>$rate) {
 | 
				
			||||||
                // shift decimal eight places for precise int storage
 | 
					                // shift decimal eight places for precise int storage
 | 
				
			||||||
                $rate = intval($rate * 1e8);
 | 
					                $rate = intval($rate * 1e8);
 | 
				
			||||||
                $query = $wpdb->prepare("INSERT INTO `$table_name` (currency, rate, updated) VALUES (%s, %d, NOW()) ON DUPLICATE KEY UPDATE rate=%d, updated=NOW()", array( $currency, $rate, $rate));
 | 
					                $query = $wpdb->prepare("INSERT INTO $table_name (currency, rate, updated) VALUES (%s, %d, NOW()) ON DUPLICATE KEY UPDATE rate=%d, updated=NOW()", array($currency, $rate, $rate));
 | 
				
			||||||
                $result = $wpdb->query($query);
 | 
					                $result = $wpdb->query($query);
 | 
				
			||||||
                if(!$result){
 | 
					              	if(!$result){
 | 
				
			||||||
                    self::$log->add('Monero_Payments', "[ERROR] Impossible to write DB. Please check your DB connection or enable Debugging.");
 | 
					                    self::$log->add('Monero_Payments', "[ERROR] Impossible to write DB. Please check your DB connection or enable Debugging.");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else{
 | 
					        else{
 | 
				
			||||||
             self::$log->add('Monero_Payments', "[ERROR] Unable to fetch prices from cryptocompare.com.");
 | 
					             self::$log->add('Monero_Payments', "[ERROR] Unable to fetch prices from coingecko.com.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Get current network/wallet height
 | 
					        // Get current network/wallet height
 | 
				
			||||||
        if(self::$confirm_type == 'monero-wallet-rpc')
 | 
					        if(self::$confirm_type == 'monero-wallet-rpc')
 | 
				
			||||||
            $height = self::$monero_wallet_rpc->getheight();
 | 
					            $height = self::$monero_wallet_rpc->getheight();
 | 
				
			||||||
 | 
				
			|||||||
@ -3,8 +3,8 @@
 | 
				
			|||||||
Plugin Name: Monero Woocommerce Gateway
 | 
					Plugin Name: Monero Woocommerce Gateway
 | 
				
			||||||
Plugin URI: https://github.com/monero-integrations/monerowp
 | 
					Plugin URI: https://github.com/monero-integrations/monerowp
 | 
				
			||||||
Description: Extends WooCommerce by adding a Monero Gateway
 | 
					Description: Extends WooCommerce by adding a Monero Gateway
 | 
				
			||||||
Version: 3.0.1
 | 
					Version: 3.0.5
 | 
				
			||||||
Tested up to: 4.9.8
 | 
					Tested up to: 5.7.2
 | 
				
			||||||
Author: mosu-forge, SerHack
 | 
					Author: mosu-forge, SerHack
 | 
				
			||||||
Author URI: https://monerointegrations.com/
 | 
					Author URI: https://monerointegrations.com/
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										33
									
								
								readme.txt
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								readme.txt
									
									
									
									
									
								
							@ -1,9 +1,9 @@
 | 
				
			|||||||
=== Monero WooCommerce Extension ===
 | 
					=== Monero WooCommerce Extension ===
 | 
				
			||||||
Contributors: SerHack, mosu-forge
 | 
					Contributors: serhack, mosu-forge and Monero Integrations contributors
 | 
				
			||||||
Donate link: http://monerointegrations.com/donate.html
 | 
					Donate link: http://monerointegrations.com/donate.html
 | 
				
			||||||
Tags: monero, woocommerce, integration, payment, merchant, cryptocurrency, accept monero, monero woocommerce
 | 
					Tags: monero, woocommerce, integration, payment, merchant, cryptocurrency, accept monero, monero woocommerce
 | 
				
			||||||
Requires at least: 4.0
 | 
					Requires at least: 4.0
 | 
				
			||||||
Tested up to: 5.0.1
 | 
					Tested up to: 5.7.2
 | 
				
			||||||
Stable tag: trunk
 | 
					Stable tag: trunk
 | 
				
			||||||
License: MIT license
 | 
					License: MIT license
 | 
				
			||||||
License URI: https://github.com/monero-integrations/monerowp/blob/master/LICENSE
 | 
					License URI: https://github.com/monero-integrations/monerowp/blob/master/LICENSE
 | 
				
			||||||
@ -61,7 +61,7 @@ Once you installed and activated WooCommerce, you may install and activate Moner
 | 
				
			|||||||
* Bug fixing
 | 
					* Bug fixing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
= 3.0.0 =
 | 
					= 3.0.0 =
 | 
				
			||||||
Huge shoutout to mosu-forge who contributes a lot to make 3.0 possible.
 | 
					Huge shoutout to mosu-forge who contributed a lot to make 3.0 possible.
 | 
				
			||||||
* Ability to set number of confirms: 0 for zero conf, up to 60.
 | 
					* Ability to set number of confirms: 0 for zero conf, up to 60.
 | 
				
			||||||
* Amount owed in XMR gets locked in after the order for a configurable amount of time after which the order is invalid, default 60 minutes.
 | 
					* Amount owed in XMR gets locked in after the order for a configurable amount of time after which the order is invalid, default 60 minutes.
 | 
				
			||||||
* Shows transactions received along with the number of confirms right on the order success page, auto-updates through AJAX.
 | 
					* Shows transactions received along with the number of confirms right on the order success page, auto-updates through AJAX.
 | 
				
			||||||
@ -72,6 +72,20 @@ Huge shoutout to mosu-forge who contributes a lot to make 3.0 possible.
 | 
				
			|||||||
* Live prices are also run via cron, shortcodes for showing exchange rates.
 | 
					* Live prices are also run via cron, shortcodes for showing exchange rates.
 | 
				
			||||||
* Properly hooks into order confirmation email page.
 | 
					* Properly hooks into order confirmation email page.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					= 3.0.1 =
 | 
				
			||||||
 | 
					* Fixed the incorrect generation of integrated addresses;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					= 3.0.2 =
 | 
				
			||||||
 | 
					* Fixed the problem of 'hard-coded' prices which causes a division by zero: now any currencies supported by cryptocompare API should work;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					= 3.0.3 =
 | 
				
			||||||
 | 
					* Fixed the problem related to explorer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					= 3.0.4 =
 | 
				
			||||||
 | 
					* Bug fixing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					= 3.0.5 =
 | 
				
			||||||
 | 
					* Removed cryptocompare.com API and switched to CoinGecko
 | 
				
			||||||
 | 
					
 | 
				
			||||||
== Upgrade Notice ==
 | 
					== Upgrade Notice ==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -79,15 +93,4 @@ soon
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
== Frequently Asked Questions ==
 | 
					== Frequently Asked Questions ==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* What is Monero ?
 | 
					soon
 | 
				
			||||||
Monero is completely private, cryptographically secure, digital cash used across the globe. See https://getmonero.org for more information
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* What is a Monero wallet?
 | 
					 | 
				
			||||||
A Monero wallet is a piece of software that allows you to store your funds and interact with the Monero network. You can get a Monero wallet from https://getmonero.org/downloads
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* What is monero-wallet-rpc ?
 | 
					 | 
				
			||||||
The monero-wallet-rpc is an RPC server that will allow this plugin to communicate with the Monero network. You can download it from https://getmonero.org/downloads with the command-line tools.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why do I see `[ERROR] Failed to connect to monero-wallet-rpc at localhost port 18080
 | 
					 | 
				
			||||||
Syntax error: Invalid response data structure: Request id: 1 is different from Response id: ` ?
 | 
					 | 
				
			||||||
This is most likely because this plugin can not reach your monero-wallet-rpc. Make sure that you have supplied the correct host IP and port to the plugin in their fields. If your monero-wallet-rpc is on a different server than your wordpress site, make sure that the appropriate port is open with port forwarding enabled.
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user