Zen Cart Logo
Forums / PayPal Express Checkout support / Paypal In-context popup does not load content, then proceeds to full-page payment

Paypal In-context popup does not load content, then proceeds to full-page payment

Views: 46,658

Results 1 to 20 of 38
3 Aug 2016, 11:43 AM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,872
Plugin Contributions:
7

Paypal In-context popup does not load content, then proceeds to full-page payment

I'm trying to use the In-context option without success.
The popup opens, lightbox style, seems to be trying to load for a few seconds but then redirects to the usual full page for Express.
I have read that this symptom can occur when the shop is not in the accepted country list, this is Spain so should be valid.
The source code on the payment confirmation page seems correct:

<form onsubmit="submitonce();" id="checkout_confirmation" method="post" action="https://www.mysite.es/subdir/ipn_main_handler.php?type=ec&markflow=1&clearSess=1&stage=final" name="checkout_confirmation"><input type="hidden" value="7249fe1578a4fdfaf92fd07bcb427f38" name="securityToken"> <script> window.paypalCheckoutReady = function () { paypal.checkout.setup('my merchant id', { //locale: 'en_US', container: 'checkout_confirmation', button: 'btn_submit' }); }; </script> <script async="" src="//www.paypalobjects.com/api/checkout.js"></script><div class="buttonRow forward"><button id="btn_submit" name="btn_submit_x" value="Confirm Order" type="submit" onmouseout="this.className='cssButton submit_button button button_confirm_order'" onmouseover="this.className='cssButtonHover button_confirm_order button_confirm_orderHover'" class="cssButton submit_button button button_confirm_order">Confirm Order</button></div> </form>

Setting the PPDEBUG cookie from the console yields this info

{"status":"IC_SETUP","button-type":"JS","button-number":1,"merchantSite":"www.my_website.es","version":"3.0","token":null,"guid":"f46da875-5c2d-7b58-260d-0715581980e3","oneTouchShowed":"false","jsBtnConfig":[]}
iframe
{"status":"IC_HERMES_PREFETCH_COMPLETE","elapsed":1203,"merchantSite":" www.my_website.es ","version":"3.0","token":null,"guid":"f46da875-5c2d-7b58-260d-0715581980e3","oneTouchShowed":"false","jsBtnConfig":[]}

I note that after cancelling the paypal page to return to the shop and trying again, the in-context code is NOT generated...?

<form onsubmit="submitonce();" id="checkout_confirmation" method="post" action="https://www.motorvista.es/tienda_155/ipn_main_handler.php?type=ec&markflow=1&clearSess=1&stage=final" name="checkout_confirmation"><input type="hidden" value="7249fe1578a4fdfaf92fd07bcb427f38" name="securityToken"><div class="buttonRow forward"><button id="btn_submit" name="btn_submit_x" value="Confirm Order" type="submit" onmouseout="this.className='cssButton submit_button button button_confirm_order'" onmouseover="this.className='cssButtonHover button_confirm_order button_confirm_orderHover'" class="cssButton submit_button button button_confirm_order">Confirm Order</button></div> </form>

Often I come across stuff that fails when in Spanish, but this is generated with shop language as English.
I've tried this with my in-development 155 shop and a vanilla 155 on my hosting with the same result.
Since there are few/no queries about this, I assume it usually works.

All I have done to enable this is add my merchant id. From what I can see in the code, that is all that is necessary.

3 Aug 2016, 9:37 PM
#2
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
730
Plugin Contributions:
0

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

I am experiencing this also. Setup correctly as far as I know on UK store, with merchant ID after going to Paypal settings as instructed. I could see sometimes it starts to open a lightbox then goes to full page version. But right now it seems to go straight to normal paypal full page version.

4 Aug 2016, 11:52 AM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

Is there anything noted in the console-log?

4 Aug 2016, 1:43 PM
#4
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,872
Plugin Contributions:
7

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

No errors, only the info stuff due to the debug cookie being set.

5 Aug 2016, 9:10 AM
#5
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,872
Plugin Contributions:
7

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

Since this was added in 1.55, I would assume the lack of a comment from a dev implies it all worked first time when implemented/they have not seen this issue.

I note that the js code for in-context is added into the page only on the first attempt, after the failure/subsequently it is not, and so goes straight to the full-page screen.
If I try again "some time later" the code does get inserted on the first attempt again. This seems to be a consequence of the problem, not the problem itself. I assume this is a Paypal-controlled thing?

5 Aug 2016, 9:54 AM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

torvista:

Since this was added in 1.55, I would assume the lack of a comment from a dev implies it all worked first time when implemented/they have not seen this issue.

I note that the js code for in-context is added into the page only on the first attempt, after the failure/subsequently it is not, and so goes straight to the full-page screen.
If I try again "some time later" the code does get inserted on the first attempt again. This seems to be a consequence of the problem, not the problem itself. I assume this is a Paypal-controlled thing?

They were having difficulty with reloading the applicable page to then cause/allow the javascript to reload, but I have seen it implemented on previous ZC versions outside of the changes made to support ZC 1.5.5 where 1) it continues to function, 2) does reload after a cancel operation, 3) is not going directly to the standard PP screen like is being seen on ZC 1.5.5.

