mirror of
https://git.wownero.com/wownero/wownerowp.git
synced 2024-08-15 01:03:16 +00:00
Compare commits
35 commits
Author | SHA1 | Date | |
---|---|---|---|
|
8122cdf8ef | ||
|
b9e5fcc96e | ||
|
572f04dfba | ||
|
9f0a8581e6 | ||
|
2e6ec376a2 | ||
|
acfdc094da | ||
|
fcedf21b30 | ||
|
90e058baeb | ||
|
954eb92785 | ||
|
b45b9625fb | ||
|
009f1d0594 | ||
|
25416473eb | ||
|
a3e10ab36f | ||
|
9af67ae75d | ||
|
a29b4d00b6 | ||
|
fea43715ea | ||
|
596a1e29ad | ||
|
646bcd671a | ||
|
5fa97a8282 | ||
|
21df86e4b8 | ||
|
8e7d258b5b | ||
|
7e48521570 | ||
|
ba395d507e | ||
|
f7d1f9b968 | ||
|
184e740452 | ||
|
8009819592 | ||
|
5064b95040 | ||
|
ad0d9ef004 | ||
|
17a379a2aa | ||
|
903432ac7a | ||
|
f7fa0b758e | ||
|
cd06d0303b | ||
|
ccb387095d | ||
|
53463e9111 | ||
|
a17af45bd8 |
31 changed files with 1062 additions and 989 deletions
4
LICENSE
4
LICENSE
|
@ -1,7 +1,7 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018, Ryo Currency Project
|
||||
Portions Copyright (c) 2017-2018, Monero Integrations
|
||||
Copyright (c) 2017-2018, Monero Integrations
|
||||
Copyright (c) 2018, Fireice Trust Fund
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
91
README.md
91
README.md
|
@ -1,8 +1,8 @@
|
|||
# Wownero Gateway for WooCommerce
|
||||
# Monero Gateway for WooCommerce
|
||||
|
||||
## Features
|
||||
|
||||
* Payment validation done through either `wownero-wallet-rpc` or the [explore.wownero.com blockchain explorer](https://explore.wownero.com/).
|
||||
* 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.
|
||||
|
@ -10,60 +10,66 @@
|
|||
* 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 Wownero.
|
||||
* Optionally display all prices on your store in terms of Monero.
|
||||
* Shortcodes! Display exchange rates in numerous currencies.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Wownero wallet to receive payments - [GUI](https://github.com/wownero/wownero/releases)
|
||||
* Monero wallet to receive payments - [GUI](https://github.com/monero-project/monero-gui/releases) - [CLI](https://github.com/monero-project/monero/releases) - [Paper](https://moneroaddress.org/)
|
||||
* [BCMath](http://php.net/manual/en/book.bc.php) - A PHP extension used for arbitrary precision maths
|
||||
|
||||
## Installing the plugin
|
||||
|
||||
* Download the plugin from the [releases page](https://github.com/itssteven/monerowp) or clone with `git clone https://github.com/itssteven/monerowp`
|
||||
* Unzip or place the `wownero-woocommerce-gateway` folder in the `wp-content/plugins` directory.
|
||||
* Activate "Wownero Woocommerce Gateway" in your WordPress admin dashboard.
|
||||
### 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 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.
|
||||
|
||||
## Option 1: Use your wallet address and viewkey
|
||||
|
||||
This is the easiest way to start accepting Wownero on your website. You'll need:
|
||||
This is the easiest way to start accepting Monero on your website. You'll need:
|
||||
|
||||
* Your Wownero wallet address starting with `W`
|
||||
* 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 `wownero-wallet-rpc` instance.
|
||||
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 `wownero-wallet-rpc`
|
||||
## Option 2: Using `monero-wallet-rpc`
|
||||
|
||||
The most secure way to accept Wownero on your website. You'll need:
|
||||
The most secure way to accept Monero on your website. You'll need:
|
||||
|
||||
* Root access to your webserver
|
||||
* Latest [Wownero-currency binaries](https://github.com/wownero/wownero/releases)
|
||||
* Latest [Monero-currency binaries](https://github.com/monero-project/monero/releases)
|
||||
|
||||
After downloading (or compiling) the Wownero binaries on your server, install the [systemd unit files](https://github.com/monero-integrations/monerowp/tree/master/assets/systemd-unit-files) or run `wownerod` and `wownero-wallet-rpc` with `screen` or `tmux`. You can skip running `wownerod` by using a remote node with `wownero-wallet-rpc` by adding `--daemon-address node.wowne.ro:34568` to the `wownero-wallet-rpc.service` file.
|
||||
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 Wownero 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.
|
||||
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.
|
||||
|
||||
## Configuration
|
||||
|
||||
* `Enable / Disable` - Turn on or off Wownero gateway. (Default: Disable)
|
||||
* `Title` - Name of the payment gateway as displayed to the customer. (Default: Wownero Gateway)
|
||||
* `Discount for using Wownero` - Percentage discount applied to orders for paying with Wownero. Can also be negative to apply a surcharge. (Default: 0)
|
||||
* `Enable / Disable` - Turn on or off Monero gateway. (Default: Disable)
|
||||
* `Title` - Name of the payment gateway as displayed to the customer. (Default: Monero Gateway)
|
||||
* `Discount for using Monero` - Percentage discount applied to orders for paying with Monero. Can also be negative to apply a surcharge. (Default: 0)
|
||||
* `Order valid time` - Number of seconds after order is placed that the transaction must be seen in the mempool. (Default: 3600 [1 hour])
|
||||
* `Number of confirmations` - Number of confirmations the transaction must recieve before the order is marked as complete. Use `0` for nearly instant confirmation. (Default: 5)
|
||||
* `Confirmation Type` - Confirm transactions with either your viewkey, or by using `wownero-wallet-rpc`. (Default: viewkey)
|
||||
* `Wownero Address` (if confirmation type is viewkey) - Your public Wownero address starting with 4. (No default)
|
||||
* `Confirmation Type` - Confirm transactions with either your viewkey, or by using `monero-wallet-rpc`. (Default: viewkey)
|
||||
* `Monero Address` (if confirmation type is viewkey) - Your public Monero address starting with 4. (No default)
|
||||
* `Secret Viewkey` (if confirmation type is viewkey) - Your *private* viewkey (No default)
|
||||
* `Wownero wallet RPC Host/IP` (if confirmation type is `wownero-wallet-rpc`) - IP address where the wallet rpc is running. It is highly discouraged to run the wallet anywhere other than the local server! (Default: 127.0.0.1)
|
||||
* `Wownero wallet RPC port` (if confirmation type is `wownero-wallet-rpc`) - Port the wallet rpc is bound to with the `--rpc-bind-port` argument. (Default 18080)
|
||||
* `Monero wallet RPC Host/IP` (if confirmation type is `monero-wallet-rpc`) - IP address where the wallet rpc is running. It is highly discouraged to run the wallet anywhere other than the local server! (Default: 127.0.0.1)
|
||||
* `Monero wallet RPC port` (if confirmation type is `monero-wallet-rpc`) - Port the wallet rpc is bound to with the `--rpc-bind-port` argument. (Default 18080)
|
||||
* `Testnet` - Check this to change the blockchain explorer links to the testnet explorer. (Default: unchecked)
|
||||
* `SSL warnings` - Check this to silence SSL warnings. (Default: unchecked)
|
||||
* `Show QR Code` - Show payment QR codes. There is no Wownero software that can read QR codes at this time (Default: unchecked)
|
||||
* `Show Prices in Wownero` - Convert all prices on the frontend to Wownero. Experimental feature, only use if you do not accept any other payment option. (Default: unchecked)
|
||||
* `Display Decimals` (if show prices in Wownero is enabled) - Number of decimals to round prices to on the frontend. The final order amount will not be rounded and will be displayed down to the nanoWownero. (Default: 11)
|
||||
* `Show QR Code` - Show payment QR codes. (Default: unchecked)
|
||||
* `Show Prices in Monero` - Convert all prices on the frontend to Monero. Experimental feature, only use if you do not accept any other payment option. (Default: unchecked)
|
||||
* `Display Decimals` (if show prices in Monero is enabled) - Number of decimals to round prices to on the frontend. The final order amount will not be rounded and will be displayed down to the nanoMonero. (Default: 12)
|
||||
|
||||
## Shortcodes
|
||||
|
||||
|
@ -71,36 +77,35 @@ This plugin makes available two shortcodes that you can use in your theme.
|
|||
|
||||
#### Live price shortcode
|
||||
|
||||
This will display the price of Wownero in the selected currency. If no currency is provided, the store's default currency will be used.
|
||||
This will display the price of Monero in the selected currency. If no currency is provided, the store's default currency will be used.
|
||||
|
||||
```
|
||||
[wownero-price]
|
||||
[wownero-price currency="BTC"]
|
||||
[wownero-price currency="USD"]
|
||||
[wownero-price currency="CAD"]
|
||||
[wownero-price currency="EUR"]
|
||||
[wownero-price currency="GBP"]
|
||||
[monero-price]
|
||||
[monero-price currency="BTC"]
|
||||
[monero-price currency="USD"]
|
||||
[monero-price currency="CAD"]
|
||||
[monero-price currency="EUR"]
|
||||
[monero-price currency="GBP"]
|
||||
```
|
||||
Will display:
|
||||
```
|
||||
1 WOW = 123.68000 USD
|
||||
1 WOW = 0.01827000 BTC
|
||||
1 WOW = 123.68000 USD
|
||||
1 WOW = 168.43000 CAD
|
||||
1 WOW = 105.54000 EUR
|
||||
1 WOW = 94.84000 GBP
|
||||
1 XMR = 123.68000 USD
|
||||
1 XMR = 0.01827000 BTC
|
||||
1 XMR = 123.68000 USD
|
||||
1 XMR = 168.43000 CAD
|
||||
1 XMR = 105.54000 EUR
|
||||
1 XMR = 94.84000 GBP
|
||||
```
|
||||
|
||||
|
||||
#### Wownero accepted here badge
|
||||
#### Monero accepted here badge
|
||||
|
||||
This will display a badge showing that you accept Wownero-currency.
|
||||
This will display a badge showing that you accept Monero-currency.
|
||||
|
||||
`[wownero-accepted-here]`
|
||||
`[monero-accepted-here]`
|
||||
|
||||

|
||||

|
||||
|
||||
## Donations
|
||||
|
||||
monero-integrations: 44krVcL6TPkANjpFwS2GWvg1kJhTrN7y9heVeQiDJ3rP8iGbCd5GeA4f3c2NKYHC1R4mCgnW7dsUUUae2m9GiNBGT4T8s2X
|
||||
guy who converted it to wownero: Wo57gnyJUihhnfpr7rbjv8Q9eJ8igcbyFPtbPogbLoGaLrYCV3RZHANc1SCJoL3WkCD6XGHbVaWYminF6rCzei6Y1Bhix1iRn
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
#wownero_payment_messages > span {
|
||||
#monero_payment_messages > span {
|
||||
display:none;
|
||||
}
|
||||
.wownero_details_row {
|
||||
.monero_details_row {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
margin:0 -8px;
|
||||
}
|
||||
.wownero_details_row > * {
|
||||
.monero_details_row > * {
|
||||
padding:0 8px;
|
||||
}
|
||||
.wownero_details_left {
|
||||
.monero_details_left {
|
||||
}
|
||||
.wownero_details_main {
|
||||
.monero_details_main {
|
||||
flex-grow: 1;
|
||||
word-break:break-all;
|
||||
}
|
||||
.wownero_details_right.button-row {
|
||||
.monero_details_right.button-row {
|
||||
display:flex;
|
||||
margin-top: 5px;
|
||||
align-self: self-start;
|
||||
}
|
||||
.wownero_details_right.button-row button {
|
||||
.monero_details_right.button-row button {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 6px 2px;
|
||||
|
@ -28,10 +28,10 @@
|
|||
line-height:28px;
|
||||
text-align:center;
|
||||
}
|
||||
#wownero_integrated_address {
|
||||
#monero_integrated_address {
|
||||
line-height: 16px;
|
||||
}
|
||||
#wownero_qr_code_container {
|
||||
#monero_qr_code_container {
|
||||
position:fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
|
@ -40,7 +40,7 @@
|
|||
z-index:9999;
|
||||
background:rgba(0,0,0,0.5);
|
||||
}
|
||||
#wownero_qr_code {
|
||||
#monero_qr_code {
|
||||
position: absolute;
|
||||
width: 256px;
|
||||
height: 256px;
|
||||
|
@ -52,13 +52,13 @@
|
|||
background: white;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#wownero_toast {
|
||||
#monero_toast {
|
||||
position: fixed;
|
||||
z-index: 999;
|
||||
top: 32px;
|
||||
right: 12px;
|
||||
}
|
||||
#wownero_toast > div {
|
||||
#monero_toast > div {
|
||||
display: block;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
@ -70,9 +70,9 @@
|
|||
color: white;
|
||||
right: -400px;
|
||||
}
|
||||
#wownero_toast > div.success {
|
||||
#monero_toast > div.success {
|
||||
background: rgba(68, 190, 117, 0.8);
|
||||
}
|
||||
#wownero_toast > div.error {
|
||||
#monero_toast > div.error {
|
||||
background: rgba(195, 60, 60, 0.8);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 941 B |
Binary file not shown.
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4.1 KiB |
161
assets/js/monero-gateway-order-page.js
Normal file
161
assets/js/monero-gateway-order-page.js
Normal file
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Fireice Trust Fund
|
||||
*/
|
||||
function monero_showNotification(message, type='success') {
|
||||
var toast = jQuery('<div class="' + type + '"><span>' + message + '</span></div>');
|
||||
jQuery('#monero_toast').append(toast);
|
||||
toast.animate({ "right": "12px" }, "fast");
|
||||
setInterval(function() {
|
||||
toast.animate({ "right": "-400px" }, "fast", function() {
|
||||
toast.remove();
|
||||
});
|
||||
}, 2500)
|
||||
}
|
||||
function monero_showQR(show=true) {
|
||||
jQuery('#monero_qr_code_container').toggle(show);
|
||||
}
|
||||
function monero_fetchDetails() {
|
||||
var data = {
|
||||
'_': jQuery.now(),
|
||||
'order_id': monero_details.order_id
|
||||
};
|
||||
jQuery.get(monero_ajax_url, data, function(response) {
|
||||
if (typeof response.error !== 'undefined') {
|
||||
console.log(response.error);
|
||||
} else {
|
||||
monero_details = response;
|
||||
monero_updateDetails();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function monero_updateDetails() {
|
||||
|
||||
var details = monero_details;
|
||||
|
||||
jQuery('#monero_payment_messages').children().hide();
|
||||
switch(details.status) {
|
||||
case 'unpaid':
|
||||
jQuery('.monero_payment_unpaid').show();
|
||||
jQuery('.monero_payment_expire_time').html(details.order_expires);
|
||||
break;
|
||||
case 'partial':
|
||||
jQuery('.monero_payment_partial').show();
|
||||
jQuery('.monero_payment_expire_time').html(details.order_expires);
|
||||
break;
|
||||
case 'paid':
|
||||
jQuery('.monero_payment_paid').show();
|
||||
jQuery('.monero_confirm_time').html(details.time_to_confirm);
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
case 'confirmed':
|
||||
jQuery('.monero_payment_confirmed').show();
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
case 'expired':
|
||||
jQuery('.monero_payment_expired').show();
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
case 'expired_partial':
|
||||
jQuery('.monero_payment_expired_partial').show();
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
}
|
||||
|
||||
jQuery('#monero_exchange_rate').html('1 WOW = '+details.rate_formatted+' '+details.currency);
|
||||
jQuery('#monero_total_amount').html(details.amount_total_formatted);
|
||||
jQuery('#monero_total_paid').html(details.amount_paid_formatted);
|
||||
jQuery('#monero_total_due').html(details.amount_due_formatted);
|
||||
|
||||
jQuery('#monero_integrated_address').html(details.integrated_address);
|
||||
|
||||
if(monero_show_qr) {
|
||||
var qr = jQuery('#monero_qr_code').html('');
|
||||
new QRCode(qr.get(0), details.qrcode_uri);
|
||||
}
|
||||
|
||||
if(details.txs.length) {
|
||||
jQuery('#monero_tx_table').show();
|
||||
jQuery('#monero_tx_none').hide();
|
||||
jQuery('#monero_tx_table tbody').html('');
|
||||
for(var i=0; i < details.txs.length; i++) {
|
||||
var tx = details.txs[i];
|
||||
var height = tx.height == 0 ? 'N/A' : tx.height;
|
||||
var row = ''+
|
||||
'<tr>'+
|
||||
'<td style="word-break: break-all">'+
|
||||
'<a href="'+monero_explorer_url+'/tx/'+tx.txid+'" target="_blank">'+tx.txid+'</a>'+
|
||||
'</td>'+
|
||||
'<td>'+height+'</td>'+
|
||||
'<td>'+tx.amount_formatted+' Wownero</td>'+
|
||||
'</tr>';
|
||||
|
||||
jQuery('#monero_tx_table tbody').append(row);
|
||||
}
|
||||
} else {
|
||||
jQuery('#monero_tx_table').hide();
|
||||
jQuery('#monero_tx_none').show();
|
||||
}
|
||||
|
||||
// Show state change notifications
|
||||
var new_txs = details.txs;
|
||||
var old_txs = monero_order_state.txs;
|
||||
if(new_txs.length != old_txs.length) {
|
||||
for(var i = 0; i < new_txs.length; i++) {
|
||||
var is_new_tx = true;
|
||||
for(var j = 0; j < old_txs.length; j++) {
|
||||
if(new_txs[i].txid == old_txs[j].txid && new_txs[i].amount == old_txs[j].amount) {
|
||||
is_new_tx = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(is_new_tx) {
|
||||
monero_showNotification('Transaction received for '+new_txs[i].amount_formatted+' Wownero');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(details.status != monero_order_state.status) {
|
||||
switch(details.status) {
|
||||
case 'paid':
|
||||
monero_showNotification('Your order has been paid in full');
|
||||
break;
|
||||
case 'confirmed':
|
||||
monero_showNotification('Your order has been confirmed');
|
||||
break;
|
||||
case 'expired':
|
||||
case 'expired_partial':
|
||||
monero_showNotification('Your order has expired', 'error');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
monero_order_state = {
|
||||
status: monero_details.status,
|
||||
txs: monero_details.txs
|
||||
};
|
||||
|
||||
}
|
||||
jQuery(document).ready(function($) {
|
||||
if (typeof monero_details !== 'undefined') {
|
||||
monero_order_state = {
|
||||
status: monero_details.status,
|
||||
txs: monero_details.txs
|
||||
};
|
||||
setInterval(monero_fetchDetails, 30000);
|
||||
monero_updateDetails();
|
||||
new ClipboardJS('.clipboard').on('success', function(e) {
|
||||
e.clearSelection();
|
||||
if(e.trigger.disabled) return;
|
||||
switch(e.trigger.getAttribute('data-clipboard-target')) {
|
||||
case '#monero_integrated_address':
|
||||
monero_showNotification('Copied destination address!');
|
||||
break;
|
||||
case '#monero_total_due':
|
||||
monero_showNotification('Copied total amount due!');
|
||||
break;
|
||||
}
|
||||
e.clearSelection();
|
||||
});
|
||||
}
|
||||
});
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Ryo Currency Project
|
||||
*/
|
||||
function wownero_showNotification(message, type='success') {
|
||||
var toast = jQuery('<div class="' + type + '"><span>' + message + '</span></div>');
|
||||
jQuery('#wownero_toast').append(toast);
|
||||
toast.animate({ "right": "12px" }, "fast");
|
||||
setInterval(function() {
|
||||
toast.animate({ "right": "-400px" }, "fast", function() {
|
||||
toast.remove();
|
||||
});
|
||||
}, 2500)
|
||||
}
|
||||
function wownero_showQR(show=true) {
|
||||
jQuery('#wownero_qr_code_container').toggle(show);
|
||||
}
|
||||
function wownero_fetchDetails() {
|
||||
var data = {
|
||||
'_': jQuery.now(),
|
||||
'order_id': wownero_details.order_id
|
||||
};
|
||||
jQuery.get(wownero_ajax_url, data, function(response) {
|
||||
if (typeof response.error !== 'undefined') {
|
||||
console.log(response.error);
|
||||
} else {
|
||||
wownero_details = response;
|
||||
wownero_updateDetails();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function wownero_updateDetails() {
|
||||
|
||||
var details = wownero_details;
|
||||
|
||||
jQuery('#wownero_payment_messages').children().hide();
|
||||
switch(details.status) {
|
||||
case 'unpaid':
|
||||
jQuery('.wownero_payment_unpaid').show();
|
||||
jQuery('.wownero_payment_expire_time').html(details.order_expires);
|
||||
break;
|
||||
case 'partial':
|
||||
jQuery('.wownero_payment_partial').show();
|
||||
jQuery('.wownero_payment_expire_time').html(details.order_expires);
|
||||
break;
|
||||
case 'paid':
|
||||
jQuery('.wownero_payment_paid').show();
|
||||
jQuery('.wownero_confirm_time').html(details.time_to_confirm);
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
case 'confirmed':
|
||||
jQuery('.wownero_payment_confirmed').show();
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
case 'expired':
|
||||
jQuery('.wownero_payment_expired').show();
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
case 'expired_partial':
|
||||
jQuery('.wownero_payment_expired_partial').show();
|
||||
jQuery('.button-row button').prop("disabled",true);
|
||||
break;
|
||||
}
|
||||
|
||||
jQuery('#wownero_exchange_rate').html('1 WOW = '+details.rate_formatted+' '+details.currency);
|
||||
jQuery('#wownero_total_amount').html(details.amount_total_formatted);
|
||||
jQuery('#wownero_total_paid').html(details.amount_paid_formatted);
|
||||
jQuery('#wownero_total_due').html(details.amount_due_formatted);
|
||||
|
||||
jQuery('#wownero_integrated_address').html(details.integrated_address);
|
||||
|
||||
if(wownero_show_qr) {
|
||||
var qr = jQuery('#wownero_qr_code').html('');
|
||||
new QRCode(qr.get(0), details.qrcode_uri);
|
||||
}
|
||||
|
||||
if(details.txs.length) {
|
||||
jQuery('#wownero_tx_table').show();
|
||||
jQuery('#wownero_tx_none').hide();
|
||||
jQuery('#wownero_tx_table tbody').html('');
|
||||
for(var i=0; i < details.txs.length; i++) {
|
||||
var tx = details.txs[i];
|
||||
var height = tx.height == 0 ? 'N/A' : tx.height;
|
||||
var row = ''+
|
||||
'<tr>'+
|
||||
'<td style="word-break: break-all">'+
|
||||
'<a href="'+wownero_explorer_url+'/tx/'+tx.txid+'" target="_blank">'+tx.txid+'</a>'+
|
||||
'</td>'+
|
||||
'<td>'+height+'</td>'+
|
||||
'<td>'+tx.amount_formatted+' wownero</td>'+
|
||||
'</tr>';
|
||||
|
||||
jQuery('#wownero_tx_table tbody').append(row);
|
||||
}
|
||||
} else {
|
||||
jQuery('#wownero_tx_table').hide();
|
||||
jQuery('#wownero_tx_none').show();
|
||||
}
|
||||
|
||||
// Show state change notifications
|
||||
var new_txs = details.txs;
|
||||
var old_txs = wownero_order_state.txs;
|
||||
if(new_txs.length != old_txs.length) {
|
||||
for(var i = 0; i < new_txs.length; i++) {
|
||||
var is_new_tx = true;
|
||||
for(var j = 0; j < old_txs.length; j++) {
|
||||
if(new_txs[i].txid == old_txs[j].txid && new_txs[i].amount == old_txs[j].amount) {
|
||||
is_new_tx = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(is_new_tx) {
|
||||
wownero_showNotification('Transaction received for '+new_txs[i].amount_formatted+' wownero');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(details.status != wownero_order_state.status) {
|
||||
switch(details.status) {
|
||||
case 'paid':
|
||||
wownero_showNotification('Your order has been paid in full');
|
||||
break;
|
||||
case 'confirmed':
|
||||
wownero_showNotification('Your order has been confirmed');
|
||||
break;
|
||||
case 'expired':
|
||||
case 'expired_partial':
|
||||
wownero_showNotification('Your order has expired', 'error');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wownero_order_state = {
|
||||
status: wownero_details.status,
|
||||
txs: wownero_details.txs
|
||||
};
|
||||
|
||||
}
|
||||
jQuery(document).ready(function($) {
|
||||
if (typeof wownero_details !== 'undefined') {
|
||||
wownero_order_state = {
|
||||
status: wownero_details.status,
|
||||
txs: wownero_details.txs
|
||||
};
|
||||
setInterval(wownero_fetchDetails, 30000);
|
||||
wownero_updateDetails();
|
||||
new ClipboardJS('.clipboard').on('success', function(e) {
|
||||
e.clearSelection();
|
||||
if(e.trigger.disabled) return;
|
||||
switch(e.trigger.getAttribute('data-clipboard-target')) {
|
||||
case '#wownero_integrated_address':
|
||||
wownero_showNotification('Copied destination address!');
|
||||
break;
|
||||
case '#wownero_total_due':
|
||||
wownero_showNotification('Copied total amount due!');
|
||||
break;
|
||||
}
|
||||
e.clearSelection();
|
||||
});
|
||||
}
|
||||
});
|
14
assets/systemd-unit-files/monero-wallet-rpc.service
Normal file
14
assets/systemd-unit-files/monero-wallet-rpc.service
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Monero Wallet RPC
|
||||
After=network.target monerod.service
|
||||
|
||||
[Service]
|
||||
User=moneroservices
|
||||
Group=moneroservices
|
||||
WorkingDirectory=/opt/monero-wallets
|
||||
Type=simple
|
||||
ExecStart=/opt/monero-bin/monero-wallet-rpc --wallet-file /opt/monero-wallets/woocommerce --rpc-bind-port 18080 --password-file /opt/monero-wallets/woocommerce.password --disable-rpc-login --log-file /var/log/monero-wallet.log
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
14
assets/systemd-unit-files/monerod.service
Normal file
14
assets/systemd-unit-files/monerod.service
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Monero Full Node
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=moneroservices
|
||||
Group=moneroservices
|
||||
WorkingDirectory=/opt/monero-data-dir
|
||||
Type=simple
|
||||
LimitNOFILE=65535
|
||||
ExecStart=/usr/bin/monerod --log-file /var/log/monerod.log --data-dir /opt/monero-data-dir --non-interactive
|
||||
Restart=always
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,14 +0,0 @@
|
|||
[Unit]
|
||||
Description=Wownero Wallet RPC
|
||||
After=network.target wownerod.service
|
||||
|
||||
[Service]
|
||||
User=wowneroservices
|
||||
Group=wowneroservices
|
||||
WorkingDirectory=/opt/wownero-wallets
|
||||
Type=simple
|
||||
ExecStart=/opt/wownero-bin/wownero-wallet-rpc --wallet-file /opt/wownero-wallets/woocommerce --rpc-bind-port 18080 --password-file /opt/wownero-wallets/woocommerce.password --disable-rpc-login --log-file /var/log/wownero-wallet.log
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,14 +0,0 @@
|
|||
[Unit]
|
||||
Description=Wownero Full Node
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=wowneroservices
|
||||
Group=wowneroservices
|
||||
WorkingDirectory=/opt/wownero-data-dir
|
||||
Type=simple
|
||||
LimitNOFILE=65535
|
||||
ExecStart=/usr/bin/wownerod --log-file /var/log/wownerod.log --data-dir /opt/wownero-data-dir --non-interactive
|
||||
Restart=always
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,19 +1,18 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2018, Ryo Currency Project
|
||||
* Admin interface for Wownero gateway
|
||||
* Authors: mosu-forge
|
||||
* Copyright (c) 2018, Fireice Trust Fund
|
||||
* Admin interface for Monero gateway
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
require_once('class-wownero-admin-payments-list.php');
|
||||
require_once('class-monero-admin-payments-list.php');
|
||||
|
||||
if (class_exists('Wownero_Admin_Interface', false)) {
|
||||
return new Wownero_Admin_Interface();
|
||||
if (class_exists('Monero_Admin_Interface', false)) {
|
||||
return new Monero_Admin_Interface();
|
||||
}
|
||||
|
||||
class Wownero_Admin_Interface {
|
||||
class Monero_Admin_Interface {
|
||||
|
||||
public function __construct() {
|
||||
add_action('add_meta_boxes', array($this, 'meta_boxes'));
|
||||
|
@ -26,7 +25,7 @@ class Wownero_Admin_Interface {
|
|||
*/
|
||||
public function meta_boxes() {
|
||||
add_meta_box(
|
||||
'wownero_admin_order_details',
|
||||
'monero_admin_order_details',
|
||||
__('Wownero Gateway','wownero_gateway'),
|
||||
array($this, 'meta_box_order_details'),
|
||||
'shop_order',
|
||||
|
@ -39,7 +38,7 @@ class Wownero_Admin_Interface {
|
|||
* Meta box for order page
|
||||
*/
|
||||
public function meta_box_order_details($order) {
|
||||
Wownero_Gateway::admin_order_page($order);
|
||||
Monero_Gateway::admin_order_page($order);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +69,7 @@ class Wownero_Admin_Interface {
|
|||
__('Settings', 'wownero_gateway'),
|
||||
__('Settings', 'wownero_gateway'),
|
||||
'manage_options',
|
||||
'wownero_gateway_settings',
|
||||
'monero_gateway_settings',
|
||||
array($this, 'settings_page')
|
||||
);
|
||||
add_action('load-'.$settings_page, array($this, 'settings_page_init'));
|
||||
|
@ -87,16 +86,16 @@ class Wownero_Admin_Interface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Wownero payments page
|
||||
* Monero payments page
|
||||
*/
|
||||
public function payments_page() {
|
||||
$payments_list = new Wownero_Admin_Payments_List();
|
||||
$payments_list = new Monero_Admin_Payments_List();
|
||||
$payments_list->prepare_items();
|
||||
$payments_list->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wownero settings page
|
||||
* Monero settings page
|
||||
*/
|
||||
public function settings_page() {
|
||||
WC_Admin_Settings::output();
|
||||
|
@ -130,4 +129,4 @@ class Wownero_Admin_Interface {
|
|||
|
||||
}
|
||||
|
||||
return new Wownero_Admin_Interface();
|
||||
return new Monero_Admin_Interface();
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2018, Ryo Currency Project
|
||||
* Admin interface for Wownero gateway
|
||||
* Authors: mosu-forge
|
||||
* Copyright (c) 2018, Fireice Trust Fund
|
||||
* Admin interface for Monero gateway
|
||||
*/
|
||||
|
||||
if(!class_exists('WP_List_Table')) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
||||
}
|
||||
|
||||
class Wownero_Admin_Payments_List extends WP_List_Table {
|
||||
class Monero_Admin_Payments_List extends WP_List_Table {
|
||||
|
||||
function __construct() {
|
||||
parent::__construct(array(
|
||||
|
@ -54,8 +53,8 @@ class Wownero_Admin_Payments_List extends WP_List_Table {
|
|||
} else {
|
||||
$tab_info['all']['active'] = 'class="current" aria-current="page"';
|
||||
}
|
||||
if(Wownero_Gateway::get_confirm_type() == 'wownero-wallet-rpc') {
|
||||
$balance = Wownero_Gateway::admin_balance_info();
|
||||
if(Monero_Gateway::get_confirm_type() == 'wownero-wallet-rpc') {
|
||||
$balance = Monero_Gateway::admin_balance_info();
|
||||
$balance_info = <<<HTML
|
||||
<div style="border:1px solid #ddd;padding:5px 10px;">
|
||||
Wallet height: {$balance['height']}</br>
|
||||
|
@ -99,7 +98,7 @@ HTML;
|
|||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form id="wownero-payments-filter" method="get" style="display:none">
|
||||
<form id="monero-payments-filter" method="get" style="display:none">
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="post-search-input">Search payments:</label>
|
||||
<input type="search" id="post-search-input" name="s" value="">
|
||||
|
@ -145,7 +144,7 @@ HTML;
|
|||
echo $item->height;
|
||||
break;
|
||||
case 'col_amount':
|
||||
echo Wownero_Gateway::format_wownero($item->amount).' Wownero';
|
||||
echo Monero_Gateway::format_monero($item->amount).' Wownero';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -212,8 +211,8 @@ HTML;
|
|||
|
||||
protected function get_item_count($type) {
|
||||
global $wpdb;
|
||||
$table_name_1 = $wpdb->prefix.'wownero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'wownero_gateway_quotes_txids';
|
||||
$table_name_1 = $wpdb->prefix.'monero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'monero_gateway_quotes_txids';
|
||||
$query_where = ' WHERE 1=1 '.$this->get_clause_type($type);
|
||||
$query = "SELECT COUNT(*) AS count FROM {$table_name_2} t2 LEFT JOIN $table_name_1 t1 ON t2.payment_id = t1.payment_id {$query_where}";
|
||||
$item_count = $wpdb->get_var($query);
|
||||
|
@ -249,8 +248,8 @@ HTML;
|
|||
$this->items = array();
|
||||
$filters = $this->get_filter_vars();
|
||||
|
||||
$table_name_1 = $wpdb->prefix.'wownero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'wownero_gateway_quotes_txids';
|
||||
$table_name_1 = $wpdb->prefix.'monero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'monero_gateway_quotes_txids';
|
||||
|
||||
$query_where = ' WHERE 1=1 ';
|
||||
|
|
@ -40,7 +40,7 @@ return array(
|
|||
'desc_tip' => __('Number of confirms a transaction must have to be valid', 'wownero_gateway'),
|
||||
'description' => __('Enter the number of confirms that transactions must have. Enter 0 to zero-confim. Each confirm will take approximately four minutes', 'wownero_gateway'),
|
||||
'type' => __('number'),
|
||||
'default' => '5'
|
||||
'default' => '4'
|
||||
),
|
||||
'confirm_type' => array(
|
||||
'title' => __('Confirmation Type', 'wownero_gateway'),
|
||||
|
@ -53,11 +53,11 @@ return array(
|
|||
),
|
||||
'default' => 'viewkey'
|
||||
),
|
||||
'wownero_address' => array(
|
||||
'monero_address' => array(
|
||||
'title' => __('Wownero Address', 'wownero_gateway'),
|
||||
'label' => __('Useful for people that have not a daemon online'),
|
||||
'type' => 'text',
|
||||
'desc_tip' => __('Wownero Wallet Address (Wownero)', 'wownero_gateway')
|
||||
'desc_tip' => __('Wownero Wallet Address (MoneroL)', 'wownero_gateway')
|
||||
),
|
||||
'viewkey' => array(
|
||||
'title' => __('Secret Viewkey', 'wownero_gateway'),
|
||||
|
@ -75,7 +75,7 @@ return array(
|
|||
'title' => __('Wownero wallet RPC port', 'wownero_gateway'),
|
||||
'type' => __('number'),
|
||||
'desc_tip' => __('This is the Wallet RPC port to authorize the payment with', 'wownero_gateway'),
|
||||
'default' => '18080',
|
||||
'default' => '34567',
|
||||
),
|
||||
'testnet' => array(
|
||||
'title' => __(' Testnet', 'wownero_gateway'),
|
||||
|
@ -84,6 +84,12 @@ return array(
|
|||
'description' => __('Advanced usage only', 'wownero_gateway'),
|
||||
'default' => 'no'
|
||||
),
|
||||
'javascript' => array(
|
||||
'title' => __(' Javascript', 'wownero_gateway'),
|
||||
'label' => __(' Check this to ENABLE Javascript in Checkout page ', 'wownero_gateway'),
|
||||
'type' => 'checkbox',
|
||||
'default' => 'no'
|
||||
),
|
||||
'onion_service' => array(
|
||||
'title' => __(' SSL warnings ', 'wownero_gateway'),
|
||||
'label' => __(' Check to Silence SSL warnings', 'wownero_gateway'),
|
||||
|
@ -98,14 +104,14 @@ return array(
|
|||
'description' => __('Enable this to show a QR code after checkout with payment details.'),
|
||||
'default' => 'no'
|
||||
),
|
||||
'use_wownero_price' => array(
|
||||
'use_monero_price' => array(
|
||||
'title' => __('Show Prices in Wownero', 'wownero_gateway'),
|
||||
'label' => __('Show Prices in Wownero', 'wownero_gateway'),
|
||||
'type' => 'checkbox',
|
||||
'description' => __('Enable this to convert ALL prices on the frontend to Wownero (experimental)'),
|
||||
'default' => 'no'
|
||||
),
|
||||
'use_wownero_price_decimals' => array(
|
||||
'use_monero_price_decimals' => array(
|
||||
'title' => __('Display Decimals', 'wownero_gateway'),
|
||||
'type' => __('number'),
|
||||
'description' => __('Number of decimal places to display on frontend. Upon checkout exact price will be displayed.'),
|
356
include/class-monero-base58.php
Normal file
356
include/class-monero-base58.php
Normal file
|
@ -0,0 +1,356 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* monerophp/base58
|
||||
*
|
||||
* A PHP Base58 codec
|
||||
* https://github.com/monero-integrations/monerophp
|
||||
*
|
||||
* Using work from
|
||||
* bigreddmachine [MoneroPy] (https://github.com/bigreddmachine)
|
||||
* Paul Shapiro [mymonero-core-js] (https://github.com/paulshapiro)
|
||||
*
|
||||
* @author Monero Integrations Team <support@monerointegrations.com> (https://github.com/monero-integrations)
|
||||
* @copyright 2018
|
||||
* @license MIT
|
||||
*
|
||||
* ============================================================================
|
||||
*
|
||||
* // Initialize class
|
||||
* $base58 = new base58();
|
||||
*
|
||||
* // Encode a hexadecimal (base16) string as base58
|
||||
* $encoded = $base58->encode('0137F8F06C971B168745F562AA107B4D172F336271BC0F9D3B510C14D3460DFB27D8CEBE561E73AC1E11833D5EA40200EB3C82E9C66ACAF1AB1A6BB53C40537C0B7A22160B0E');
|
||||
*
|
||||
* // Decode
|
||||
* $decoded = $base58->decode('479cG5opa54beQWSyqNoWw5tna9sHUNmMTtiFqLPaUhDevpJ2YLwXAggSx5ePdeFrYF8cdbmVRSmp1Kn3t4Y9kFu7rZ7pFw');
|
||||
*
|
||||
*/
|
||||
class Monero_base58
|
||||
{
|
||||
static $alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
static $encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11];
|
||||
static $full_block_size = 8;
|
||||
static $full_encoded_block_size = 11;
|
||||
/**
|
||||
*
|
||||
* Convert a hexadecimal string to a binary array
|
||||
*
|
||||
* @param string $hex A hexadecimal string to convert to a binary array
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function hex_to_bin($hex)
|
||||
{
|
||||
if (gettype($hex) != 'string') {
|
||||
throw new Exception('base58->hex_to_bin(): Invalid input type (must be a string)');
|
||||
}
|
||||
if (strlen($hex) % 2 != 0) {
|
||||
throw new Exception('base58->hex_to_bin(): Invalid input length (must be even)');
|
||||
}
|
||||
$res = array_fill(0, strlen($hex) / 2, 0);
|
||||
for ($i = 0; $i < strlen($hex) / 2; $i++) {
|
||||
$res[$i] = intval(substr($hex, $i * 2, $i * 2 + 2 - $i * 2), 16);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a binary array to a hexadecimal string
|
||||
*
|
||||
* @param array $bin A binary array to convert to a hexadecimal string
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
private function bin_to_hex($bin)
|
||||
{
|
||||
if (gettype($bin) != 'array') {
|
||||
throw new Exception('base58->bin_to_hex(): Invalid input type (must be an array)');
|
||||
}
|
||||
$res = [];
|
||||
for ($i = 0; $i < count($bin); $i++) {
|
||||
$res[] = substr('0'.dechex($bin[$i]), -2);
|
||||
}
|
||||
return join($res);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a string to a binary array
|
||||
*
|
||||
* @param string $str A string to convert to a binary array
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function str_to_bin($str)
|
||||
{
|
||||
if (gettype($str) != 'string') {
|
||||
throw new Exception('base58->str_to_bin(): Invalid input type (must be a string)');
|
||||
}
|
||||
$res = array_fill(0, strlen($str), 0);
|
||||
for ($i = 0; $i < strlen($str); $i++) {
|
||||
$res[$i] = ord($str[$i]);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a binary array to a string
|
||||
*
|
||||
* @param array $bin A binary array to convert to a string
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
private function bin_to_str($bin)
|
||||
{
|
||||
if (gettype($bin) != 'array') {
|
||||
throw new Exception('base58->bin_to_str(): Invalid input type (must be an array)');
|
||||
}
|
||||
$res = array_fill(0, count($bin), 0);
|
||||
for ($i = 0; $i < count($bin); $i++) {
|
||||
$res[$i] = chr($bin[$i]);
|
||||
}
|
||||
return preg_replace('/[[:^print:]]/', '', join($res)); // preg_replace necessary to strip errant non-ASCII characters eg. ''
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a UInt8BE (one unsigned big endian byte) array to UInt64
|
||||
*
|
||||
* @param array $data A UInt8BE array to convert to UInt64
|
||||
*
|
||||
* @return number
|
||||
*
|
||||
*/
|
||||
private function uint8_be_to_64($data)
|
||||
{
|
||||
if (gettype($data) != 'array') {
|
||||
throw new Exception ('base58->uint8_be_to_64(): Invalid input type (must be an array)');
|
||||
}
|
||||
$res = 0;
|
||||
$i = 0;
|
||||
switch (9 - count($data)) {
|
||||
case 1:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 2:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 3:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 4:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 5:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 6:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 7:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 8:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('base58->uint8_be_to_64: Invalid input length (1 <= count($data) <= 8)');
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a UInt64 (unsigned 64 bit integer) to a UInt8BE array
|
||||
*
|
||||
* @param number $num A UInt64 number to convert to a UInt8BE array
|
||||
* @param integer $size Size of array to return
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function uint64_to_8_be($num, $size)
|
||||
{
|
||||
if (gettype($num) != ('integer' || 'double')) {
|
||||
throw new Exception ('base58->uint64_to_8_be(): Invalid input type ($num must be a number)');
|
||||
}
|
||||
if (gettype($size) != 'integer') {
|
||||
throw new Exception ('base58->uint64_to_8_be(): Invalid input type ($size must be an integer)');
|
||||
}
|
||||
if ($size < 1 || $size > 8) {
|
||||
throw new Exception ('base58->uint64_to_8_be(): Invalid size (1 <= $size <= 8)');
|
||||
}
|
||||
$res = array_fill(0, $size, 0);
|
||||
for ($i = $size - 1; $i >= 0; $i--) {
|
||||
$res[$i] = bcmod($num, bcpow(2, 8));
|
||||
$num = bcdiv($num, bcpow(2, 8));
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a hexadecimal (Base16) array to a Base58 string
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $buf
|
||||
* @param number $index
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function encode_block($data, $buf, $index)
|
||||
{
|
||||
if (gettype($data) != 'array') {
|
||||
throw new Exception('base58->encode_block(): Invalid input type ($data must be an array)');
|
||||
}
|
||||
if (gettype($buf) != 'array') {
|
||||
throw new Exception('base58->encode_block(): Invalid input type ($buf must be an array)');
|
||||
}
|
||||
if (gettype($index) != ('integer' || 'double')) {
|
||||
throw new Exception('base58->encode_block(): Invalid input type ($index must be a number)');
|
||||
}
|
||||
if (count($data) < 1 or count($data) > self::$full_encoded_block_size) {
|
||||
throw new Exception('base58->encode_block(): Invalid input length (1 <= count($data) <= 8)');
|
||||
}
|
||||
$num = self::uint8_be_to_64($data);
|
||||
$i = self::$encoded_block_sizes[count($data)] - 1;
|
||||
while ($num > 0) {
|
||||
$remainder = bcmod($num, 58);
|
||||
$num = bcdiv($num, 58);
|
||||
$buf[$index + $i] = ord(self::$alphabet[$remainder]);
|
||||
$i--;
|
||||
}
|
||||
return $buf;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Encode a hexadecimal (Base16) string to Base58
|
||||
*
|
||||
* @param string $hex A hexadecimal (Base16) string to convert to Base58
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function encode($hex)
|
||||
{
|
||||
if (gettype($hex) != 'string') {
|
||||
throw new Exception ('base58->encode(): Invalid input type (must be a string)');
|
||||
}
|
||||
$data = self::hex_to_bin($hex);
|
||||
if (count($data) == 0) {
|
||||
return '';
|
||||
}
|
||||
$full_block_count = floor(count($data) / self::$full_block_size);
|
||||
$last_block_size = count($data) % self::$full_block_size;
|
||||
$res_size = $full_block_count * self::$full_encoded_block_size + self::$encoded_block_sizes[$last_block_size];
|
||||
$res = array_fill(0, $res_size, ord(self::$alphabet[0]));
|
||||
for ($i = 0; $i < $full_block_count; $i++) {
|
||||
$res = self::encode_block(array_slice($data, $i * self::$full_block_size, ($i * self::$full_block_size + self::$full_block_size) - ($i * self::$full_block_size)), $res, $i * self::$full_encoded_block_size);
|
||||
}
|
||||
if ($last_block_size > 0) {
|
||||
$res = self::encode_block(array_slice($data, $full_block_count * self::$full_block_size, $full_block_count * self::$full_block_size + $last_block_size), $res, $full_block_count * self::$full_encoded_block_size);
|
||||
}
|
||||
return self::bin_to_str($res);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Convert a Base58 input to hexadecimal (Base16)
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $buf
|
||||
* @param integer $index
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function decode_block($data, $buf, $index)
|
||||
{
|
||||
if (gettype($data) != 'array') {
|
||||
throw new Exception('base58->decode_block(): Invalid input type ($data must be an array)');
|
||||
}
|
||||
if (gettype($buf) != 'array') {
|
||||
throw new Exception('base58->decode_block(): Invalid input type ($buf must be an array)');
|
||||
}
|
||||
if (gettype($index) != ('integer' || 'double')) {
|
||||
throw new Exception('base58->decode_block(): Invalid input type ($index must be a number)');
|
||||
}
|
||||
$res_size = self::index_of(self::$encoded_block_sizes, count($data));
|
||||
if ($res_size <= 0) {
|
||||
throw new Exception('base58->decode_block(): Invalid input length ($data must be a value from base58::$encoded_block_sizes)');
|
||||
}
|
||||
$res_num = 0;
|
||||
$order = 1;
|
||||
for ($i = count($data) - 1; $i >= 0; $i--) {
|
||||
$digit = strpos(self::$alphabet, chr($data[$i]));
|
||||
if ($digit < 0) {
|
||||
throw new Exception("base58->decode_block(): Invalid character ($digit \"{$digit}\" not found in base58::$alphabet)");
|
||||
}
|
||||
$product = bcadd(bcmul($order, $digit), $res_num);
|
||||
if ($product > bcpow(2, 64)) {
|
||||
throw new Exception('base58->decode_block(): Integer overflow ($product exceeds the maximum 64bit integer)');
|
||||
}
|
||||
$res_num = $product;
|
||||
$order = bcmul($order, 58);
|
||||
}
|
||||
if ($res_size < self::$full_block_size && bcpow(2, 8 * $res_size) <= 0) {
|
||||
throw new Exception('base58->decode_block(): Integer overflow (bcpow(2, 8 * $res_size) exceeds the maximum 64bit integer)');
|
||||
}
|
||||
|
||||
$tmp_buf = self::uint64_to_8_be($res_num, $res_size);
|
||||
for ($i = 0; $i < count($tmp_buf); $i++) {
|
||||
$buf[$i + $index] = $tmp_buf[$i];
|
||||
}
|
||||
return $buf;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Decode a Base58 string to hexadecimal (Base16)
|
||||
*
|
||||
* @param string $hex A Base58 string to convert to hexadecimal (Base16)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function decode($enc)
|
||||
{
|
||||
if (gettype($enc) != 'string') {
|
||||
throw new Exception ('base58->decode(): Invalid input type (must be a string)');
|
||||
}
|
||||
$enc = self::str_to_bin($enc);
|
||||
if (count($enc) == 0) {
|
||||
return '';
|
||||
}
|
||||
$full_block_count = floor(bcdiv(count($enc), self::$full_encoded_block_size));
|
||||
$last_block_size = bcmod(count($enc), self::$full_encoded_block_size);
|
||||
$last_block_decoded_size = self::index_of(self::$encoded_block_sizes, $last_block_size);
|
||||
$data_size = $full_block_count * self::$full_block_size + $last_block_decoded_size;
|
||||
if ($data_size == -1) {
|
||||
return '';
|
||||
}
|
||||
$data = array_fill(0, $data_size, 0);
|
||||
for ($i = 0; $i <= $full_block_count; $i++) {
|
||||
$data = self::decode_block(array_slice($enc, $i * self::$full_encoded_block_size, ($i * self::$full_encoded_block_size + self::$full_encoded_block_size) - ($i * self::$full_encoded_block_size)), $data, $i * self::$full_block_size);
|
||||
}
|
||||
if ($last_block_size > 0) {
|
||||
$data = self::decode_block(array_slice($enc, $full_block_count * self::$full_encoded_block_size, $full_block_count * self::$full_encoded_block_size + $last_block_size), $data, $full_block_count * self::$full_block_size);
|
||||
}
|
||||
return self::bin_to_hex($data);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Search an array for a value
|
||||
* Source: https://stackoverflow.com/a/30994678
|
||||
*
|
||||
* @param array $haystack An array to search
|
||||
* @param string $needle A string to search for
|
||||
*)
|
||||
* @return number The index of the element found (or -1 for no match)
|
||||
*
|
||||
*/
|
||||
private function index_of($haystack, $needle)
|
||||
{
|
||||
if (gettype($haystack) != 'array') {
|
||||
throw new Exception ('base58->decode(): Invalid input type ($haystack must be an array)');
|
||||
}
|
||||
// if (gettype($needle) != 'string') {
|
||||
// throw new Exception ('base58->decode(): Invalid input type ($needle must be a string)');
|
||||
// }
|
||||
foreach ($haystack as $key => $value) if ($value === $needle) return $key;
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -11,15 +11,15 @@ if(!class_exists('SHA3'))
|
|||
if(!class_exists('ed25519'))
|
||||
require_once('crypto/ed25519.php');
|
||||
|
||||
require_once('class-wownero-base58.php');
|
||||
require_once('class-monero-base58.php');
|
||||
|
||||
class Wownero_Cryptonote
|
||||
class Monero_Cryptonote
|
||||
{
|
||||
protected $ed25519;
|
||||
public function __construct()
|
||||
{
|
||||
$this->ed25519 = new ed25519();
|
||||
$this->base58 = new Wownero_base58();
|
||||
$this->base58 = new Monero_base58();
|
||||
$this->address_prefix = MONERO_GATEWAY_ADDRESS_PREFIX;
|
||||
$this->address_prefix_integrated = MONERO_GATEWAY_ADDRESS_PREFIX_INTEGRATED;
|
||||
}
|
||||
|
@ -222,12 +222,12 @@ class Wownero_Cryptonote
|
|||
}
|
||||
|
||||
/*
|
||||
* Create a valid base58 encoded Wownero address from public keys
|
||||
* Create a valid base58 encoded Monero address from public keys
|
||||
*
|
||||
* @param string Public spend key
|
||||
* @param string Public view key
|
||||
*
|
||||
* @return string Base58 encoded Wownero address
|
||||
* @return string Base58 encoded Monero address
|
||||
*/
|
||||
public function encode_address($pSpendKey, $pViewKey)
|
||||
{
|
||||
|
@ -246,9 +246,9 @@ class Wownero_Cryptonote
|
|||
}
|
||||
|
||||
/*
|
||||
* Decode a base58 encoded Wownero address
|
||||
* Decode a base58 encoded Monero address
|
||||
*
|
||||
* @param string A base58 encoded Wownero address
|
||||
* @param string A base58 encoded Monero address
|
||||
*
|
||||
* @return array An array containing the Address network byte, public spend key, and public view key
|
||||
*/
|
||||
|
@ -291,11 +291,11 @@ class Wownero_Cryptonote
|
|||
}
|
||||
|
||||
/*
|
||||
* Generate a Wownero address from seed
|
||||
* Generate a Monero address from seed
|
||||
*
|
||||
* @param string Hex string to use as seed
|
||||
*
|
||||
* @return string A base58 encoded Wownero address
|
||||
* @return string A base58 encoded Monero address
|
||||
*/
|
||||
public function address_from_seed($hex_seed)
|
||||
{
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* wownero_explorer_tools.php
|
||||
* monero_explorer_tools.php
|
||||
*
|
||||
* Uses CURL to call API functions from the block explorer
|
||||
* https://explore.wownero.com/
|
||||
* https://xmrchain.net/
|
||||
*
|
||||
* @author Serhack
|
||||
* @author cryptochangements
|
||||
* @author mosu-forge
|
||||
*
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Wownero_Explorer_Tools
|
||||
class Monero_Explorer_Tools
|
||||
{
|
||||
private $url;
|
||||
public function __construct($testnet = false)
|
||||
{
|
||||
$this->url = $testnet ? MONERO_GATEWAY_TESTNET_EXPLORER_URL : MONERO_GATEWAY_MAINNET_EXPLORER_URL;
|
||||
$this->url = preg_replace("/\/+$/", "", $this->url);
|
||||
}
|
||||
|
||||
private function call_api($endpoint)
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
/*
|
||||
* Main Gateway of Wownero using either a local daemon or the explorer
|
||||
* Authors: Serhack, cryptochangements, mosu-forge
|
||||
* Main Gateway of Monero using either a local daemon or the explorer
|
||||
* Authors: SerHack, cryptochangements
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
require_once('class-wownero-cryptonote.php');
|
||||
require_once('class-monero-cryptonote.php');
|
||||
|
||||
class Wownero_Gateway extends WC_Payment_Gateway
|
||||
class Monero_Gateway extends WC_Payment_Gateway
|
||||
{
|
||||
private static $_id = 'wownero_gateway';
|
||||
private static $_title = 'Wownero Gateway';
|
||||
|
@ -27,21 +27,22 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
private static $testnet = false;
|
||||
private static $onion_service = false;
|
||||
private static $show_qr = false;
|
||||
private static $use_wownero_price = false;
|
||||
private static $use_wownero_price_decimals = MONERO_GATEWAY_ATOMIC_UNITS;
|
||||
private static $use_monero_price = false;
|
||||
private static $use_monero_price_decimals = MONERO_GATEWAY_ATOMIC_UNITS;
|
||||
|
||||
private static $cryptonote;
|
||||
private static $wownero_wallet_rpc;
|
||||
private static $wownero_explorer_tools;
|
||||
private static $monero_wallet_rpc;
|
||||
private static $monero_explorer_tools;
|
||||
private static $log;
|
||||
|
||||
private static $currencies = 'USD';
|
||||
private static $rates = array();
|
||||
|
||||
private static $payment_details = array();
|
||||
|
||||
public function get_icon()
|
||||
{
|
||||
return apply_filters('woocommerce_gateway_icon', '<img src="'.MONERO_GATEWAY_PLUGIN_URL.'assets/images/wownero-icon.png"/>');
|
||||
return apply_filters('woocommerce_gateway_icon', '<img src="'.MONERO_GATEWAY_PLUGIN_URL.'assets/images/wownero-icon.png"/>', $this->id);
|
||||
}
|
||||
|
||||
function __construct($add_action=true)
|
||||
|
@ -73,30 +74,34 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
self::$valid_time = $this->settings['valid_time'];
|
||||
self::$confirms = $this->settings['confirms'];
|
||||
self::$confirm_type = $this->settings['confirm_type'];
|
||||
self::$address = $this->settings['wownero_address'];
|
||||
self::$address = $this->settings['monero_address'];
|
||||
self::$viewkey = $this->settings['viewkey'];
|
||||
self::$host = $this->settings['daemon_host'];
|
||||
self::$port = $this->settings['daemon_port'];
|
||||
self::$testnet = $this->settings['testnet'] == 'yes';
|
||||
self::$onion_service = $this->settings['onion_service'] == 'yes';
|
||||
self::$show_qr = $this->settings['show_qr'] == 'yes';
|
||||
self::$use_wownero_price = $this->settings['use_wownero_price'] == 'yes';
|
||||
self::$use_wownero_price_decimals = $this->settings['use_wownero_price_decimals'];
|
||||
self::$use_monero_price = $this->settings['use_monero_price'] == 'yes';
|
||||
self::$use_monero_price_decimals = $this->settings['use_monero_price_decimals'];
|
||||
|
||||
$explorer_url = self::$testnet ? MONERO_GATEWAY_TESTNET_EXPLORER_URL : MONERO_GATEWAY_MAINNET_EXPLORER_URL;
|
||||
defined('MONERO_GATEWAY_EXPLORER_URL') || define('MONERO_GATEWAY_EXPLORER_URL', $explorer_url);
|
||||
|
||||
// Add the currency of the shop to $currencies array. Needed for do_update_event() function
|
||||
$currency_shop = get_woocommerce_currency();
|
||||
array_push(self::$currencies, $currency_shop);
|
||||
|
||||
if($add_action)
|
||||
add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options'));
|
||||
|
||||
// Initialize helper classes
|
||||
self::$cryptonote = new Wownero_Cryptonote();
|
||||
self::$cryptonote = new Monero_Cryptonote();
|
||||
if(self::$confirm_type == 'wownero-wallet-rpc') {
|
||||
require_once('class-wownero-wallet-rpc.php');
|
||||
self::$wownero_wallet_rpc = new Wownero_Wallet_Rpc(self::$host, self::$port);
|
||||
self::$monero_wallet_rpc = new Monero_Wallet_Rpc(self::$host, self::$port);
|
||||
} else {
|
||||
require_once('class-wownero-explorer-tools.php');
|
||||
self::$wownero_explorer_tools = new Wownero_Explorer_Tools(self::$testnet);
|
||||
require_once('class-monero-explorer-tools.php');
|
||||
self::$monero_explorer_tools = new Monero_Explorer_Tools(self::$testnet);
|
||||
}
|
||||
|
||||
self::$log = new WC_Logger();
|
||||
|
@ -104,13 +109,13 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
|
||||
public function init_form_fields()
|
||||
{
|
||||
$this->form_fields = include 'admin/wownero-gateway-admin-settings.php';
|
||||
$this->form_fields = include 'admin/monero-gateway-admin-settings.php';
|
||||
}
|
||||
|
||||
public function validate_wownero_address_field($key,$address)
|
||||
public function validate_monero_address_field($key,$address)
|
||||
{
|
||||
if($this->settings['confirm_type'] == 'viewkey') {
|
||||
if (strlen($address) == 97 && substr($address, 0, 1) == 'W')
|
||||
if (strlen($address) == 97)
|
||||
if(self::$cryptonote->verify_checksum($address))
|
||||
return $address;
|
||||
self::$_errors[] = 'Wownero address is invalid';
|
||||
|
@ -153,7 +158,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
|
||||
$settings_html = $this->generate_settings_html(array(), false);
|
||||
$errors = array_merge(self::$_errors, $this->admin_php_module_check(), $this->admin_ssl_check());
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/admin/settings-page.php';
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/admin/settings-page.php';
|
||||
}
|
||||
|
||||
public static function admin_balance_info()
|
||||
|
@ -165,11 +170,11 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
'unlocked_balance' => 'Not Available',
|
||||
);
|
||||
}
|
||||
$wallet_amount = self::$wownero_wallet_rpc->getbalance();
|
||||
$height = self::$wownero_wallet_rpc->getheight();
|
||||
$wallet_amount = self::$monero_wallet_rpc->getbalance();
|
||||
$height = self::$monero_wallet_rpc->getheight();
|
||||
if (!isset($wallet_amount)) {
|
||||
self::$_errors[] = 'Cannot connect to wownero-wallet-rpc';
|
||||
self::$log->add('Wownero_Payments', '[ERROR] Cannot connect to wownero-wallet-rpc');
|
||||
self::$log->add('Monero_Payments', '[ERROR] Cannot connect to wownero-wallet-rpc');
|
||||
return array(
|
||||
'height' => 'Not Available',
|
||||
'balance' => 'Not Available',
|
||||
|
@ -178,8 +183,8 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
} else {
|
||||
return array(
|
||||
'height' => $height,
|
||||
'balance' => self::format_wownero($wallet_amount['balance']).' Wownero',
|
||||
'unlocked_balance' => self::format_wownero($wallet_amount['unlocked_balance']).' Wownero'
|
||||
'balance' => self::format_monero($wallet_amount['balance']).' Wownero',
|
||||
'unlocked_balance' => self::format_monero($wallet_amount['unlocked_balance']).' Wownero'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -204,32 +209,54 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
public function process_payment($order_id)
|
||||
{
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix.'wownero_gateway_quotes';
|
||||
$table_name = $wpdb->prefix.'monero_gateway_quotes';
|
||||
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if(self::$confirm_type != 'wownero-wallet-rpc') {
|
||||
// Generate a unique payment id
|
||||
do {
|
||||
$payment_id = bin2hex(openssl_random_pseudo_bytes(8));
|
||||
$query = $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE payment_id=%s", array($payment_id));
|
||||
$payment_id_used = $wpdb->get_var($query);
|
||||
} while ($payment_id_used);
|
||||
}
|
||||
else {
|
||||
// Generate subaddress
|
||||
$payment_id = self::$monero_wallet_rpc->create_address(0, 'Order: ' . $order_id);
|
||||
if(isset($payment_id['address'])) {
|
||||
$payment_id = $payment_id['address'];
|
||||
}
|
||||
else {
|
||||
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('');
|
||||
$wownero_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 Wownero 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)
|
||||
$wownero_amount = $wownero_amount - $wownero_amount * self::$discount / 100;
|
||||
$monero_amount = $monero_amount - $monero_amount * self::$discount / 100;
|
||||
|
||||
$wownero_amount = intval($wownero_amount * MONERO_GATEWAY_ATOMIC_UNITS_POW);
|
||||
$monero_amount = intval($monero_amount * MONERO_GATEWAY_ATOMIC_UNITS_POW);
|
||||
|
||||
$query = $wpdb->prepare("INSERT INTO $table_name (order_id, payment_id, currency, rate, amount) VALUES (%d, %s, %s, %d, %d)", array($order_id, $payment_id, $currency, $rate, $wownero_amount));
|
||||
$query = $wpdb->prepare("INSERT INTO $table_name (order_id, payment_id, currency, rate, amount) VALUES (%d, %s, %s, %d, %d)", array($order_id, $payment_id, $currency, $rate, $monero_amount));
|
||||
$wpdb->query($query);
|
||||
|
||||
$order->update_status('on-hold', __('Awaiting offline payment', 'wownero_gateway'));
|
||||
$order->reduce_order_stock(); // Reduce stock levels
|
||||
wc_reduce_stock_levels( $order_id );
|
||||
WC()->cart->empty_cart(); // Remove cart
|
||||
|
||||
return array(
|
||||
|
@ -242,12 +269,12 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
* function for verifying payments
|
||||
* This cron runs every 30 seconds
|
||||
*/
|
||||
|
||||
public static function do_update_event()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
// Get usd and btc price for wownero
|
||||
// Get Live Price
|
||||
$currencies = implode(',', self::$currencies);
|
||||
$api_link = 'https://api.coingecko.com/api/v3/coins/wownero/tickers?page=1';
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
|
@ -256,56 +283,36 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
));
|
||||
$resp = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$price = json_decode($resp, true);
|
||||
if( ! isset( $price['tickers'][0]['converted_last']['usd'] ) ||
|
||||
! isset( $price['tickers'][0]['converted_last']['btc'] ) ) {
|
||||
$this->log->add('Wownero_Gateway', '[ERROR] coingecko.com api');
|
||||
}
|
||||
else {
|
||||
$usd = $price['tickers'][0]['converted_last']['usd'];
|
||||
$btc = $price['tickers'][0]['converted_last']['btc'];
|
||||
$json = json_decode($resp, true);
|
||||
$price = $json['tickers'][0]['converted_last']['usd'];
|
||||
|
||||
// get other currency rates based off usd
|
||||
$api_link = 'https://api.exchangeratesapi.io/latest?base=USD';
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $api_link,
|
||||
));
|
||||
$resp = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$price = json_decode($resp, true);
|
||||
|
||||
if( ! isset( $price['rates'] ) ) {
|
||||
$this->log->add('Wownero_Gateway', '[ERROR] exchangeratesapi.io');
|
||||
}
|
||||
else {
|
||||
$rates = $price['rates'];
|
||||
$table_name = $wpdb->prefix.'wownero_gateway_live_rates';
|
||||
// usd
|
||||
$query = $wpdb->prepare("INSERT INTO $table_name (currency, rate, updated) VALUES (%s, %d, NOW()) ON DUPLICATE KEY UPDATE rate=%d, updated=NOW()", array('BTC', $btc, $btc));
|
||||
|
||||
$query = $wpdb->prepare("INSERT INTO $table_name (currency, rate, updated) VALUES (%s, %d, NOW()) ON DUPLICATE KEY UPDATE rate=%d, updated=NOW()", array('USD', $usd, $usd));
|
||||
foreach( $rates as $currency=>$rate ) {
|
||||
if( $currency == 'USD' ) continue;
|
||||
if(!isset($price['Response']) || $price['Response'] != 'Error') {
|
||||
$table_name = $wpdb->prefix.'monero_gateway_live_rates';
|
||||
foreach($price 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, $usd*$rate, $usd*$rate));
|
||||
$wpdb->query($query);
|
||||
}
|
||||
}
|
||||
$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);
|
||||
if(!$result){
|
||||
self::$log->add('Wownero_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 coingecko.com.");
|
||||
}
|
||||
|
||||
// Get current network/wallet height
|
||||
if(self::$confirm_type == 'wownero-wallet-rpc')
|
||||
$height = self::$wownero_wallet_rpc->getheight();
|
||||
$height = self::$monero_wallet_rpc->getheight();
|
||||
else
|
||||
$height = self::$wownero_explorer_tools->getheight();
|
||||
set_transient('wownero_gateway_network_height', $height);
|
||||
$height = self::$monero_explorer_tools->getheight();
|
||||
set_transient('monero_gateway_network_height', $height);
|
||||
|
||||
// Get pending payments
|
||||
$table_name_1 = $wpdb->prefix.'wownero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'wownero_gateway_quotes_txids';
|
||||
$table_name_1 = $wpdb->prefix.'monero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'monero_gateway_quotes_txids';
|
||||
|
||||
$query = $wpdb->prepare("SELECT *, $table_name_1.payment_id AS payment_id, $table_name_1.amount AS amount_total, $table_name_2.amount AS amount_paid, NOW() as now FROM $table_name_1 LEFT JOIN $table_name_2 ON $table_name_1.payment_id = $table_name_2.payment_id WHERE pending=1", array());
|
||||
$rows = $wpdb->get_results($query);
|
||||
|
@ -331,7 +338,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$order_id = $quote->order_id;
|
||||
$order = wc_get_order($order_id);
|
||||
$payment_id = self::sanatize_id($quote->payment_id);
|
||||
$amount_wownero = $quote->amount_total;
|
||||
$amount_monero = $quote->amount_total;
|
||||
|
||||
if(self::$confirm_type == 'wownero-wallet-rpc')
|
||||
$new_txs = self::check_payment_rpc($payment_id);
|
||||
|
@ -362,7 +369,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$heights[] = $tx->height;
|
||||
}
|
||||
|
||||
$paid = $amount_paid > $amount_wownero - MONERO_GATEWAY_ATOMIC_UNIT_THRESHOLD;
|
||||
$paid = $amount_paid > $amount_monero - MONERO_GATEWAY_ATOMIC_UNIT_THRESHOLD;
|
||||
|
||||
if($paid) {
|
||||
if(self::$confirms == 0) {
|
||||
|
@ -380,7 +387,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
}
|
||||
|
||||
if($paid && $confirmed) {
|
||||
self::$log->add('Wownero_Payments', "[SUCCESS] Payment has been confirmed for order id $order_id and payment id $payment_id");
|
||||
self::$log->add('Monero_Payments', "[SUCCESS] Payment has been confirmed for order id $order_id and payment id $payment_id");
|
||||
$query = $wpdb->prepare("UPDATE $table_name_1 SET confirmed=1,paid=1,pending=0 WHERE payment_id=%s", array($payment_id));
|
||||
$wpdb->query($query);
|
||||
|
||||
|
@ -393,7 +400,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
}
|
||||
|
||||
} else if($paid) {
|
||||
self::$log->add('Wownero_Payments', "[SUCCESS] Payment has been received for order id $order_id and payment id $payment_id");
|
||||
self::$log->add('Monero_Payments', "[SUCCESS] Payment has been received for order id $order_id and payment id $payment_id");
|
||||
$query = $wpdb->prepare("UPDATE $table_name_1 SET paid=1 WHERE payment_id=%s", array($payment_id));
|
||||
$wpdb->query($query);
|
||||
|
||||
|
@ -404,7 +411,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$timestamp_now = new DateTime($quote->now);
|
||||
$order_age_seconds = $timestamp_now->getTimestamp() - $timestamp_created->getTimestamp();
|
||||
if($order_age_seconds > self::$valid_time) {
|
||||
self::$log->add('Wownero_Payments', "[FAILED] Payment has expired for order id $order_id and payment id $payment_id");
|
||||
self::$log->add('Monero_Payments', "[FAILED] Payment has expired for order id $order_id and payment id $payment_id");
|
||||
$query = $wpdb->prepare("UPDATE $table_name_1 SET pending=0 WHERE payment_id=%s", array($payment_id));
|
||||
$wpdb->query($query);
|
||||
|
||||
|
@ -416,24 +423,43 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
}
|
||||
}
|
||||
|
||||
protected static function check_payment_rpc($payment_id)
|
||||
protected static function check_payment_rpc($subaddress)
|
||||
{
|
||||
$txs = array();
|
||||
$payments = self::$wownero_wallet_rpc->get_all_payments($payment_id);
|
||||
foreach($payments as $payment) {
|
||||
$address_index = self::$monero_wallet_rpc->get_address_index($subaddress);
|
||||
if(isset($address_index['index']['minor'])){
|
||||
$address_index = $address_index['index']['minor'];
|
||||
}
|
||||
else {
|
||||
self::$log->add('Monero_Gateway', '[ERROR] Couldn\'t get address index of subaddress: ' . $subaddress);
|
||||
return $txs;
|
||||
}
|
||||
$payments = self::$monero_wallet_rpc->get_transfers(array( 'in' => true, 'pool' => true, 'subaddr_indices' => array($address_index)));
|
||||
if(isset($payments['in'])) {
|
||||
foreach($payments['in'] as $payment) {
|
||||
$txs[] = array(
|
||||
'amount' => $payment['amount'],
|
||||
'txid' => $payment['tx_hash'],
|
||||
'height' => $payment['block_height']
|
||||
'txid' => $payment['txid'],
|
||||
'height' => $payment['height']
|
||||
);
|
||||
}
|
||||
}
|
||||
if(isset($payments['pool'])) {
|
||||
foreach($payments['pool'] as $payment) {
|
||||
$txs[] = array(
|
||||
'amount' => $payment['amount'],
|
||||
'txid' => $payment['txid'],
|
||||
'height' => $payment['height']
|
||||
);
|
||||
}
|
||||
}
|
||||
return $txs;
|
||||
}
|
||||
|
||||
public static function check_payment_explorer($payment_id)
|
||||
{
|
||||
$txs = array();
|
||||
$outputs = self::$wownero_explorer_tools->get_outputs(self::$address, self::$viewkey);
|
||||
$outputs = self::$monero_explorer_tools->get_outputs(self::$address, self::$viewkey);
|
||||
foreach($outputs as $payment) {
|
||||
if($payment['payment_id'] == $payment_id) {
|
||||
$txs[] = array(
|
||||
|
@ -455,8 +481,8 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
return self::$payment_details[$order_id];
|
||||
|
||||
global $wpdb;
|
||||
$table_name_1 = $wpdb->prefix.'wownero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'wownero_gateway_quotes_txids';
|
||||
$table_name_1 = $wpdb->prefix.'monero_gateway_quotes';
|
||||
$table_name_2 = $wpdb->prefix.'monero_gateway_quotes_txids';
|
||||
$query = $wpdb->prepare("SELECT *, $table_name_1.payment_id AS payment_id, $table_name_1.amount AS amount_total, $table_name_2.amount AS amount_paid, NOW() as now FROM $table_name_1 LEFT JOIN $table_name_2 ON $table_name_1.payment_id = $table_name_2.payment_id WHERE order_id=%d", array($order_id));
|
||||
$details = $wpdb->get_results($query);
|
||||
if (count($details)) {
|
||||
|
@ -470,7 +496,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
'txid' => $tx->txid,
|
||||
'height' => $tx->height,
|
||||
'amount' => $tx->amount_paid,
|
||||
'amount_formatted' => self::format_wownero($tx->amount_paid)
|
||||
'amount_formatted' => self::format_monero($tx->amount_paid)
|
||||
);
|
||||
$amount_paid += $tx->amount_paid;
|
||||
$heights[] = $tx->height;
|
||||
|
@ -482,7 +508,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
});
|
||||
|
||||
if(count($heights) && !in_array(0, $heights)) {
|
||||
$height = get_transient('wownero_gateway_network_height');
|
||||
$height = get_transient('monero_gateway_network_height');
|
||||
$highest_block = max($heights);
|
||||
$confirms = $height - $highest_block;
|
||||
$blocks_to_confirm = self::$confirms - $confirms;
|
||||
|
@ -504,13 +530,7 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$payment_id = self::sanatize_id($details[0]->payment_id);
|
||||
|
||||
if(self::$confirm_type == 'wownero-wallet-rpc') {
|
||||
$array_integrated_address = self::$wownero_wallet_rpc->make_integrated_address($payment_id);
|
||||
if (isset($array_integrated_address['integrated_address'])) {
|
||||
$integrated_addr = $array_integrated_address['integrated_address'];
|
||||
} else {
|
||||
self::$log->add('Wownero_Gateway', '[ERROR] Unable get integrated address');
|
||||
return '[ERROR] Unable get integrated address';
|
||||
}
|
||||
$integrated_addr = $payment_id;
|
||||
} else {
|
||||
if ($address) {
|
||||
$decoded_address = self::$cryptonote->decode_address($address);
|
||||
|
@ -546,7 +566,8 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
}
|
||||
}
|
||||
|
||||
$qrcode_uri = 'wownero:'.$address.'?tx_amount='.$amount_due.'&tx_payment_id='.$payment_id;
|
||||
$amount_formatted = self::format_monero($amount_due);
|
||||
$qrcode_uri = 'monero:'.$integrated_addr.'?tx_amount='.$amount_formatted.'&tx_payment_id='.$payment_id;
|
||||
$my_order_url = wc_get_endpoint_url('view-order', $order_id, wc_get_page_permalink('myaccount'));
|
||||
|
||||
$payment_details = array(
|
||||
|
@ -561,9 +582,9 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
'amount_total' => $amount_total,
|
||||
'amount_paid' => $amount_paid,
|
||||
'amount_due' => $amount_due,
|
||||
'amount_total_formatted' => self::format_wownero($amount_total),
|
||||
'amount_paid_formatted' => self::format_wownero($amount_paid),
|
||||
'amount_due_formatted' => self::format_wownero($amount_due),
|
||||
'amount_total_formatted' => self::format_monero($amount_total),
|
||||
'amount_paid_formatted' => self::format_monero($amount_paid),
|
||||
'amount_due_formatted' => self::format_monero($amount_due),
|
||||
'status' => $status,
|
||||
'created' => $details[0]->created,
|
||||
'order_age' => $order_age_seconds,
|
||||
|
@ -586,10 +607,11 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
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 );
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if($order->user_id != $user->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)
|
||||
|
@ -600,11 +622,13 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
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();
|
||||
}
|
||||
|
@ -619,10 +643,10 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$details = self::get_payment_details($order);
|
||||
if(!is_array($details)) {
|
||||
$error = $details;
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/admin/order-history-error-page.php';
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/admin/order-history-error-page.php';
|
||||
return;
|
||||
}
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/admin/order-history-page.php';
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/admin/order-history-page.php';
|
||||
}
|
||||
|
||||
public static function customer_order_page($order)
|
||||
|
@ -641,13 +665,13 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$details = self::get_payment_details($order_id);
|
||||
if(!is_array($details)) {
|
||||
$error = $details;
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/customer/order-error-page.php';
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/customer/order-error-page.php';
|
||||
return;
|
||||
}
|
||||
$show_qr = self::$show_qr;
|
||||
$details_json = json_encode($details);
|
||||
$ajax_url = WC_AJAX::get_endpoint('wownero_gateway_payment_details');
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/customer/order-page.php';
|
||||
$ajax_url = WC_AJAX::get_endpoint('monero_gateway_payment_details');
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/customer/order-page.php';
|
||||
}
|
||||
|
||||
public static function customer_order_email($order)
|
||||
|
@ -665,10 +689,10 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
$method_title = self::$_title;
|
||||
$details = self::get_payment_details($order_id);
|
||||
if(!is_array($details)) {
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/customer/order-email-error-block.php';
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/customer/order-email-error-block.php';
|
||||
return;
|
||||
}
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/wownero-gateway/customer/order-email-block.php';
|
||||
include MONERO_GATEWAY_PLUGIN_DIR . '/templates/monero-gateway/customer/order-email-block.php';
|
||||
}
|
||||
|
||||
public static function get_id()
|
||||
|
@ -686,22 +710,22 @@ class Wownero_Gateway extends WC_Payment_Gateway
|
|||
return self::$show_qr;
|
||||
}
|
||||
|
||||
public static function use_wownero_price()
|
||||
public static function use_monero_price()
|
||||
{
|
||||
return self::$use_wownero_price;
|
||||
return self::$use_monero_price;
|
||||
}
|
||||
|
||||
|
||||
public static function convert_wc_price($price, $currency)
|
||||
{
|
||||
$rate = self::get_live_rate($currency);
|
||||
$wownero_amount = intval(MONERO_GATEWAY_ATOMIC_UNITS_POW * 1e8 * $price / $rate) / MONERO_GATEWAY_ATOMIC_UNITS_POW;
|
||||
$wownero_amount_formatted = sprintf('%.'.self::$use_wownero_price_decimals.'f', $wownero_amount);
|
||||
$monero_amount = intval(MONERO_GATEWAY_ATOMIC_UNITS_POW * 1e8 * $price / $rate) / MONERO_GATEWAY_ATOMIC_UNITS_POW;
|
||||
$monero_amount_formatted = sprintf('%.'.self::$use_monero_price_decimals.'f', $monero_amount);
|
||||
|
||||
return <<<HTML
|
||||
<span class="woocommerce-Price-amount amount" data-price="$price" data-currency="$currency"
|
||||
data-rate="$rate" data-rate-type="live">
|
||||
$wownero_amount_formatted
|
||||
$monero_amount_formatted
|
||||
<span class="woocommerce-Price-currencySymbol">WOW</span>
|
||||
</span>
|
||||
|
||||
|
@ -726,13 +750,13 @@ HTML;
|
|||
$price = array_pop($matches);
|
||||
$currency = $payment_details['currency'];
|
||||
$rate = $payment_details['rate'];
|
||||
$wownero_amount = intval(MONERO_GATEWAY_ATOMIC_UNITS_POW * 1e8 * $price / $rate) / MONERO_GATEWAY_ATOMIC_UNITS_POW;
|
||||
$wownero_amount_formatted = sprintf('%.'.MONERO_GATEWAY_ATOMIC_UNITS.'f', $wownero_amount);
|
||||
$monero_amount = intval(MONERO_GATEWAY_ATOMIC_UNITS_POW * 1e8 * $price / $rate) / MONERO_GATEWAY_ATOMIC_UNITS_POW;
|
||||
$monero_amount_formatted = sprintf('%.'.MONERO_GATEWAY_ATOMIC_UNITS.'f', $monero_amount);
|
||||
|
||||
return <<<HTML
|
||||
<span class="woocommerce-Price-amount amount" data-price="$price" data-currency="$currency"
|
||||
data-rate="$rate" data-rate-type="fixed">
|
||||
$wownero_amount_formatted
|
||||
$monero_amount_formatted
|
||||
<span class="woocommerce-Price-currencySymbol">WOW</span>
|
||||
</span>
|
||||
|
||||
|
@ -745,7 +769,7 @@ HTML;
|
|||
return self::$rates[$currency];
|
||||
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix.'wownero_gateway_live_rates';
|
||||
$table_name = $wpdb->prefix.'monero_gateway_live_rates';
|
||||
$query = $wpdb->prepare("SELECT rate FROM $table_name WHERE currency=%s", array($currency));
|
||||
|
||||
$rate = $wpdb->get_row($query)->rate;
|
||||
|
@ -777,7 +801,7 @@ HTML;
|
|||
return $virtual_items == $cart_size;
|
||||
}
|
||||
|
||||
public static function format_wownero($atomic_units) {
|
||||
public static function format_monero($atomic_units) {
|
||||
return sprintf(MONERO_GATEWAY_ATOMIC_UNITS_SPRINTF, $atomic_units / MONERO_GATEWAY_ATOMIC_UNITS_POW);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* wownero_wallet_rpc
|
||||
* monero_wallet_rpc
|
||||
*
|
||||
* Written using the JSON RPC specification -
|
||||
* http://json-rpc.org/wiki/specification
|
||||
|
@ -8,12 +8,11 @@
|
|||
* @author Kacper Rowinski <krowinski@implix.com>
|
||||
* http://implix.com
|
||||
* Modified to work with monero-rpc wallet by Serhack and cryptochangements
|
||||
* Modified to work with monero-wallet-rpc wallet by mosu-forge
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Wownero_Wallet_Rpc
|
||||
class Monero_Wallet_Rpc
|
||||
{
|
||||
protected $url = null, $is_debug = false;
|
||||
protected $curl_options = array(
|
||||
|
@ -214,7 +213,7 @@ class Wownero_Wallet_Rpc
|
|||
}
|
||||
|
||||
/*
|
||||
* The following functions can all be called to interact with the Wownero RPC wallet
|
||||
* The following functions can all be called to interact with the Monero RPC wallet
|
||||
* They will majority of them will return the result as an array
|
||||
* Example: $daemon->address(); where $daemon is an instance of this class, will return the wallet address as string within an array
|
||||
*/
|
||||
|
@ -244,13 +243,6 @@ class Wownero_Wallet_Rpc
|
|||
return $incoming_transfers;
|
||||
}
|
||||
|
||||
public function get_transfers($input_type, $input_value)
|
||||
{
|
||||
$get_parameters = array($input_type => $input_value);
|
||||
$get_transfers = $this->_run('get_transfers', $get_parameters);
|
||||
return $get_transfers;
|
||||
}
|
||||
|
||||
public function view_key()
|
||||
{
|
||||
$query_key = array('key_type' => 'view_key');
|
||||
|
@ -349,4 +341,30 @@ class Wownero_Wallet_Rpc
|
|||
$get_bulk_payments = $this->_run('get_bulk_payments', $get_bulk_payments_parameters);
|
||||
return $get_bulk_payments;
|
||||
}
|
||||
|
||||
public function get_transfers($arr)
|
||||
{
|
||||
$get_parameters = $arr;
|
||||
$get_transfers = $this->_run('get_transfers', $get_parameters);
|
||||
return $get_transfers;
|
||||
}
|
||||
|
||||
public function get_address_index($subaddress)
|
||||
{
|
||||
$params = array('address' => $subaddress);
|
||||
return $this->_run('get_address_index', $params);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
return $this->_run('store');
|
||||
}
|
||||
|
||||
public function create_address($account_index = 0, $label = '')
|
||||
{
|
||||
$params = array('account_index' => $account_index, 'label' => $label);
|
||||
$create_address_method = $this->_run('create_address', $params);
|
||||
$save = $this->store(); // Save wallet state after subaddress creation
|
||||
return $create_address_method;
|
||||
}
|
||||
}
|
|
@ -1,354 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* base58.php
|
||||
*
|
||||
* PHP Base58 codec
|
||||
*
|
||||
* Based on https://github.com/MoneroPy/moneropy/base58.py and https://github.com/mymonero/mymonero-core-js/cryptonote_utils/cryptonote_base58.js
|
||||
*
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Wownero_base58 {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static $alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
static $encoded_block_sizes = [0, 2, 3, 5, 6, 7, 9, 10, 11];
|
||||
static $full_block_size = 8;
|
||||
static $full_encoded_block_size = 11;
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a hexadecimal string to a binary array
|
||||
*
|
||||
* @param string $hex A hexadecimal string to convert to a binary array
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function hex_to_bin($hex) {
|
||||
if (gettype($hex) != 'string') {
|
||||
throw new Exception('base58->hex_to_bin(): Invalid input type (must be a string)');
|
||||
}
|
||||
if (strlen($hex) % 2 != 0) {
|
||||
throw new Exception('base58->hex_to_bin(): Invalid input length (must be even)');
|
||||
}
|
||||
|
||||
$res = array_fill(0, strlen($hex) / 2, 0);
|
||||
for ($i = 0; $i < strlen($hex) / 2; $i++) {
|
||||
$res[$i] = intval(substr($hex, $i * 2, $i * 2 + 2 - $i * 2), 16);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a binary array to a hexadecimal string
|
||||
*
|
||||
* @param array $bin A binary array to convert to a hexadecimal string
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
private function bin_to_hex($bin) {
|
||||
if (gettype($bin) != 'array') {
|
||||
throw new Exception('base58->bin_to_hex(): Invalid input type (must be an array)');
|
||||
}
|
||||
|
||||
$res = [];
|
||||
for ($i = 0; $i < count($bin); $i++) {
|
||||
$res[] = substr('0'.dechex($bin[$i]), -2);
|
||||
}
|
||||
return join($res);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a string to a binary array
|
||||
*
|
||||
* @param string $str A string to convert to a binary array
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function str_to_bin($str) {
|
||||
if (gettype($str) != 'string') {
|
||||
throw new Exception('base58->str_to_bin(): Invalid input type (must be a string)');
|
||||
}
|
||||
|
||||
$res = array_fill(0, strlen($str), 0);
|
||||
for ($i = 0; $i < strlen($str); $i++) {
|
||||
$res[$i] = ord($str[$i]);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a binary array to a string
|
||||
*
|
||||
* @param array $bin A binary array to convert to a string
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
private function bin_to_str($bin) {
|
||||
if (gettype($bin) != 'array') {
|
||||
throw new Exception('base58->bin_to_str(): Invalid input type (must be an array)');
|
||||
}
|
||||
|
||||
$res = array_fill(0, count($bin), 0);
|
||||
for ($i = 0; $i < count($bin); $i++) {
|
||||
$res[$i] = chr($bin[$i]);
|
||||
}
|
||||
return preg_replace('/[[:^print:]]/', '', join($res)); // preg_replace necessary to strip errant non-ASCII characters eg. ''
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a UInt8BE (one unsigned big endian byte) array to UInt64
|
||||
*
|
||||
* @param array $data A UInt8BE array to convert to UInt64
|
||||
* @return number
|
||||
*
|
||||
*/
|
||||
private function uint8_be_to_64($data) {
|
||||
if (gettype($data) != 'array') {
|
||||
throw new Exception ('base58->uint8_be_to_64(): Invalid input type (must be an array)');
|
||||
}
|
||||
|
||||
$res = 0;
|
||||
$i = 0;
|
||||
switch (9 - count($data)) {
|
||||
case 1:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 2:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 3:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 4:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 5:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 6:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 7:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
case 8:
|
||||
$res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('base58->uint8_be_to_64: Invalid input length (1 <= count($data) <= 8)');
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a UInt64 (unsigned 64 bit integer) to a UInt8BE array
|
||||
*
|
||||
* @param number $num A UInt64 number to convert to a UInt8BE array
|
||||
* @param integer $size Size of array to return
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function uint64_to_8_be($num, $size) {
|
||||
if (gettype($num) != ('integer' || 'double')) {
|
||||
throw new Exception ('base58->uint64_to_8_be(): Invalid input type ($num must be a number)');
|
||||
}
|
||||
if (gettype($size) != 'integer') {
|
||||
throw new Exception ('base58->uint64_to_8_be(): Invalid input type ($size must be an integer)');
|
||||
}
|
||||
if ($size < 1 || $size > 8) {
|
||||
throw new Exception ('base58->uint64_to_8_be(): Invalid size (1 <= $size <= 8)');
|
||||
}
|
||||
|
||||
$res = array_fill(0, $size, 0);
|
||||
for ($i = $size - 1; $i >= 0; $i--) {
|
||||
$res[$i] = bcmod($num, bcpow(2, 8));
|
||||
$num = bcdiv($num, bcpow(2, 8));
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a hexadecimal (Base16) array to a Base58 string
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $buf
|
||||
* @param number $index
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function encode_block($data, $buf, $index) {
|
||||
if (gettype($data) != 'array') {
|
||||
throw new Exception('base58->encode_block(): Invalid input type ($data must be an array)');
|
||||
}
|
||||
if (gettype($buf) != 'array') {
|
||||
throw new Exception('base58->encode_block(): Invalid input type ($buf must be an array)');
|
||||
}
|
||||
if (gettype($index) != ('integer' || 'double')) {
|
||||
throw new Exception('base58->encode_block(): Invalid input type ($index must be a number)');
|
||||
}
|
||||
if (count($data) < 1 or count($data) > self::$full_encoded_block_size) {
|
||||
throw new Exception('base58->encode_block(): Invalid input length (1 <= count($data) <= 8)');
|
||||
}
|
||||
|
||||
$num = self::uint8_be_to_64($data);
|
||||
$i = self::$encoded_block_sizes[count($data)] - 1;
|
||||
while ($num > 0) {
|
||||
$remainder = bcmod($num, 58);
|
||||
$num = bcdiv($num, 58);
|
||||
$buf[$index + $i] = ord(self::$alphabet[$remainder]);
|
||||
$i--;
|
||||
}
|
||||
return $buf;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Encode a hexadecimal (Base16) string to Base58
|
||||
*
|
||||
* @param string $hex A hexadecimal (Base16) string to convert to Base58
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function encode($hex) {
|
||||
if (gettype($hex) != 'string') {
|
||||
throw new Exception ('base58->encode(): Invalid input type (must be a string)');
|
||||
}
|
||||
|
||||
$data = self::hex_to_bin($hex);
|
||||
if (count($data) == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$full_block_count = floor(count($data) / self::$full_block_size);
|
||||
$last_block_size = count($data) % self::$full_block_size;
|
||||
$res_size = $full_block_count * self::$full_encoded_block_size + self::$encoded_block_sizes[$last_block_size];
|
||||
|
||||
$res = array_fill(0, $res_size, 0);
|
||||
for ($i = 0; $i < $res_size; $i++) {
|
||||
$res[$i] = self::$alphabet[0];
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $full_block_count; $i++) {
|
||||
$res = self::encode_block(array_slice($data, $i * self::$full_block_size, ($i * self::$full_block_size + self::$full_block_size) - ($i * self::$full_block_size)), $res, $i * self::$full_encoded_block_size);
|
||||
}
|
||||
|
||||
if ($last_block_size > 0) {
|
||||
$res = self::encode_block(array_slice($data, $full_block_count * self::$full_block_size, $full_block_count * self::$full_block_size + $last_block_size), $res, $full_block_count * self::$full_encoded_block_size);
|
||||
}
|
||||
|
||||
return self::bin_to_str($res);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a Base58 input to hexadecimal (Base16)
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $buf
|
||||
* @param integer $index
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
private function decode_block($data, $buf, $index) {
|
||||
if (gettype($data) != 'array') {
|
||||
throw new Exception('base58->decode_block(): Invalid input type ($data must be an array)');
|
||||
}
|
||||
if (gettype($buf) != 'array') {
|
||||
throw new Exception('base58->decode_block(): Invalid input type ($buf must be an array)');
|
||||
}
|
||||
if (gettype($index) != ('integer' || 'double')) {
|
||||
throw new Exception('base58->decode_block(): Invalid input type ($index must be a number)');
|
||||
}
|
||||
|
||||
$res_size = self::index_of(self::$encoded_block_sizes, count($data));
|
||||
if ($res_size <= 0) {
|
||||
throw new Exception('base58->decode_block(): Invalid input length ($data must be a value from base58::$encoded_block_sizes)');
|
||||
}
|
||||
|
||||
$res_num = 0;
|
||||
$order = 1;
|
||||
for ($i = count($data) - 1; $i >= 0; $i--) {
|
||||
$digit = strpos(self::$alphabet, chr($data[$i]));
|
||||
if ($digit < 0) {
|
||||
throw new Exception("base58->decode_block(): Invalid character ($digit \"{$digit}\" not found in base58::$alphabet)");
|
||||
}
|
||||
|
||||
$product = bcadd(bcmul($order, $digit), $res_num);
|
||||
if ($product > bcpow(2, 64)) {
|
||||
throw new Exception('base58->decode_block(): Integer overflow ($product exceeds the maximum 64bit integer)');
|
||||
}
|
||||
|
||||
$res_num = $product;
|
||||
$order = bcmul($order, 58);
|
||||
}
|
||||
if ($res_size < self::$full_block_size && bcpow(2, 8 * $res_size) <= 0) {
|
||||
throw new Exception('base58->decode_block(): Integer overflow (bcpow(2, 8 * $res_size) exceeds the maximum 64bit integer)');
|
||||
}
|
||||
|
||||
$tmp_buf = self::uint64_to_8_be($res_num, $res_size);
|
||||
for ($i = 0; $i < count($tmp_buf); $i++) {
|
||||
$buf[$i + $index] = $tmp_buf[$i];
|
||||
}
|
||||
return $buf;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Decode a Base58 string to hexadecimal (Base16)
|
||||
*
|
||||
* @param string $hex A Base58 string to convert to hexadecimal (Base16)
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function decode($enc) {
|
||||
if (gettype($enc) != 'string') {
|
||||
throw new Exception ('base58->decode(): Invalid input type (must be a string)');
|
||||
}
|
||||
|
||||
$enc = self::str_to_bin($enc);
|
||||
if (count($enc) == 0) {
|
||||
return '';
|
||||
}
|
||||
$full_block_count = floor(bcdiv(count($enc), self::$full_encoded_block_size));
|
||||
$last_block_size = bcmod(count($enc), self::$full_encoded_block_size);
|
||||
$last_block_decoded_size = self::index_of(self::$encoded_block_sizes, $last_block_size);
|
||||
|
||||
$data_size = $full_block_count * self::$full_block_size + $last_block_decoded_size;
|
||||
|
||||
$data = array_fill(0, $data_size, 0);
|
||||
for ($i = 0; $i < $full_block_count; $i++) {
|
||||
$data = self::decode_block(array_slice($enc, $i * self::$full_encoded_block_size, ($i * self::$full_encoded_block_size + self::$full_encoded_block_size) - ($i * self::$full_encoded_block_size)), $data, $i * self::$full_block_size);
|
||||
}
|
||||
|
||||
if ($last_block_size > 0) {
|
||||
$data = self::decode_block(array_slice($enc, $full_block_count * self::$full_encoded_block_size, $full_block_count * self::$full_encoded_block_size + $last_block_size), $data, $full_block_count * self::$full_block_size);
|
||||
}
|
||||
|
||||
return self::bin_to_hex($data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Search an array for a value
|
||||
* Source: https://stackoverflow.com/a/30994678
|
||||
*
|
||||
* @param array $haystack An array to search
|
||||
* @param string $needle A string to search for
|
||||
* @return number The index of the element found (or -1 for no match)
|
||||
*
|
||||
*/
|
||||
private function index_of($haystack, $needle) {
|
||||
if (gettype($haystack) != 'array') {
|
||||
throw new Exception ('base58->decode(): Invalid input type ($haystack must be an array)');
|
||||
}
|
||||
// if (gettype($needle) != 'string') {
|
||||
// throw new Exception ('base58->decode(): Invalid input type ($needle must be a string)');
|
||||
// }
|
||||
|
||||
foreach ($haystack as $key => $value) if ($value === $needle) return $key;
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -1,25 +1,25 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: Wownero Woocommerce Gateway
|
||||
Plugin Name: Monero Woocommerce Gateway
|
||||
Plugin URI: https://github.com/monero-integrations/monerowp
|
||||
Description: Extends WooCommerce by adding a Wownero Gateway
|
||||
Version: 3.0.0
|
||||
Version: 3.0.1
|
||||
Tested up to: 4.9.8
|
||||
Author: mosu-forge, SerHack
|
||||
Author: SerHack
|
||||
Author URI: https://monerointegrations.com/
|
||||
*/
|
||||
// This code isn't for Dark Net Markets, please report them to Authority!
|
||||
// This code is for Dark Net Markets
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
// Constants, you can edit these if you fork this repo
|
||||
define('MONERO_GATEWAY_MAINNET_EXPLORER_URL', 'https://explore.wownero.com/');
|
||||
define('MONERO_GATEWAY_TESTNET_EXPLORER_URL', 'http://explorer.wowne.ro:8082/');
|
||||
define('MONERO_GATEWAY_ADDRESS_PREFIX', 0x12);
|
||||
define('MONERO_GATEWAY_ADDRESS_PREFIX_INTEGRATED', 0x13);
|
||||
define('MONERO_GATEWAY_TESTNET_EXPLORER_URL', 'https://testnet.xmrchain.com/');
|
||||
define('MONERO_GATEWAY_ADDRESS_PREFIX', 0x1032);
|
||||
define('MONERO_GATEWAY_ADDRESS_PREFIX_INTEGRATED', 0x1A9A);
|
||||
define('MONERO_GATEWAY_ATOMIC_UNITS', 11);
|
||||
define('MONERO_GATEWAY_ATOMIC_UNIT_THRESHOLD', 10); // Amount under in atomic units payment is valid
|
||||
define('MONERO_GATEWAY_DIFFICULTY_TARGET', 120);
|
||||
define('MONERO_GATEWAY_DIFFICULTY_TARGET', 300);
|
||||
|
||||
// Do not edit these constants
|
||||
define('MONERO_GATEWAY_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
|
@ -28,37 +28,37 @@ define('MONERO_GATEWAY_ATOMIC_UNITS_POW', pow(10, MONERO_GATEWAY_ATOMIC_UNITS));
|
|||
define('MONERO_GATEWAY_ATOMIC_UNITS_SPRINTF', '%.'.MONERO_GATEWAY_ATOMIC_UNITS.'f');
|
||||
|
||||
// Include our Gateway Class and register Payment Gateway with WooCommerce
|
||||
add_action('plugins_loaded', 'wownero_init', 1);
|
||||
function wownero_init() {
|
||||
add_action('plugins_loaded', 'monero_init', 1);
|
||||
function monero_init() {
|
||||
|
||||
// If the class doesn't exist (== WooCommerce isn't installed), return NULL
|
||||
if (!class_exists('WC_Payment_Gateway')) return;
|
||||
|
||||
// If we made it this far, then include our Gateway Class
|
||||
require_once('include/class-wownero-gateway.php');
|
||||
require_once('include/class-monero-gateway.php');
|
||||
|
||||
// Create a new instance of the gateway so we have static variables set up
|
||||
new Wownero_Gateway($add_action=false);
|
||||
new Monero_Gateway($add_action=false);
|
||||
|
||||
// Include our Admin interface class
|
||||
require_once('include/admin/class-wownero-admin-interface.php');
|
||||
require_once('include/admin/class-monero-admin-interface.php');
|
||||
|
||||
add_filter('woocommerce_payment_gateways', 'wownero_gateway');
|
||||
function wownero_gateway($methods) {
|
||||
$methods[] = 'Wownero_Gateway';
|
||||
$methods[] = 'Monero_Gateway';
|
||||
return $methods;
|
||||
}
|
||||
|
||||
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'wownero_payment');
|
||||
function wownero_payment($links) {
|
||||
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'monero_payment');
|
||||
function monero_payment($links) {
|
||||
$plugin_links = array(
|
||||
'<a href="'.admin_url('admin.php?page=wownero_gateway_settings').'">'.__('Settings', 'wownero_gateway').'</a>'
|
||||
'<a href="'.admin_url('admin.php?page=monero_gateway_settings').'">'.__('Settings', 'wownero_gateway').'</a>'
|
||||
);
|
||||
return array_merge($plugin_links, $links);
|
||||
}
|
||||
|
||||
add_filter('cron_schedules', 'wownero_cron_add_one_minute');
|
||||
function wownero_cron_add_one_minute($schedules) {
|
||||
add_filter('cron_schedules', 'monero_cron_add_one_minute');
|
||||
function monero_cron_add_one_minute($schedules) {
|
||||
$schedules['one_minute'] = array(
|
||||
'interval' => 60,
|
||||
'display' => __('Once every minute', 'wownero_gateway')
|
||||
|
@ -66,46 +66,46 @@ function wownero_init() {
|
|||
return $schedules;
|
||||
}
|
||||
|
||||
add_action('wp', 'wownero_activate_cron');
|
||||
function wownero_activate_cron() {
|
||||
if(!wp_next_scheduled('wownero_update_event')) {
|
||||
wp_schedule_event(time(), 'one_minute', 'wownero_update_event');
|
||||
add_action('wp', 'monero_activate_cron');
|
||||
function monero_activate_cron() {
|
||||
if(!wp_next_scheduled('monero_update_event')) {
|
||||
wp_schedule_event(time(), 'one_minute', 'monero_update_event');
|
||||
}
|
||||
}
|
||||
|
||||
add_action('wownero_update_event', 'wownero_update_event');
|
||||
function wownero_update_event() {
|
||||
Wownero_Gateway::do_update_event();
|
||||
add_action('monero_update_event', 'monero_update_event');
|
||||
function monero_update_event() {
|
||||
Monero_Gateway::do_update_event();
|
||||
}
|
||||
|
||||
add_action('woocommerce_thankyou_'.Wownero_Gateway::get_id(), 'wownero_order_confirm_page');
|
||||
add_action('woocommerce_order_details_after_order_table', 'wownero_order_page');
|
||||
add_action('woocommerce_email_after_order_table', 'wownero_order_email');
|
||||
add_action('woocommerce_thankyou_'.Monero_Gateway::get_id(), 'monero_order_confirm_page');
|
||||
add_action('woocommerce_order_details_after_order_table', 'monero_order_page');
|
||||
add_action('woocommerce_email_after_order_table', 'monero_order_email');
|
||||
|
||||
function wownero_order_confirm_page($order_id) {
|
||||
Wownero_Gateway::customer_order_page($order_id);
|
||||
function monero_order_confirm_page($order_id) {
|
||||
Monero_Gateway::customer_order_page($order_id);
|
||||
}
|
||||
function wownero_order_page($order) {
|
||||
function monero_order_page($order) {
|
||||
if(!is_wc_endpoint_url('order-received'))
|
||||
Wownero_Gateway::customer_order_page($order);
|
||||
Monero_Gateway::customer_order_page($order);
|
||||
}
|
||||
function wownero_order_email($order) {
|
||||
Wownero_Gateway::customer_order_email($order);
|
||||
function monero_order_email($order) {
|
||||
Monero_Gateway::customer_order_email($order);
|
||||
}
|
||||
|
||||
add_action('wc_ajax_wownero_gateway_payment_details', 'wownero_get_payment_details_ajax');
|
||||
function wownero_get_payment_details_ajax() {
|
||||
Wownero_Gateway::get_payment_details_ajax();
|
||||
add_action('wc_ajax_monero_gateway_payment_details', 'monero_get_payment_details_ajax');
|
||||
function monero_get_payment_details_ajax() {
|
||||
Monero_Gateway::get_payment_details_ajax();
|
||||
}
|
||||
|
||||
add_filter('woocommerce_currencies', 'wownero_add_currency');
|
||||
function wownero_add_currency($currencies) {
|
||||
add_filter('woocommerce_currencies', 'monero_add_currency');
|
||||
function monero_add_currency($currencies) {
|
||||
$currencies['Wownero'] = __('Wownero', 'wownero_gateway');
|
||||
return $currencies;
|
||||
}
|
||||
|
||||
add_filter('woocommerce_currency_symbol', 'wownero_add_currency_symbol', 10, 2);
|
||||
function wownero_add_currency_symbol($currency_symbol, $currency) {
|
||||
add_filter('woocommerce_currency_symbol', 'monero_add_currency_symbol', 10, 2);
|
||||
function monero_add_currency_symbol($currency_symbol, $currency) {
|
||||
switch ($currency) {
|
||||
case 'Wownero':
|
||||
$currency_symbol = 'WOW';
|
||||
|
@ -114,102 +114,102 @@ function wownero_init() {
|
|||
return $currency_symbol;
|
||||
}
|
||||
|
||||
if(Wownero_Gateway::use_wownero_price()) {
|
||||
if(Monero_Gateway::use_monero_price()) {
|
||||
|
||||
// This filter will replace all prices with amount in Wownero (live rates)
|
||||
add_filter('wc_price', 'wownero_live_price_format', 10, 3);
|
||||
function wownero_live_price_format($price_html, $price_float, $args) {
|
||||
// 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) {
|
||||
if(!isset($args['currency']) || !$args['currency']) {
|
||||
global $woocommerce;
|
||||
$currency = strtoupper(get_woocommerce_currency());
|
||||
} else {
|
||||
$currency = strtoupper($args['currency']);
|
||||
}
|
||||
return Wownero_Gateway::convert_wc_price($price_float, $currency);
|
||||
return Monero_Gateway::convert_wc_price($price_float, $currency);
|
||||
}
|
||||
|
||||
// These filters will replace the live rate with the exchange rate locked in for the order
|
||||
// We must be careful to hit all the hooks for price displays associated with an order,
|
||||
// else the exchange rate can change dynamically (which it should for an order)
|
||||
add_filter('woocommerce_order_formatted_line_subtotal', 'wownero_order_item_price_format', 10, 3);
|
||||
function wownero_order_item_price_format($price_html, $item, $order) {
|
||||
return Wownero_Gateway::convert_wc_price_order($price_html, $order);
|
||||
add_filter('woocommerce_order_formatted_line_subtotal', 'monero_order_item_price_format', 10, 3);
|
||||
function monero_order_item_price_format($price_html, $item, $order) {
|
||||
return Monero_Gateway::convert_wc_price_order($price_html, $order);
|
||||
}
|
||||
|
||||
add_filter('woocommerce_get_formatted_order_total', 'wownero_order_total_price_format', 10, 2);
|
||||
function wownero_order_total_price_format($price_html, $order) {
|
||||
return Wownero_Gateway::convert_wc_price_order($price_html, $order);
|
||||
add_filter('woocommerce_get_formatted_order_total', 'monero_order_total_price_format', 10, 2);
|
||||
function monero_order_total_price_format($price_html, $order) {
|
||||
return Monero_Gateway::convert_wc_price_order($price_html, $order);
|
||||
}
|
||||
|
||||
add_filter('woocommerce_get_order_item_totals', 'wownero_order_totals_price_format', 10, 3);
|
||||
function wownero_order_totals_price_format($total_rows, $order, $tax_display) {
|
||||
add_filter('woocommerce_get_order_item_totals', 'monero_order_totals_price_format', 10, 3);
|
||||
function monero_order_totals_price_format($total_rows, $order, $tax_display) {
|
||||
foreach($total_rows as &$row) {
|
||||
$price_html = $row['value'];
|
||||
$row['value'] = Wownero_Gateway::convert_wc_price_order($price_html, $order);
|
||||
$row['value'] = Monero_Gateway::convert_wc_price_order($price_html, $order);
|
||||
}
|
||||
return $total_rows;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'wownero_enqueue_scripts');
|
||||
function wownero_enqueue_scripts() {
|
||||
if(Wownero_Gateway::use_wownero_price())
|
||||
add_action('wp_enqueue_scripts', 'monero_enqueue_scripts');
|
||||
function monero_enqueue_scripts() {
|
||||
if(Monero_Gateway::use_monero_price())
|
||||
wp_dequeue_script('wc-cart-fragments');
|
||||
if(Wownero_Gateway::use_qr_code())
|
||||
wp_enqueue_script('wownero-qr-code', MONERO_GATEWAY_PLUGIN_URL.'assets/js/qrcode.min.js');
|
||||
if(Monero_Gateway::use_qr_code())
|
||||
wp_enqueue_script('monero-qr-code', MONERO_GATEWAY_PLUGIN_URL.'assets/js/qrcode.min.js');
|
||||
|
||||
wp_enqueue_script('wownero-clipboard-js', MONERO_GATEWAY_PLUGIN_URL.'assets/js/clipboard.min.js');
|
||||
wp_enqueue_script('wownero-gateway', MONERO_GATEWAY_PLUGIN_URL.'assets/js/wownero-gateway-order-page.js');
|
||||
wp_enqueue_style('wownero-gateway', MONERO_GATEWAY_PLUGIN_URL.'assets/css/wownero-gateway-order-page.css');
|
||||
wp_enqueue_script('monero-clipboard-js', MONERO_GATEWAY_PLUGIN_URL.'assets/js/clipboard.min.js');
|
||||
wp_enqueue_script('monero-gateway', MONERO_GATEWAY_PLUGIN_URL.'assets/js/monero-gateway-order-page.js');
|
||||
wp_enqueue_style('monero-gateway', MONERO_GATEWAY_PLUGIN_URL.'assets/css/monero-gateway-order-page.css');
|
||||
}
|
||||
|
||||
// [wownero-price currency="USD"]
|
||||
// [monero-price currency="USD"]
|
||||
// currency: BTC, GBP, etc
|
||||
// if no none, then default store currency
|
||||
function wownero_price_func( $atts ) {
|
||||
function monero_price_func( $atts ) {
|
||||
global $woocommerce;
|
||||
$a = shortcode_atts( array(
|
||||
'currency' => get_woocommerce_currency()
|
||||
), $atts );
|
||||
|
||||
$currency = strtoupper($a['currency']);
|
||||
$rate = Wownero_Gateway::get_live_rate($currency);
|
||||
$rate = Monero_Gateway::get_live_rate($currency);
|
||||
if($currency == 'BTC')
|
||||
$rate_formatted = sprintf('%.8f', $rate / 1e8);
|
||||
else
|
||||
$rate_formatted = sprintf('%.5f', $rate / 1e8);
|
||||
|
||||
return "<span class=\"wownero-price\">1 XMR = $rate_formatted $currency</span>";
|
||||
return "<span class=\"monero-price\">1 WOW = $rate_formatted $currency</span>";
|
||||
}
|
||||
add_shortcode('wownero-price', 'wownero_price_func');
|
||||
add_shortcode('monero-price', 'monero_price_func');
|
||||
|
||||
|
||||
// [wownero-accepted-here]
|
||||
function wownero_accepted_func() {
|
||||
return '<img src="'.MONERO_GATEWAY_PLUGIN_URL.'assets/images/wownero-accepted-here.png" />';
|
||||
// [monero-accepted-here]
|
||||
function monero_accepted_func() {
|
||||
return '<img src="'.MONERO_GATEWAY_PLUGIN_URL.'assets/images/monero-accepted-here.png" />';
|
||||
}
|
||||
add_shortcode('wownero-accepted-here', 'wownero_accepted_func');
|
||||
add_shortcode('monero-accepted-here', 'monero_accepted_func');
|
||||
|
||||
}
|
||||
|
||||
register_deactivation_hook(__FILE__, 'wownero_deactivate');
|
||||
function wownero_deactivate() {
|
||||
$timestamp = wp_next_scheduled('wownero_update_event');
|
||||
wp_unschedule_event($timestamp, 'wownero_update_event');
|
||||
register_deactivation_hook(__FILE__, 'monero_deactivate');
|
||||
function monero_deactivate() {
|
||||
$timestamp = wp_next_scheduled('monero_update_event');
|
||||
wp_unschedule_event($timestamp, 'monero_update_event');
|
||||
}
|
||||
|
||||
register_activation_hook(__FILE__, 'wownero_install');
|
||||
function wownero_install() {
|
||||
register_activation_hook(__FILE__, 'monero_install');
|
||||
function monero_install() {
|
||||
global $wpdb;
|
||||
require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
$table_name = $wpdb->prefix . "wownero_gateway_quotes";
|
||||
$table_name = $wpdb->prefix . "monero_gateway_quotes";
|
||||
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
||||
$sql = "CREATE TABLE $table_name (
|
||||
order_id BIGINT(20) UNSIGNED NOT NULL,
|
||||
payment_id VARCHAR(16) DEFAULT '' NOT NULL,
|
||||
payment_id VARCHAR(95) DEFAULT '' NOT NULL,
|
||||
currency VARCHAR(6) DEFAULT '' NOT NULL,
|
||||
rate BIGINT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
amount BIGINT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
|
@ -222,11 +222,11 @@ function wownero_install() {
|
|||
dbDelta($sql);
|
||||
}
|
||||
|
||||
$table_name = $wpdb->prefix . "wownero_gateway_quotes_txids";
|
||||
$table_name = $wpdb->prefix . "monero_gateway_quotes_txids";
|
||||
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
||||
$sql = "CREATE TABLE $table_name (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
payment_id VARCHAR(16) DEFAULT '' NOT NULL,
|
||||
payment_id VARCHAR(95) DEFAULT '' NOT NULL,
|
||||
txid VARCHAR(64) DEFAULT '' NOT NULL,
|
||||
amount BIGINT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
height MEDIUMINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
@ -236,7 +236,7 @@ function wownero_install() {
|
|||
dbDelta($sql);
|
||||
}
|
||||
|
||||
$table_name = $wpdb->prefix . "wownero_gateway_live_rates";
|
||||
$table_name = $wpdb->prefix . "monero_gateway_live_rates";
|
||||
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
||||
$sql = "CREATE TABLE $table_name (
|
||||
currency VARCHAR(6) DEFAULT '' NOT NULL,
|
52
readme.txt
52
readme.txt
|
@ -1,18 +1,19 @@
|
|||
=== Monero WooCommerce Extension ===
|
||||
Contributors: serhack, mosu-forge
|
||||
Contributors: SerHack
|
||||
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: 4.9.8
|
||||
Tested up to: 5.0.1
|
||||
Stable tag: trunk
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
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 bitcoins at WooCommerce-powered online stores.
|
||||
Monero WooCommerce Extension is a Wordpress plugin that allows to accept monero at WooCommerce-powered online stores.
|
||||
|
||||
== Description ==
|
||||
|
||||
An extension to WooCommerce for accepting Monero as payment in your store.
|
||||
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 =
|
||||
|
||||
|
@ -21,17 +22,15 @@ An extension to WooCommerce for accepting Monero as payment in your store.
|
|||
* 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 real time exchange rate feed and calculations.
|
||||
* 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.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Install "Monero WooCommerce extension" WordPress plugin just like any other WordPress plugin.
|
||||
1. Install "Monero WooCommerce extension" wordpress plugin just like any other Wordpress plugin.
|
||||
2. Activate
|
||||
3. Setup your monero-wallet-rpc with a view-only wallet
|
||||
4. Add your monero-wallet-rpc host address and Monero address in the settings panel
|
||||
5. Click “Enable this payment gateway”
|
||||
6. Enjoy it!
|
||||
3. Configure it with your wallet rpc address, (username or password not requested), your monero address
|
||||
4. Enjoy it!
|
||||
|
||||
== Remove plugin ==
|
||||
|
||||
|
@ -47,11 +46,32 @@ An extension to WooCommerce for accepting Monero as payment in your store.
|
|||
= 0.1 =
|
||||
* First version ! Yay!
|
||||
|
||||
= 0.2 =
|
||||
* Bug fixes
|
||||
= 1.0 =
|
||||
* Added the view key option
|
||||
|
||||
= 2.1 =
|
||||
* Verify transactions without monero-wallet-rpc
|
||||
* Optionally accept zero confirmation transactions
|
||||
* bug fixing
|
||||
|
||||
= 2.2 =
|
||||
* Fix some bugs
|
||||
|
||||
= 2.3 =
|
||||
* Bug fixing
|
||||
|
||||
= 3.0.0 =
|
||||
Fuck you mosu-forge
|
||||
* 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.
|
||||
* QR code generation is done with Javascript instead of sending payment details to a 3rd party.
|
||||
* Admin page for showing all transactions made to the wallet.
|
||||
* Logic is done via cron, instead of the user having to stay on the order page until payment is confirmed.
|
||||
* Payment details (along with the txid) are always visible on the customer's account dashboard on the my orders section.
|
||||
* Live prices are also run via cron, shortcodes for showing exchange rates.
|
||||
* Properly hooks into order confirmation email page.
|
||||
|
||||
= 0.3 =
|
||||
* Complete rewrite of how the plugin handles payments
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>Order age</td>
|
||||
<td><?php echo Wownero_Gateway::format_seconds_to_time($details['order_age']) ?> ago</td>
|
||||
<td><?php echo Monero_Gateway::format_seconds_to_time($details['order_age']) ?> ago</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Order exipires</td>
|
||||
|
@ -72,10 +72,10 @@
|
|||
<?php foreach($details['txs'] as $tx): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo MONERO_GATEWAY_EXPLORER_URL.'/tx/'.$tx['txid']; ?>" target="_blank"><?php echo $tx['txid']; ?></a>
|
||||
<a href="<?php echo MONERO_GATEWAY_EXPLORER_URL.'tx/'.$tx['txid']; ?>" target="_blank"><?php echo $tx['txid']; ?></a>
|
||||
</td>
|
||||
<td><?php echo $tx['height']; ?></td>
|
||||
<td><?php echo sprintf(MONERO_GATEWAY_ATOMIC_UNITS_SPRINTF, $tx['amount'] / MONERO_GATEWAY_ATOMIC_UNITS_POW); ?> XMR</td>
|
||||
<td><?php echo sprintf(MONERO_GATEWAY_ATOMIC_UNITS_SPRINTF, $tx['amount'] / MONERO_GATEWAY_ATOMIC_UNITS_POW); ?> WOW</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
54
templates/monero-gateway/admin/settings-page.php
Normal file
54
templates/monero-gateway/admin/settings-page.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php foreach($errors as $error): ?>
|
||||
<div class="error"><p><strong>Wownero Gateway Error</strong>: <?php echo $error; ?></p></div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h1>Wownero Gateway Settings</h1>
|
||||
|
||||
<?php if($confirm_type === 'wownero-wallet-rpc'): ?>
|
||||
<div style="border:1px solid #ddd;padding:5px 10px;">
|
||||
<?php
|
||||
echo 'Wallet height: ' . $balance['height'] . '</br>';
|
||||
echo 'Your balance is: ' . $balance['balance'] . '</br>';
|
||||
echo 'Unlocked balance: ' . $balance['unlocked_balance'] . '</br>';
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="form-table">
|
||||
<?php echo $settings_html ?>
|
||||
</table>
|
||||
|
||||
<h4><a href="https://github.com/monero-integrations/monerowp">Learn more about using the Wownero payment gateway</a></h4>
|
||||
|
||||
<script>
|
||||
function moneroUpdateFields() {
|
||||
var confirmType = jQuery("#woocommerce_monero_gateway_confirm_type").val();
|
||||
if(confirmType == "wownero-wallet-rpc") {
|
||||
jQuery("#woocommerce_monero_gateway_monero_address").closest("tr").hide();
|
||||
jQuery("#woocommerce_monero_gateway_viewkey").closest("tr").hide();
|
||||
jQuery("#woocommerce_monero_gateway_daemon_host").closest("tr").show();
|
||||
jQuery("#woocommerce_monero_gateway_daemon_port").closest("tr").show();
|
||||
} else {
|
||||
jQuery("#woocommerce_monero_gateway_monero_address").closest("tr").show();
|
||||
jQuery("#woocommerce_monero_gateway_viewkey").closest("tr").show();
|
||||
jQuery("#woocommerce_monero_gateway_daemon_host").closest("tr").hide();
|
||||
jQuery("#woocommerce_monero_gateway_daemon_port").closest("tr").hide();
|
||||
}
|
||||
var useMoneroPrices = jQuery("#woocommerce_monero_gateway_use_monero_price").is(":checked");
|
||||
if(useMoneroPrices) {
|
||||
jQuery("#woocommerce_monero_gateway_use_monero_price_decimals").closest("tr").show();
|
||||
} else {
|
||||
jQuery("#woocommerce_monero_gateway_use_monero_price_decimals").closest("tr").hide();
|
||||
}
|
||||
}
|
||||
moneroUpdateFields();
|
||||
jQuery("#woocommerce_monero_gateway_confirm_type").change(moneroUpdateFields);
|
||||
jQuery("#woocommerce_monero_gateway_use_monero_price").change(moneroUpdateFields);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#woocommerce_monero_gateway_monero_address,
|
||||
#woocommerce_monero_gateway_viewkey {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
|
@ -2,35 +2,35 @@
|
|||
<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>
|
||||
|
||||
<strong id="wownero_payment_messages">
|
||||
<strong id="monero_payment_messages">
|
||||
|
||||
<span class="wownero_payment_unpaid">Please pay the amount due to complete your transactions. Your order will expire in <span class="wownero_payment_expire_time"></span> if payment is not received.</span>
|
||||
<span class="monero_payment_unpaid">Please pay the amount due to complete your transactions. Your order will expire in <span class="monero_payment_expire_time"></span> if payment is not received.</span>
|
||||
|
||||
<span class="wownero_payment_partial">We have received partial payment. Please pay the remaining amount to complete your transactions. Your order will expire in <span class="wownero_payment_expire_time"></span> if payment is not received.</span>
|
||||
<span class="monero_payment_partial">We have received partial payment. Please pay the remaining amount to complete your transactions. Your order will expire in <span class="monero_payment_expire_time"></span> if payment is not received.</span>
|
||||
|
||||
<span class="wownero_payment_paid">We have received your payment in full. Please wait while amount is confirmed. Approximate confirm time is <span class="wownero_confirm_time"></span>. <?php if(is_wc_endpoint_url('order-received')): ?><br/>You can <a href="<?php echo $details['my_order_url']; ?>">check your payment status</a> anytime in your account dashboard.<?php endif; ?></span>
|
||||
<span class="monero_payment_paid">We have received your payment in full. Please wait while amount is confirmed. Approximate confirm time is <span class="monero_confirm_time"></span>. <?php if(is_wc_endpoint_url('order-received')): ?><br/>You can <a href="<?php echo $details['my_order_url']; ?>">check your payment status</a> anytime in your account dashboard.<?php endif; ?></span>
|
||||
|
||||
<span class="wownero_payment_confirmed">Your order has been confirmed. Thank you for paying with Wownero!</span>
|
||||
<span class="monero_payment_confirmed">Your order has been confirmed. Thank you for paying with Wownero!</span>
|
||||
|
||||
<span class="wownero_payment_expired">Your order has expired. Please place another order to complete your purchase.</span>
|
||||
<span class="monero_payment_expired">Your order has expired. Please place another order to complete your purchase.</span>
|
||||
|
||||
<span class="wownero_payment_expired_partial">Your order has expired. Please contact the store owner to receive refund on your partial payment.</span>
|
||||
<span class="monero_payment_expired_partial">Your order has expired. Please contact the store owner to receive refund on your partial payment.</span>
|
||||
|
||||
</strong>
|
||||
|
||||
<ul class="order_details" style="margin-top:30px">
|
||||
<li>
|
||||
Pay to:
|
||||
<strong class="wownero_details_row">
|
||||
<span class="wownero_details_main" id="wownero_integrated_address"></span>
|
||||
<span class="wownero_details_right button-row">
|
||||
<strong class="monero_details_row">
|
||||
<span class="monero_details_main" id="monero_integrated_address"></span>
|
||||
<span class="monero_details_right button-row">
|
||||
<?php if($show_qr): ?>
|
||||
<button href="#" class="button" title="Show QR Code" onclick="wownero_showQR()">
|
||||
<button href="#" class="button" title="Show QR Code" onclick="monero_showQR()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512" version="1"><path d="M0 512h233V279H0zm47-186h139v139H47z"/><path d="M93 372h47v47H93zm279 93h47v47h-47zm93 0h47v47h-47z"/><path d="M465 326h-46v-47H279v233h47V372h46v47h140V279h-47zM0 233h233V0H0zM47 47h139v139H47z"/><path d="M93 93h47v47H93zM279 0v233h233V0zm186 186H326V47h139z"/><path d="M372 93h47v47h-47z"/></svg>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<button href="#" class="button clipboard" title="Copy Address"
|
||||
data-clipboard-target="#wownero_integrated_address">
|
||||
data-clipboard-target="#monero_integrated_address">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512" version="1"><path d="M504 118c-6-6-12-8-20-8H365c-11 0-23 3-36 11V27c0-7-3-14-8-19s-12-8-20-8H183c-8 0-16 2-25 6-10 4-17 8-22 13L19 136c-5 5-9 12-13 22-4 9-6 17-6 25v192c0 7 3 14 8 19s12 8 19 8h156v82c0 8 2 14 8 20 5 5 12 8 19 8h274c8 0 14-3 20-8 5-6 8-12 8-20V137c0-8-3-14-8-19zm-175 52v86h-85l85-86zM146 61v85H61l85-85zm56 185c-5 5-10 12-14 21-3 9-5 18-5 25v73H37V183h118c8 0 14-3 20-8 5-6 8-12 8-20V37h109v118l-90 91zm273 229H219V292h119c8 0 14-2 19-8 6-5 8-11 8-19V146h110v329z"/></svg>
|
||||
</button>
|
||||
</span>
|
||||
|
@ -38,13 +38,13 @@
|
|||
</li>
|
||||
<li>
|
||||
Total due:
|
||||
<strong class="wownero_details_row">
|
||||
<span class="wownero_details_main">
|
||||
<span id="wownero_total_due"></span> WOW
|
||||
<strong class="monero_details_row">
|
||||
<span class="monero_details_main">
|
||||
<span id="monero_total_due"></span> WOW
|
||||
</span>
|
||||
<span class="wownero_details_right button-row">
|
||||
<span class="monero_details_right button-row">
|
||||
<button href="#" class="button clipboard" title="Copy Amount"
|
||||
data-clipboard-target="#wownero_total_due">
|
||||
data-clipboard-target="#monero_total_due">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512" version="1"><path d="M504 118c-6-6-12-8-20-8H365c-11 0-23 3-36 11V27c0-7-3-14-8-19s-12-8-20-8H183c-8 0-16 2-25 6-10 4-17 8-22 13L19 136c-5 5-9 12-13 22-4 9-6 17-6 25v192c0 7 3 14 8 19s12 8 19 8h156v82c0 8 2 14 8 20 5 5 12 8 19 8h274c8 0 14-3 20-8 5-6 8-12 8-20V137c0-8-3-14-8-19zm-175 52v86h-85l85-86zM146 61v85H61l85-85zm56 185c-5 5-10 12-14 21-3 9-5 18-5 25v73H37V183h118c8 0 14-3 20-8 5-6 8-12 8-20V37h109v118l-90 91zm273 229H219V292h119c8 0 14-2 19-8 6-5 8-11 8-19V146h110v329z"/></svg>
|
||||
</button>
|
||||
</span>
|
||||
|
@ -53,23 +53,23 @@
|
|||
<li style="display:none">
|
||||
Total order amount:
|
||||
<strong>
|
||||
<span id="wownero_total_amount"></span> WOW
|
||||
<span id="monero_total_amount"></span> WOW
|
||||
</strong>
|
||||
</li>
|
||||
<li>
|
||||
Total paid:
|
||||
<strong>
|
||||
<span id="wownero_total_paid"></span> WOW
|
||||
<span id="monero_total_paid"></span> WOW
|
||||
</strong>
|
||||
</li>
|
||||
<li>
|
||||
Exchange rate:<strong id="wownero_exchange_rate"></strong>
|
||||
Exchange rate:<strong id="monero_exchange_rate"></strong>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<table id="wownero_tx_table" style="display:none;">
|
||||
<table id="monero_tx_table" style="display:none;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Transaction id</th>
|
||||
|
@ -80,21 +80,21 @@
|
|||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="wownero_tx_none" style="display:none;">
|
||||
<div id="monero_tx_none" style="display:none;">
|
||||
</div>
|
||||
|
||||
<div id="wownero_qr_code_container" style="display:none;" onclick="wownero_showQR(false)">
|
||||
<div id="wownero_qr_code">
|
||||
<div id="monero_qr_code_container" style="display:none;" onclick="monero_showQR(false)">
|
||||
<div id="monero_qr_code">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<div id="wownero_toast"></div>
|
||||
<div id="monero_toast"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var wownero_show_qr = <?php echo $show_qr ? 'true' : 'false'; ?>;
|
||||
var wownero_ajax_url = '<?php echo $ajax_url; ?>';
|
||||
var wownero_explorer_url = '<?php echo MONERO_GATEWAY_EXPLORER_URL; ?>';
|
||||
var wownero_details = <?php echo $details_json; ?>;
|
||||
var monero_show_qr = <?php echo $show_qr ? 'true' : 'false'; ?>;
|
||||
var monero_ajax_url = '<?php echo $ajax_url; ?>';
|
||||
var monero_explorer_url = '<?php echo MONERO_GATEWAY_EXPLORER_URL; ?>';
|
||||
var monero_details = <?php echo $details_json; ?>;
|
||||
</script>
|
|
@ -1,54 +0,0 @@
|
|||
<?php foreach($errors as $error): ?>
|
||||
<div class="error"><p><strong>Wownero Gateway Error</strong>: <?php echo $error; ?></p></div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h1>Wownero Gateway Settings</h1>
|
||||
|
||||
<?php if($confirm_type === 'wownero-wallet-rpc'): ?>
|
||||
<div style="border:1px solid #ddd;padding:5px 10px;">
|
||||
<?php
|
||||
echo 'Wallet height' . $balance['height'] . '</br>';
|
||||
echo 'Your balance is: ' . $balance['balance'] . '</br>';
|
||||
echo 'Unlocked balance: ' . $balance['unlocked_balance'] . '</br>';
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="form-table">
|
||||
<?php echo $settings_html ?>
|
||||
</table>
|
||||
|
||||
<h4><a href="https://github.com/monero-integrations/monerowp">Learn more about using the Wownero payment gateway</a></h4>
|
||||
|
||||
<script>
|
||||
function wowneroUpdateFields() {
|
||||
var confirmType = jQuery("#woocommerce_wownero_gateway_confirm_type").val();
|
||||
if(confirmType == "wownero-wallet-rpc") {
|
||||
jQuery("#woocommerce_wownero_gateway_wownero_address").closest("tr").hide();
|
||||
jQuery("#woocommerce_wownero_gateway_viewkey").closest("tr").hide();
|
||||
jQuery("#woocommerce_wownero_gateway_daemon_host").closest("tr").show();
|
||||
jQuery("#woocommerce_wownero_gateway_daemon_port").closest("tr").show();
|
||||
} else {
|
||||
jQuery("#woocommerce_wownero_gateway_wownero_address").closest("tr").show();
|
||||
jQuery("#woocommerce_wownero_gateway_viewkey").closest("tr").show();
|
||||
jQuery("#woocommerce_wownero_gateway_daemon_host").closest("tr").hide();
|
||||
jQuery("#woocommerce_wownero_gateway_daemon_port").closest("tr").hide();
|
||||
}
|
||||
var useWowneroPrices = jQuery("#woocommerce_wownero_gateway_use_wownero_price").is(":checked");
|
||||
if(useWowneroPrices) {
|
||||
jQuery("#woocommerce_wownero_gateway_use_wownero_price_decimals").closest("tr").show();
|
||||
} else {
|
||||
jQuery("#woocommerce_wownero_gateway_use_wownero_price_decimals").closest("tr").hide();
|
||||
}
|
||||
}
|
||||
wowneroUpdateFields();
|
||||
jQuery("#woocommerce_wownero_gateway_confirm_type").change(wowneroUpdateFields);
|
||||
jQuery("#woocommerce_wownero_gateway_use_wownero_price").change(wowneroUpdateFields);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#woocommerce_wownero_gateway_wownero_address,
|
||||
#woocommerce_wownero_gateway_viewkey {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue