PayPal 灯箱无法在 iPhone Safari/Web 应用程序中打开;'win.location' 未定义 [英] PayPal lightbox won't open in iPhone safari/web app; 'win.location' undefined

查看:23
本文介绍了PayPal 灯箱无法在 iPhone Safari/Web 应用程序中打开;'win.location' 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(在 iPhone 上的 Chrome 中工作正常)

(works fine in Chrome on the iPhone)

我收到此错误:

TypeError: 'undefined' is not an object (evaluating 'win.location') in dg.js line 3

并且灯箱打不开.

PayPal dg.js 中的相关代码是:

The code in question inside PayPal's dg.js is:

startFlow: function (url) {
    var win = that._render();
    if (win.location) {
        win.location = url;
    } else {
        win.src = url;
    }
}

那么移动 Safari 不理解 that._render() 吗?我该如何解决这个问题?

So does mobile Safari not understand that._render()? How do I get around this?

如果有关系,我正在使用 Adaptive Payments,这样称呼它:

If it matters, I'm using Adaptive Payments, calling it like so:

var dg = new PAYPAL.apps.DGFlow({
    trigger: null, 
    expType: 'light'
});
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);

我在获取 payKey 时没有任何问题 &整个 payflow 可在台式机和除 Safari 以外的移动浏览器中运行(它可在台式机 Safari 上运行).当我们的网站作为 iOS 网络应用运行时,它也不起作用,我认为它只是 Safari 的外壳.

I don't have any problems getting the payKey & the entire payflow works on desktops and in mobile browsers other than Safari (it works on desktop Safari). It also does not work when our site is run as an iOS web app, which I assume is just a shell for Safari anyway.

推荐答案

找到了几种方法来解决这个问题...location.replace 使用 PayPal URL 或使用您自己的灯箱.我使用了 easybox.

Found a couple of ways to get around this...location.replace with the PayPal URL or using your own lightbox. I used easybox.

// Replace
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);

// with
var RUNNING_AS_WEB_APP = (window.navigator.standalone == true ? true : false);
if (RUNNING_AS_WEB_APP === false) {
    dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
} else {
    location.replace('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
    // Or, lightbox option: 
    // $.easybox([{url: 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey, width: 320, height: 480}]);
} 

这篇关于PayPal 灯箱无法在 iPhone Safari/Web 应用程序中打开;'win.location' 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