Can't recall if the reload operation to provide the javascript again on cancellation required ZC code modification or was corrected by PP. Do know that one difference in application elsewhere as compared to how it was implemented in ZC 1.5.5 is that the PP variable SOLUTIONTYPE set to "sole" elsewhere was not modified to Mark. Not able at the moment to test whether that is related to this issue or not.

8 Aug 2016, 1:27 PM
#7
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

I just tested a newly upgraded 1.5.5a version and the popup does not display on it either, it just goes over to the paypal screen.
The Paypal Merchant ID is entered because I know it is required for this function to work. All other credentials are correct as well.
:please:

8 Aug 2016, 2:46 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

Following @torvista's approach, I set the PPDEBUG cookie in the FireFox console and also clicked the "Persist" button so that any transitional issues would also be reported. What I was "rewarded with" was the following additional console-log that might shed some light on the issue:

{"status":"IC_DESTROY_NO_CANCEL_RETURN_URL","merchantSite":"mysite.com","version":"3.0","token":null,"guid":"a2aea560-b928-84ad-8604-fc98812b05d2","oneTouchShowed":"false","jsBtnConfig":[]}
8 Aug 2016, 2:58 PM
#9
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

I was just asking another Zen Cart expert about this and she said we needed PayPal's AJAX. I am not a coder, so have no stinking clue what that means... but here is what I found on PayPal site

Manual or AJAX Integrations

In certain use cases, you may want to manually initiate the checkout experience, such as, if you are calling the APIs with AJAX from the browser or from a Flash application. This can be done using the click setting, and manually calling paypal.checkout.initXO, paypal.checkout.startFlow, and paypal.checkout.closeFlow. See the following example:

paypal.checkout.setup('Your-Merchant-ID', {
environment: 'sandbox',
container: 'myContainer',
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();
});

}
});

10 Aug 2016, 12:38 AM
#10
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

I'm also testing this as well and the popup does not display for me, it goes straight to paypal's full screen checkout.

11 Aug 2016, 5:01 AM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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:

<?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.)

11 Aug 2016, 11:54 AM
#12
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

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?

11 Aug 2016, 3:02 PM
#13
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

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

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:

<?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.)
11 Aug 2016, 3:20 PM
#14
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

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.

11 Aug 2016, 3:24 PM
#15
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

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?

11 Aug 2016, 3:30 PM
#16
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

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

13 Aug 2016, 1:13 PM
#17
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

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:

<?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:**
<?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.)
13 Aug 2016, 1:36 PM
#18
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

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

13 Aug 2016, 1:49 PM
#19
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Paypal In-context popup does not load content, then proceeds to full-page payment

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.

13 Aug 2016, 1:52 PM
#20
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

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?