Compare commits
10 Commits
acfdc094da
...
53612dccaa
Author | SHA1 | Date | |
---|---|---|---|
|
53612dccaa | ||
|
9ba2b640f7 | ||
|
d3bebc45bf | ||
|
6f8ed354e5 | ||
|
a73fc48538 | ||
|
99d57f94ae | ||
|
bf9e24459f | ||
|
572f04dfba | ||
|
9f0a8581e6 | ||
|
2e6ec376a2 |
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
@ -20,6 +20,12 @@
|
||||
|
||||
## Installing the plugin
|
||||
|
||||
### Automatic Method
|
||||
|
||||
In the "Add Plugins" section of the WordPress admin UI, search for "monero" and click the Install Now button next to "Monero WooCommerce Extension" by mosu-forge, SerHack. This will enable auto-updates, but only for official releases, so if you need to work from git master or your local fork, please use the manual method below.
|
||||
|
||||
### Manual Method
|
||||
|
||||
* Download the plugin from the [releases page](https://github.com/monero-integrations/monerowp) or clone with `git clone https://github.com/monero-integrations/monerowp`
|
||||
* Unzip or place the `monero-woocommerce-gateway` folder in the `wp-content/plugins` directory.
|
||||
* Activate "Monero Woocommerce Gateway" in your WordPress admin dashboard.
|
||||
|
@ -35,7 +35,7 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
private static $monero_explorer_tools;
|
||||
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 $payment_details = array();
|
||||
@ -228,15 +228,25 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
$payment_id = $payment_id['address'];
|
||||
}
|
||||
else {
|
||||
$this->log->add('Monero_Gateway', 'Couldn\'t create subaddress for order ' . $order_id);
|
||||
self::$log->add('Monero_Gateway', 'Couldn\'t create subaddress for order ' . $order_id);
|
||||
}
|
||||
}
|
||||
|
||||
$currency = $order->get_currency();
|
||||
$rate = self::get_live_rate($currency);
|
||||
$fiat_amount = $order->get_total('');
|
||||
$monero_amount = 1e8 * $fiat_amount / $rate;
|
||||
|
||||
|
||||
if($rate != 0)
|
||||
$monero_amount = 1e8 * $fiat_amount / $rate;
|
||||
else{
|
||||
// Critical, the price has not been retrivied.
|
||||
$monero_amount = -1;
|
||||
$error_message = "The price for Monero could not be retrieved. Please contact the merchant.";
|
||||
self::$log->add('Monero_Payments', "[ERROR] Impossible to retrieve price for order: ".$order_id);
|
||||
wc_add_notice( __('Payment error:', 'woothemes') . $error_message, 'error' );
|
||||
return;
|
||||
}
|
||||
|
||||
if(self::$discount)
|
||||
$monero_amount = $monero_amount - $monero_amount * self::$discount / 100;
|
||||
|
||||
@ -246,7 +256,7 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
$wpdb->query($query);
|
||||
|
||||
$order->update_status('on-hold', __('Awaiting offline payment', 'monero_gateway'));
|
||||
$order->reduce_order_stock(); // Reduce stock levels
|
||||
wc_reduce_stock_levels( $order_id );
|
||||
WC()->cart->empty_cart(); // Remove cart
|
||||
|
||||
return array(
|
||||
@ -265,7 +275,7 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
|
||||
// Get Live Price
|
||||
$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_setopt_array($curl, array(
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
@ -275,19 +285,23 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
curl_close($curl);
|
||||
$price = json_decode($resp, true);
|
||||
|
||||
if(!isset($price['Response']) || $price['Response'] != 'Error') {
|
||||
if(isset($price)) {
|
||||
$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
|
||||
$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));
|
||||
$wpdb->query($query);
|
||||
$result = $wpdb->query($query);
|
||||
if(!$result){
|
||||
self::$log->add('Monero_Payments', "[ERROR] Impossible to write DB. Please check your DB connection or enable Debugging.");
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
if(self::$confirm_type == 'monero-wallet-rpc')
|
||||
$height = self::$monero_wallet_rpc->getheight();
|
||||
@ -591,26 +605,29 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
$user = wp_get_current_user();
|
||||
if($user === 0)
|
||||
self::ajax_output(array('error' => '[ERROR] User not logged in'));
|
||||
|
||||
if(isset($_GET['order_id'])){
|
||||
$order_id = preg_replace("/[^0-9]+/", "", $_GET['order_id']);
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if($order->get_customer_id() != $user->ID)
|
||||
self::ajax_output(array('error' => '[ERROR] Order does not belong to this user'));
|
||||
|
||||
$order_id = preg_replace("/[^0-9]+/", "", $_GET['order_id']);
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
if($order->get_customer_id() != $user->ID)
|
||||
self::ajax_output(array('error' => '[ERROR] Order does not belong to this user'));
|
||||
|
||||
if($order->get_payment_method() != self::$_id)
|
||||
self::ajax_output(array('error' => '[ERROR] Order not paid for with Monero'));
|
||||
|
||||
$details = self::get_payment_details($order);
|
||||
if(!is_array($details))
|
||||
self::ajax_output(array('error' => $details));
|
||||
|
||||
self::ajax_output($details);
|
||||
|
||||
if($order->get_payment_method() != self::$_id)
|
||||
self::ajax_output(array('error' => '[ERROR] Order not paid for with Monero'));
|
||||
|
||||
$details = self::get_payment_details($order);
|
||||
if(!is_array($details))
|
||||
self::ajax_output(array('error' => $details));
|
||||
|
||||
self::ajax_output($details);
|
||||
}
|
||||
}
|
||||
public static function ajax_output($response) {
|
||||
ob_clean();
|
||||
header('Content-type: application/json');
|
||||
if (ob_get_length() > 0){
|
||||
ob_clean();
|
||||
}
|
||||
echo json_encode($response);
|
||||
wp_die();
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
Plugin Name: Monero Woocommerce Gateway
|
||||
Plugin URI: https://github.com/monero-integrations/monerowp
|
||||
Description: Extends WooCommerce by adding a Monero Gateway
|
||||
Version: 3.0.1
|
||||
Tested up to: 4.9.8
|
||||
Version: 3.0.5
|
||||
Tested up to: 5.7.2
|
||||
Author: mosu-forge, SerHack
|
||||
Author URI: https://monerointegrations.com/
|
||||
*/
|
||||
@ -119,6 +119,7 @@ function monero_init() {
|
||||
// This filter will replace all prices with amount in Monero (live rates)
|
||||
add_filter('wc_price', 'monero_live_price_format', 10, 3);
|
||||
function monero_live_price_format($price_html, $price_float, $args) {
|
||||
$price_float = wc_format_decimal($price_float);
|
||||
if(!isset($args['currency']) || !$args['currency']) {
|
||||
global $woocommerce;
|
||||
$currency = strtoupper(get_woocommerce_currency());
|
||||
|
82
readme.txt
82
readme.txt
@ -1,36 +1,64 @@
|
||||
=== Monero WooCommerce Extension ===
|
||||
Contributors: SerHack, mosu-forge
|
||||
Contributors: serhack, mosu-forge and Monero Integrations contributors
|
||||
Donate link: http://monerointegrations.com/donate.html
|
||||
Tags: monero, woocommerce, integration, payment, merchant, cryptocurrency, accept monero, monero woocommerce
|
||||
Requires at least: 4.0
|
||||
Tested up to: 5.0.1
|
||||
Tested up to: 5.7.2
|
||||
Stable tag: trunk
|
||||
License: MIT license
|
||||
License URI: https://github.com/monero-integrations/monerowp/blob/master/LICENSE
|
||||
|
||||
Monero WooCommerce Extension is a Wordpress plugin that allows to accept monero at WooCommerce-powered online stores.
|
||||
|
||||
== Description ==
|
||||
|
||||
Your online store must use WooCommerce platform (free wordpress plugin).
|
||||
Once you installed and activated WooCommerce, you may install and activate Monero WooCommerce Extension.
|
||||
|
||||
= Benefits =
|
||||
|
||||
* Accept payment directly into your personal Monero wallet.
|
||||
* Accept payment in monero for physical and digital downloadable products.
|
||||
* Add monero payments option to your existing online store with alternative main currency.
|
||||
* Flexible exchange rate calculations fully managed via administrative settings.
|
||||
* Zero fees and no commissions for monero payments processing from any third party.
|
||||
* Automatic conversion to Monero via realtime exchange rate feed and calculations.
|
||||
* Ability to set exchange rate calculation multiplier to compensate for any possible losses due to bank conversions and funds transfer fees.
|
||||
* Payment validation done through either `monero-wallet-rpc` or the [xmrchain.net blockchain explorer](https://xmrchain.net/).
|
||||
* Validates payments with `cron`, so does not require users to stay on the order confirmation page for their order to validate.
|
||||
* Order status updates are done through AJAX instead of Javascript page reloads.
|
||||
* Customers can pay with multiple transactions and are notified as soon as transactions hit the mempool.
|
||||
* Configurable block confirmations, from `0` for zero confirm to `60` for high ticket purchases.
|
||||
* Live price updates every minute; total amount due is locked in after the order is placed for a configurable amount of time (default 60 minutes) so the price does not change after order has been made.
|
||||
* Hooks into emails, order confirmation page, customer order history page, and admin order details page.
|
||||
* View all payments received to your wallet with links to the blockchain explorer and associated orders.
|
||||
* Optionally display all prices on your store in terms of Monero.
|
||||
* Shortcodes! Display exchange rates in numerous currencies.
|
||||
|
||||
== Installation ==
|
||||
= Installation =
|
||||
|
||||
1. Install "Monero WooCommerce extension" wordpress plugin just like any other Wordpress plugin.
|
||||
2. Activate
|
||||
3. Configure it with your wallet rpc address, (username or password not requested), your monero address
|
||||
4. Enjoy it!
|
||||
== Automatic method ==
|
||||
|
||||
In the "Add Plugins" section of the WordPress admin UI, search for "monero" and click the Install Now button next to "Monero WooCommerce Extension" by mosu-forge, SerHack. This will enable auto-updates, but only for official releases, so if you need to work from git master or your local fork, please use the manual method below.
|
||||
|
||||
== Manual method ==
|
||||
|
||||
* Download the plugin from the releases page (https://github.com/monero-integrations/monerowp) or clone with `git clone https://github.com/monero-integrations/monerowp`
|
||||
* Unzip or place the `monero-woocommerce-gateway` folder in the `wp-content/plugins` directory.
|
||||
* Activate "Monero Woocommerce Gateway" in your WordPress admin dashboard.
|
||||
* It is highly recommended that you use native cronjobs instead of WordPress's "Poor Man's Cron" by adding `define('DISABLE_WP_CRON', true);` into your `wp-config.php` file and adding `* * * * * wget -q -O - https://yourstore.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1` to your crontab.
|
||||
|
||||
= Configuration =
|
||||
|
||||
== Option 1: Use your wallet address and viewkey ==
|
||||
|
||||
This is the easiest way to start accepting Monero on your website. You'll need:
|
||||
|
||||
* Your Monero wallet address starting with `4`
|
||||
* Your wallet's secret viewkey
|
||||
|
||||
Then simply select the `viewkey` option in the settings page and paste your address and viewkey. You're all set!
|
||||
|
||||
Note on privacy: when you validate transactions with your private viewkey, your viewkey is sent to (but not stored on) xmrchain.net over HTTPS. This could potentially allow an attacker to see your incoming, but not outgoing, transactions if they were to get his hands on your viewkey. Even if this were to happen, your funds would still be safe and it would be impossible for somebody to steal your money. For maximum privacy use your own `monero-wallet-rpc` instance.
|
||||
|
||||
== Option 2: Using monero wallet rpc ==
|
||||
|
||||
The most secure way to accept Monero on your website. You'll need:
|
||||
|
||||
* Root access to your webserver
|
||||
* Latest [Monero-currency binaries](https://github.com/monero-project/monero/releases)
|
||||
|
||||
After downloading (or compiling) the Monero binaries on your server, install the [systemd unit files](https://github.com/monero-integrations/monerowp/tree/master/assets/systemd-unit-files) or run `monerod` and `monero-wallet-rpc` with `screen` or `tmux`. You can skip running `monerod` by using a remote node with `monero-wallet-rpc` by adding `--daemon-address node.moneroworld.com:18089` to the `monero-wallet-rpc.service` file.
|
||||
|
||||
Note on security: using this option, while the most secure, requires you to run the Monero wallet RPC program on your server. Best practice for this is to use a view-only wallet since otherwise your server would be running a hot-wallet and a security breach could allow hackers to empty your funds.
|
||||
|
||||
== Remove plugin ==
|
||||
|
||||
@ -61,7 +89,7 @@ Once you installed and activated WooCommerce, you may install and activate Moner
|
||||
* Bug fixing
|
||||
|
||||
= 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.
|
||||
* 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.
|
||||
@ -72,6 +100,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.
|
||||
* 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 ==
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<section class="woocommerce-order-details">
|
||||
<h2 class="woocommerce-order-details__title"><?php echo $method_title ?></h2>
|
||||
<noscript><h1>You must enable javascript in order to confirm your order</h1></noscript>
|
||||
<noscript><p>Javascript is disabled, you must manually refresh the page to check your order status.</noscript>
|
||||
|
||||
<strong id="monero_payment_messages">
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<li>
|
||||
Pay to:
|
||||
<strong class="monero_details_row">
|
||||
<span class="monero_details_main" id="monero_integrated_address"></span>
|
||||
<span class="monero_details_main" id="monero_integrated_address"><noscript><?php echo $details['integrated_address']; ?></noscript></span>
|
||||
<span class="monero_details_right button-row">
|
||||
<?php if($show_qr): ?>
|
||||
<button href="#" class="button" title="Show QR Code" onclick="monero_showQR()">
|
||||
@ -40,7 +40,7 @@
|
||||
Total due:
|
||||
<strong class="monero_details_row">
|
||||
<span class="monero_details_main">
|
||||
<span id="monero_total_due"></span> XMR
|
||||
<span id="monero_total_due"></span><noscript><?php echo $details['amount_due_formatted']; ?></noscript> XMR
|
||||
</span>
|
||||
<span class="monero_details_right button-row">
|
||||
<button href="#" class="button clipboard" title="Copy Amount"
|
||||
@ -53,17 +53,17 @@
|
||||
<li style="display:none">
|
||||
Total order amount:
|
||||
<strong>
|
||||
<span id="monero_total_amount"></span> XMR
|
||||
<span id="monero_total_amount"></span><noscript><?php echo $details["amount_total_formatted"]; ?></noscript> XMR
|
||||
</strong>
|
||||
</li>
|
||||
<li>
|
||||
Total paid:
|
||||
<strong>
|
||||
<span id="monero_total_paid"></span> XMR
|
||||
<span id="monero_total_paid"></span><noscript><?php echo $details["amount_paid_formatted"]; ?></noscript> XMR
|
||||
</strong>
|
||||
</li>
|
||||
<li>
|
||||
Exchange rate:<strong id="monero_exchange_rate"></strong>
|
||||
Exchange rate:<strong id="monero_exchange_rate"><noscript>1 XMR = <?php echo $details["rate_formatted"]; ?></noscript></strong>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user