Re: Paypal In-context popup does not load content, then proceeds to full-page payment
Seeing so many having difficulty using this added feature and while this (solution and addition to ZC) makes a plugin I offer obsolete, ZC 1.5.5x is missing an important part of the process outlined by PayPal to support In Context checkout. Namely the javascript code needed to support the operation.
The code needs to be incorporated first in the shopping_cart, and then anywhere from which the PayPal Express button can be applied and anywhere to which return from PayPal is expected in order to allow revisiting the in context operation and to "hold" the view in the original screen.
An easy solution that doesn't require any file overrides nor template modification is to place the following code in a file named jscript_paypal_incontext.php then place that file in the folders listed below:
jscript_paypal_incontext.php:
Code:
<?php
if (defined('MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE') && MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE == 'InContext' && defined('MODULE_PAYMENT_PAYPALWPP_MERCHANTID') && MODULE_PAYMENT_PAYPALWPP_MERCHANTID != '' && defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {
?><!-- merchant site HTML page --><script> (function(d, s, id){ var js, ref = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)){ js = d.createElement(s); js.id = id; js.async = true; js.src = "//www.paypalobjects.com/js/external/paypal.js"; ref.parentNode.insertBefore(js, ref); } }(document, "script", "paypal-js")); </script><?php
}
Place the file in at least each of the folders in the path includes/modules/pages/
shopping_cart
login
checkout_shipping
checkout_payment
checkout_confirmation
checkout_success
time_out
index
Ie. includes/modules/pages/shopping_cart/jscript_paypal_incontext.php
And any other page that has the PayPal express checkout button or that is or could be a return page displayed to the customer in the checkout process as implemented by modifications made to your site to where a customer could return from PayPal express. (For example, the shipping page can be bypassed using PayPal Express, further the payment page can be bypassed also provided there is no possibility of a coupon being applied, which would deliver the customer to the checkout_confirmation page in a default ZC install.)
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
@mc12345678, would you provide a link to the associated PayPal documentation?
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
CRUD!! I was HOPING this would work... but it still opens up in a new window. Site is https://www.tjsattic.com
Site is using 1.5.5a and everything is correct in the admin under modules/payment
Quote:
Originally Posted by
mc12345678
Seeing so many having difficulty using this added feature and while this (solution and addition to ZC) makes a plugin I offer obsolete, ZC 1.5.5x is missing an important part of the process outlined by PayPal to support In Context checkout. Namely the javascript code needed to support the operation.
The code needs to be incorporated first in the shopping_cart, and then anywhere from which the PayPal Express button can be applied and anywhere to which return from PayPal is expected in order to allow revisiting the in context operation and to "hold" the view in the original screen.
An easy solution that doesn't require any file overrides nor template modification is to place the following code in a file named jscript_paypal_incontext.php then place that file in the folders listed below:
jscript_paypal_incontext.php:
Code:
<?php
if (defined('MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE') && MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE == 'InContext' && defined('MODULE_PAYMENT_PAYPALWPP_MERCHANTID') && MODULE_PAYMENT_PAYPALWPP_MERCHANTID != '' && defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {
?><!-- merchant site HTML page --><script> (function(d, s, id){ var js, ref = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)){ js = d.createElement(s); js.id = id; js.async = true; js.src = "//www.paypalobjects.com/js/external/paypal.js"; ref.parentNode.insertBefore(js, ref); } }(document, "script", "paypal-js")); </script><?php
}
Place the file in at least each of the folders in the path includes/modules/pages/
shopping_cart
login
checkout_shipping
checkout_payment
checkout_confirmation
checkout_success
time_out
index
Ie. includes/modules/pages/shopping_cart/jscript_paypal_incontext.php
And any other page that has the PayPal express checkout button or that is or could be a return page displayed to the customer in the checkout process as implemented by modifications made to your site to where a customer could return from PayPal express. (For example, the shipping page can be bypassed using PayPal Express, further the payment page can be bypassed also provided there is no possibility of a coupon being applied, which would deliver the customer to the checkout_confirmation page in a default ZC install.)
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
Quote:
Originally Posted by
stellarweb
CRUD!! I was HOPING this would work... but it still opens up in a new window. Site is
https://www.tjsattic.com
Site is using 1.5.5a and everything is correct in the admin under modules/payment
Generally speaking, it's still supposed to open in a new window, but the previous window is supposed to have a lightbox applied to it and the new window "hovering" over the existing.
Lat9, the reference I have for that code and direction has been replaced with the current in context information. That said, the src path can be modified to //www.paypalobjects.com/api/checkout.js and still function.
In further review, it appears that in includes/modules/payment/paypalwpp.php function process_button, the reason upon returning to the shopping cart and not being able to reuse incontext checkout is because the token has been provided back even though ec_cancel=1 and therefore when presenting the button code through process_button, the applicable javascript associated is not returned for display. This is also why after a "timeout" that the next visit to the shopping cart page will allow reuse of the in context method.
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
Quote:
Originally Posted by
mc12345678
... Lat9, the reference I have for that code and direction has been replaced with the current in context information. That said, the src path can be modified to //www.paypalobjects.com/api/checkout.js and still function. ...
mc12345678, I have absolutely no idea what you mean. Are you saying that the jscript code you posted was for an older implementation of the in-context processing?
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
So.... bottom line is.... how the heck do we get this to work properly? lol
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
Quote:
Originally Posted by
mc12345678
Seeing so many having difficulty using this added feature and while this (solution and addition to ZC) makes a plugin I offer obsolete, ZC 1.5.5x is missing an important part of the process outlined by PayPal to support In Context checkout. Namely the javascript code needed to support the operation.
The code needs to be incorporated first in the shopping_cart, and then anywhere from which the PayPal Express button can be applied and anywhere to which return from PayPal is expected in order to allow revisiting the in context operation and to "hold" the view in the original screen.
An easy solution that doesn't require any file overrides nor template modification is to place the following code in a file named jscript_paypal_incontext.php then place that file in the folders listed below:
jscript_paypal_incontext.php:
Code:
<?php
if (defined('MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE') && MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE == 'InContext' && defined('MODULE_PAYMENT_PAYPALWPP_MERCHANTID') && MODULE_PAYMENT_PAYPALWPP_MERCHANTID != '' && defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {
?><!-- merchant site HTML page --><script> (function(d, s, id){ var js, ref = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)){ js = d.createElement(s); js.id = id; js.async = true; js.src = "//www.paypalobjects.com/js/external/paypal.js"; ref.parentNode.insertBefore(js, ref); } }(document, "script", "paypal-js")); </script><?php
}
Place the file in at least each of the folders in the path includes/modules/pages/
shopping_cart
login
checkout_shipping
checkout_payment
checkout_confirmation
checkout_success
time_out
index
Ie. includes/modules/pages/shopping_cart/jscript_paypal_incontext.php
And any other page that has the PayPal express checkout button or that is or could be a return page displayed to the customer in the checkout process as implemented by modifications made to your site to where a customer could return from PayPal express. (For example, the shipping page can be bypassed using PayPal Express, further the payment page can be bypassed also provided there is no possibility of a coupon being applied, which would deliver the customer to the checkout_confirmation page in a default ZC install.)
Revision to the above which so far has worked in all testing and uses more recent/locatable information.
An easy solution that doesn't require any file overrides nor template modification is to place the following code in a file named jscript_paypal_incontext.php then place that file in the folders listed below:
jscript_paypal_incontext.php:
Code:
<?php
if (defined('MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE') && MODULE_PAYMENT_PAYPALWPP_CHECKOUTSTYLE == 'InContext' && defined('MODULE_PAYMENT_PAYPALWPP_MERCHANTID') && MODULE_PAYMENT_PAYPALWPP_MERCHANTID != '' && defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {
require_once(DIR_WS_CLASSES . 'payment.php');
$paypalwpp_module = 'paypalwpp';
// init the payment object
$classPay = new payment($paypalwpp_module);
?><script>
paypal.checkout.setup('<?php echo MODULE_PAYMENT_PAYPALWPP_MERCHANTID; ?>', {
//locale: '<?php echo ${$paypalwpp_module}->getLanguageCode('incontext'); ?>',
<?php
echo (MODULE_PAYMENT_PAYPALWPP_SERVER == 'live' ? '' : "\n environment: 'sandbox',")?>
container: 'PPecic',
buttons: 'ecButton',
click: function() {
paypal.checkout.initXO();
var action = $.post('/set-express-checkout');
action.done(function (data) {
paypal.checkout.startFlow(data.token);
});
action.fail(function () {
paypal.checkout.closeFlow();
});
}
});
</script>
<!-- merchant site HTML page --><script src = "//www.paypalobjects.com/api/checkout.js" async></script><?php
}
Place the file in at least each of the folders in the path includes/modules/pages/
shopping_cart
login
checkout_shipping
checkout_payment
checkout_confirmation
checkout_success
time_out
index
Ie. includes/modules/pages/shopping_cart/jscript_paypal_incontext.php
And any other page that has the PayPal express checkout button or that is or could be a return page displayed to the customer in the checkout process as implemented by modifications made to your site to where a customer could return from PayPal express. (For example, the shipping page can be bypassed using PayPal Express, further the payment page can be bypassed also provided there is no possibility of a coupon being applied, which would deliver the customer to the checkout_confirmation page in a default ZC install.)
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
It looks like you're getting closer, mc12345678, incorporating the Advanced In-Context JavaScript settings suggested by PayPal.
There's an unclosed parentheses in your starting if-clause and I'm wondering what the purpose of setting the $classPay variable is (since it's not referenced within the code you posted).
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
Quote:
Originally Posted by
lat9
It looks like you're getting closer, mc12345678, incorporating the
Advanced In-Context JavaScript settings suggested by PayPal.
There's an unclosed parentheses in your starting if-clause and I'm wondering what the purpose of setting the $classPay variable is (since it's not referenced within the code you posted).
If there is its a miracle that the code works on my test site without an error. There are 4 opening and 4 closing parentheses, and they are matched such that a close always closes an open one.
The assignment of $classPay is not as important as the function called to assign it. The variable could likely be unset at the end of the code or not assigned to begin with, but wanted to leave the maximum potential functionality without impacting existing code by otherwise reusing a variable (though somewhat too late in using $paypalwpp_module variable.
Re: Paypal In-context popup does not load content, then proceeds to full-page payment
Thanks for all your help on this Chad!!
Tested with Firefox, Chrome and Windows Edge - still a "no go" on https://www.tjsattic.com. Have tried from the shopping cart page as well as the login page.
I can see the coding in view source mode. I have other modules and google schema on this site... wonder if I should be testing on a "vanilla" cart?