Javascript issue inside PayPal's apdg.js: Cannot read property 'apps' of undefined

lbpp
Contributor
Contributor

Hi

I'm posting here because I'm getting a TypeError from a PayPal Javascript file, remotely included into a website.

 

In our cart page (site under testing and not public at the moment) we reference, using the script tag, https://www.paypalobjects.com/js/external/apdg.js.

There seems to be a Javascript error in this script file. A TypeError is thrown.

Below is a screenshot. I placed a breakpoint at line twenty-two, and it seems that Javascript is hoisting the variable PAYPAL before window.PAYPAL is set, with window.PAYPAL being correctly initialised and the locally scoped, hoisted, PAYPAL is, if I'm correct, undefined - hence the error.

I'm running:

 

Chrome Version 67.0.3396.87 (Official Build) (64-bit)

 

Everything's been working fine until I noticed this error, I believe last time this worked would be a month ago or more.

We are using sandbox PayPal Chained Payments, with a sandbox AU business account. But this issue occurs before checkout can proceed.

 

Not sure if this technology is now deprecated, or the June security tests affect it, and hope this is the correct forum.

 

Thank you kindly

Leo


Capture.PNG

Login to Me Too
8 REPLIES 8

armandojs
Contributor
Contributor

Hi Leo,

 

Hope you're doing well.  I'm facing similar issues with embedded adaptive payments. I reached support yesterday and they told me that the lightbox is no longer supported.  I'm trying to get the 'mini' flow to work but I ran into this issue.  Here are some things I've tried out:

 

  • For some reason if I use the JS functions for the lightbox, it works a little better for the 'mini-browser', however the popup window shows a different style than before. For example, using 'dg.js' and initializing the object like this: 
    let embeddedPPFlow = new PAYPAL.apps.DGFlow({expType: 'mini', trigger: 'submitBtn'});
    Opens up a popup and a mini-browser.  In order for this to work I downloaded 'dg.js' and set line 3 to false.  This also needs to be done on 'apdg.js' 
    fullpageRedirect = false;
  • For 'apdg.js' to work, I had to replicate the PAYPAL object declaration similar to 'dg.js', however using 'apdg.js' does show the mini browser but it doesn't show the popup window. 
    if (typeof PAYPAL == 'undefined' || !PAYPAL) {
    let PAYPAL = {};
    }
    window.PAYPAL = window.PAYPAL || {};
    PAYPAL.apps = PAYPAL.apps || {};
     This popup shows when using dg.js but not with apdg.js. I'm probably doing something wrong.This popup shows when using dg.js but not with apdg.js. I'm probably doing something wrong.

This is how I got it to work, but as you can see, the login page has a very different style than the classic embedded flow.This is how I got it to work, but as you can see, the login page has a very different style than the classic embedded flow.

I hope this helps you out a bit.  Good Luck!

Login to Me Too

armandojs
Contributor
Contributor

Hi, I have no idea why my previous reply was rejected.  Here I go again.  I'll just copy/paste.

-----------------------------------------------------------------------------

Hi Leo,

Hope you're doing well. I'm facing similar issues with embedded adaptive payments. I reached support yesterday and they told me that the lightbox is no longer supported. I'm trying to get the 'mini' flow to work but I ran into this issue. Here are some things I've tried out:

 

    • For some reason if I use the JS functions for the lightbox, it works a little better for the 'mini-browser', however the popup window shows a different style than before, I added a photo at the end so you can see what I mean. For example, using 'dg.js' and initializing the object like this:
      let embeddedPPFlow = new PAYPAL.apps.DGFlow({expType: 'mini', trigger: 'submitBtn'});
      Opens up a popup and a mini-browser (image at the end). In order for this to work I downloaded 'dg.js' and set line 3 to false. This also needs to be done on 'apdg.js'.  If not then any trigger on the flow will redirect instead of open the embedded window.
      fullpageRedirect = false;
    • For 'apdg.js' to work, I had to replicate the PAYPAL object declaration similar to 'dg.js', however using 'apdg.js' does show the mini browser but it doesn't show the popup window.
      if (typeof PAYPAL == 'undefined' || !PAYPAL) {
           let PAYPAL = {};
      }
      window.PAYPAL = window.PAYPAL || {};
      PAYPAL.apps = PAYPAL.apps || {};

       

       

      This is how I got it to work, but as you can see, the login page has a very different style than the classic embedded flow.This is how I got it to work, but as you can see, the login page has a very different style than the classic embedded flow.

       

      This popup shows when using dg.js but not with apdg.js. I'm probably doing something wrong.This popup shows when using dg.js but not with apdg.js. I'm probably doing something wrong.

 

I hope this helps you out a bit. Good Luck!

Login to Me Too

Opango
Contributor
Contributor
We are having similar issue. All of a sudden our adaptive payments popup failed and the users are now directed into full page paypal to finish the operation. Because of some other dependencies, we are needing the popup mini browser to work again. I certainly suspect the appears to be bug code in https://www.paypalobjects.com/js/external/dg.js , where fullpageRedirect starts off true and never is set to false. I tried to download the file and use locally on our website, but we then get errors related to cross-origin, e.g. Refused to display 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?payKey=AP-8MS35391W82097814' in a frame because it set 'X-Frame-Options' to 'sameorigin'. Paypal needs to fix the problem!
Login to Me Too

armandojs
Contributor
Contributor
I understand your frustration, I got the same issue with Adaptive Payments, using the lightbox. I contacted support and it seems that the lightbox did not survive their recent security upgrade. It will no longer be supported, only the full page redirect and the 'mini'. I have an almost working example for the 'mini', the only thing is that once the mini browser pops up, it loads the full page design which does not fit inside the mini. Let me know if you would like an example of what I'm doing. Good Luck!
Login to Me Too

Opango
Contributor
Contributor
Thanks for the information. Suppose will try mini, but concerned about the limitations that you are seeing. Our app also runs on mobile via responsive design. Fear that it will not work there. We have posted questions to support and have been mostly ignored. Did they mention about any official word from them on this being no longer support or a potential work around maybe coming soon. Hard to see them just drop this. Guess just hopeful 🙂 Thanks again for the reply/
Login to Me Too

armandojs
Contributor
Contributor

No worries, glad I could help.  Quick question though, were you able to get the 'mini' working? I do get it to show however I get the full page inside the mini instead of the embedded style.  User won't know to scroll sideways to log-in.  

Login to Me Too

Opango
Contributor
Contributor

same issue you had.  It brings up the full window inside the dialog box.  Though, we have 2 sites basically integrated into our site.  One is using the paypalobjects.com/.../dg.js  and the other is using a local copy of some paypal code that is different.  The one using the dg.js does not work as mini,  it goes to the full page view.  The one using I think somewhat newer paypal code, behaves the same as yours.  The dialog does come up, but with a full page enclosed in it.

 

Will update here if we get any progress on this.  We are connecting with them also on a direct support event.

 

Login to Me Too

Dan2743
Member
Member

Have you heard anything back from PayPal regarding this issue?

 

Also has anyone found a way to get the PayPal mini browser to stop displaying in the full page view?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.