-
Notifications
You must be signed in to change notification settings - Fork 41
Add Feature: On-site modal checkout #26
base: master
Are you sure you want to change the base?
Conversation
Awesome, I know that @astupidmoose worked on it also. However, I think you should remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR :) In the future try and avoid formatting the files differently as it causes the diff to be harder to read.
src/assets/js/btcpay.js
Outdated
@@ -0,0 +1,135 @@ | |||
/* jshint browser: true, strict: false, maxlen: false, maxstatements: false */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to include this file here. Each btcpay host ships with this js file e.g. https://btcpay.kukks.org/modal/btcpay.js
src/class-wc-gateway-btcpay.php
Outdated
function enqueue_modal_js() | ||
{ | ||
$ajax_url = admin_url( 'admin-ajax.php' ); | ||
wp_enqueue_script( 'btcpay-modal', plugin_dir_url( __FILE__ ) . 'assets/js/btcpay.js', array( 'jquery' ), null, false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use remote btcpay script file
src/class-wc-gateway-btcpay.php
Outdated
wp_enqueue_script( 'btcpay-modal', plugin_dir_url( __FILE__ ) . 'assets/js/btcpay.js', array( 'jquery' ), null, false ); | ||
|
||
wp_add_inline_script( 'btcpay-modal', | ||
"btcpay.setApiUrlPrefix('".get_option('woocommerce_btcpay_url')."') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need this if you load the script remotely.
I could be wrong as I didn't actually code it, but I think it was required to bring in the btcpay.js for the closing and redirection functionality. Else, that functionality would be needed to be added into btcpay.js in the master repo. When calling it remotely, the window was not closing properly and would not redirect on payment success. |
Hey @astupidmoose what we talked about doesn't apply here. It is really design question - do we want separate I discussed with Mike about us providing |
|
I think we should have |
@m-adilshaikh You can print the invoice id as a js var as well though which would give you global access and not require you to depend on that event to give you the id |
@Kukks Yes I was expecting to enqueue order details but the flow is boxed up with WC Gateway API, the request goes async and response is handled by checkout.js I believe, couldn't figure where to intercept. |
@Kukks Actually I just realized I am already calling a js function as redirect... I will look into this. |
So do we need to modify |
@NicolasDorier Not required after d76a23d |
@m-adilshaikh I can't get this latest PR to install. Parse error: syntax error, unexpected '}', expecting ';' in /var/www/html/wp-content/plugins/woocommerce-btcpay/class-wc-gateway-btcpay.php on line 628 |
Tried installing now Plugin could not be activated because it triggered a fatal error. End up getting this error: |
Any idea @m-adilshaikh ? |
ping @m-adilshaikh (also need rebase) |
What's the status here @m-adilshaikh? Shall we review again? :) |
I need to check this out again. The original plugin @m-adilshaikh sent me works and is live in production, but I think it somehow re-added the libs and css file that were previously stripped. The updated versions do not work however. I'm not sure how. I need to setup another test site to check the latest version. |
This code is pretty old and there was a bunch of flaws with it. I think modal checkout would be useful, but I don't think it's safe to push this PR through. Not sure why it was "approved" |
remove built css file modal checkout: add global variable for invoice id at checkout, use for validation fix get_btcpay_redirect_modal
I have rebased and cleaned up the mess of reformatting I made, now I recall this had issues but we were very close, it was pending manual testing, I may have not committed the revisions after review. Perhaps someone can take it from here, I've lost context. |
Feature works by switching the external redirect at checkout to
btcpay.showInvoice
callExpected flow
If activated in settings
Proceed to Checkout
button, payment modal pops up4/2019 Changelog
Includebtcpay.js
script inassets/js
btcpay.js
scriptbtcpay.onModalWillLeave
and custom wp-ajax endpointPlease excuse the bulky commit, I had made the changes in distribution build and then ported to repo.
Credits to @astupidmoose for sponsoring and live testing