Skip to content

Rewrite plugin to v3.0#69

Merged
serhack merged 2 commits intomonero-integrations:masterfrom
mosu-forge:v3.0
Nov 10, 2018
Merged

Rewrite plugin to v3.0#69
serhack merged 2 commits intomonero-integrations:masterfrom
mosu-forge:v3.0

Conversation

@mosu-forge
Copy link
Copy Markdown
Contributor

v3.0 includes major reworking of how the plugin works:

  • 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.

jQuery('#monero_toast').append(toast);
toast.animate({ "right": "12px" }, "fast");
setInterval(function() {
toast.animate({ "right": "-400px" }, "fast", function() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: -400px?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, negative values are valid for top, left, bottom, right and are used to hide something off screen.

Copy link
Copy Markdown
Member

@serhack serhack Sep 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To hide something on screen: display: none.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, well you're not understanding why -400px is used... The notification is animated off-screen. Please don't resort to personal attacks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry. My intent was not to attack you on personal. However I appreciate your work.

};
setInterval(monero_fetchDetails, 30000);
monero_updateDetails();
new ClipboardJS('.clipboard').on('success', function(e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know why you need to add some random JS library for "Clipboarding".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's not standard across browsers, and mobile platforms, which is why clipboard.js exists in the first place. Originally I did not use a library and it wasn't cross-platform.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have to copy a string on mobile when you can click on a link monero:// which will open a Monero wallet (Monerujo and Cakewallet supports monero:// )?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a serious objection, then clipboarding can be done the way the masari plugin does it, however clipboard.js isn't a heavy framework, but I understand if you want to drop it.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--disable-rpc-login ? Do you know what will happen if the rpc-login is disabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing where the original WP plugin used authorization? Not being snarky.

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');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waste of resources.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with the way the current plugin works is that it only does payment checking logic when the order confirmation page is refreshed. So if a user leaves the order confirmation page, then their order will never confirm. Cron is necessary for allowing users to leave the page, and still have their order confirmed, especially if a merchant sets confirms to 10+. If you feel once a minute is too often, that can be changed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine having running 200 cronjobs at the same time. I still disagree for running cronjobs when users leaves the order confirmation page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the plugin only runs one cronjob for all payments. It does two things:

  • Fetches the price so live exchange rates can be displayed on the site, or used for displaying prices in XMR on the frontend
  • Checks for pending orders, and if there are any, checks for payments

Copy link
Copy Markdown
Member

@serhack serhack Sep 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have already had a sort of cronjob for live exchange rates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not see that anywhere in the code grep -Ri cron monerowp returns nothing.

This may be a disagreement of how the plugin should work. In my opinion if a merchant wants to require 10 confirms, it's not nice to make the user stay on the order confirmation for 20 minutes (at least, could be more), and if they close it, the payment never confirms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this PR is closed, but for the time that you re-look at this code I wanted to add:

Right now the current plugin actually runs the same payment checking code that this cron job does every 17 seconds, so this code should actually be more efficient.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, or something like this, is critical to include indeed. It is unacceptable that the page cannot be closed or the order will not fulfill.

Comment thread readme.txt
@@ -1,9 +1,9 @@
=== Monero WooCommerce Extension ===
Contributors: serhack
Contributors: serhack, mosu-forge
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR is merged, then he is indeed a contributor and this should be here.

@serhack
Copy link
Copy Markdown
Member

serhack commented Sep 22, 2018

In particular, you are using mixed content. Some variables are sent to database without a prevent escaping. "Rewriting" is a very big word. You should simplify things, not adding Javascript framework and libraries to random. Moving and splitting the code in multiple files is not "rewriting a payment gateway".

@mosu-forge
Copy link
Copy Markdown
Contributor Author

@serhack responded to all the comments above, except the license / author questions.

If there's a place I did not escape a MySql statement, that should be updated, can you point it out please?

There is a lot more than moving and splitting code, if you don't want to call it a re-write, then that's okay, just call it a version bump.

@serhack
Copy link
Copy Markdown
Member

serhack commented Sep 22, 2018

There is a lot more than moving and splitting code, if you don't want to call it a re-write, then that's okay, just call it a version bump.

I disagree on splitting code into multiple files.

@mosu-forge
Copy link
Copy Markdown
Contributor Author

I disagree on splitting code into multiple files.

There are only a few key places I split code:

  • Monero RPC class, and Monero Node tools: split because we only need to require one or the other file
  • Template files, it's not fun editing inlined HTML in PHP files
  • Admin settings options, this is a common configuration for Wordpress plugins

@Mattthev
Copy link
Copy Markdown

It's simple! XMR payments by Mosu works like a charm.
This XMR plugin just not confirm orders... It generates new address every refresh and also amount. CSS is not working for me and loading it from non SSL... It looks really dumb on checkout when you want to pay with privacy coin and the SSL lock isn't green and locked...

@cryptochangements34
Copy link
Copy Markdown
Member

Personally I do agree with some of the splitting into several files. Having all the code (including inline HTML/CSS/JS) is rather messy

@serhack
Copy link
Copy Markdown
Member

serhack commented Sep 22, 2018

I disagree, but I love community input. I recognize Monero Integrations Payment gateway for woocommerce has some issues on UX.

@serhack serhack mentioned this pull request Sep 22, 2018
@lacksfish
Copy link
Copy Markdown

This seems to be a larger rewrite, at first glance. Looks like a proper effort!

Maybe OP of the project and @mosu-forge can talk together and adapt this PR to a mergeable state, with respect to Copyright and small code cleanups and all that.

Otherwise why not fork it and keep developing anyways? :)

@serhack
Copy link
Copy Markdown
Member

serhack commented Sep 23, 2018

I'm reopening this.

@serhack serhack reopened this Sep 23, 2018
@serhack
Copy link
Copy Markdown
Member

serhack commented Sep 23, 2018

This will be the base for the next version the third one. I'll include some features like subaddresses integration and I'll try to avoid as much as possible any JS framework.

@rehrar
Copy link
Copy Markdown

rehrar commented Oct 11, 2018

This, or something like this, is critical to get working correctly. The current WP plugin is broken as is, and many of the griefs I had of the old one are addressed here.

@serhack serhack merged commit ad6fe19 into monero-integrations:master Nov 10, 2018
@monero-integrations monero-integrations deleted a comment from mosu-forge Dec 7, 2020
@monero-integrations monero-integrations deleted a comment from rehrar Dec 7, 2020
@monero-integrations monero-integrations deleted a comment from mosu-forge Dec 7, 2020
@monero-integrations monero-integrations deleted a comment from fireice-uk Dec 7, 2020
@monero-integrations monero-integrations deleted a comment from mosu-forge Dec 7, 2020
@monero-integrations monero-integrations locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants