Paypal针对移动网络的自适应支付

Sen*_*ncy 20 paypal mobile-website paypal-adaptive-payments

我正在为移动网站集成Paypal自适应支付API.但是当我提交付款时

https://www.paypal.com/webscr?cmd=_ap-payment&paykey=value

(对于Sandbox:https://www.sandbox.paypal.com/cgi-bin/webscr)

它总是重定向到Paypal主网站.不要Paypal移动网站.如何将客户端重定向到paypal移动网络?

Rus*_*hik 6

尝试将您的网站重定向到

https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-XYZ&expType=mini

填写您的付款密钥代替AP-XYZ

如果有效,请告诉我.


Tra*_*com 5

我发现的最佳方法是迷你浏览器体验.但是我在实现它的移动设备上遇到了各种不同的问题(这首先是它的意思).您将看到许多关于自适应支付的类似问题以及使用灯箱和迷你浏览器体验的各种问题.

但是最终......我已经在几小时,几天后发现了它!当涉及到PayPal适应性支付的问题以及以下问题时,这应解决所有不同品种的每个人的问题:

  1. 默认重定向的paypal页面不是移动响应,在移动设备上看起来很糟糕.
  2. 灯箱被"挂起"并且在某些移动设备上没有关闭.
  3. 完成付款或取消后,迷你浏览器不会关闭.
  4. 迷你浏览器不会从paypal apdg.js脚本重定向到callBackFunction.
  5. 付款完成后(或取消时)不会重定向到returnUrl和cancelUrl
  6. Chrome for ios(iphone)不启动回拨功能,因此在付款完成或取消后,它只会让您进入您启动PayPal付款页面的页面,从而阻止您验证付款的成功或失败.

请滚筒....这里是!! 这取代了对PayPal javascript文件等的任何需求.您需要的是以下内容以及您自己的获取PayKey以添加到重定向URL的方法.我的实时网站,使用以下代码正确地进行自适应支付,是https://www.trackabill.com.

<div>
    <?php $payUrl = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=mini&paykey=' . $payKey ?>

    <button onclick="loadPayPalPage('<?php echo $payUrl; ?>')" title="Pay online with PayPal">PayPal</button>
</div>
<script>
    function loadPayPalPage(paypalURL)
    {
        var ua = navigator.userAgent;
        var pollingInterval = 0;
        var win;
        // mobile device
        if (ua.match(/iPhone|iPod|Android|Blackberry.*WebKit/i)) {
            //VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone
                //See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610
            win = window.open(paypalURL,'_blank');

            pollingInterval = setInterval(function() {
                if (win && win.closed) {
                    clearInterval(pollingInterval);
                    returnFromPayPal();
                }
            } , 1000);
        }
        else
        {
            //Desktop device
            var width = 400,
                height = 550,
                left,
                top;

            if (window.outerWidth) {
                left = Math.round((window.outerWidth - width) / 2) + window.screenX;
                top = Math.round((window.outerHeight - height) / 2) + window.screenY;
            } else if (window.screen.width) {
                left = Math.round((window.screen.width - width) / 2);
                top = Math.round((window.screen.height - height) / 2);
            }

            //VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone
                //See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610
            win = window.open(paypalURL,'_blank','top=' + top + ', left=' + left + ', width=' + width + ', height=' + height + ', location=0, status=0, toolbar=0, menubar=0, resizable=0, scrollbars=1');

            pollingInterval = setInterval(function() {
                if (win && win.closed) {
                    clearInterval(pollingInterval);
                    returnFromPayPal();
                }
            } , 1000);
        }
    }

    var returnFromPayPal = function()
    {
       location.replace("www.yourdomain.com/paypalStatusCheck.php");
        // Here you would need to pass on the payKey to your server side handle (use session variable) to call the PaymentDetails API to make sure Payment has been successful
        // based on the payment status- redirect to your success or cancel/failed page
    }
</script>
Run Code Online (Sandbox Code Playgroud)