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

时间:2012-05-05 15:41:01

标签: paypal mobile-website paypal-adaptive-payments

我正在为移动网站整合Paypal Adaptive Payment API。 但是当我向

提交付款时

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

(适用于Sandbox:https://www.sandbox.paypal.com/cgi-bin/webscr

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

4 个答案:

答案 0 :(得分:6)

尝试将您的网站重定向到

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

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

让我知道它是否有效。

答案 1 :(得分:5)

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

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

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

答案 2 :(得分:1)

实际上有一个简单的解决方案,没有记录在任何地方。我们正在与PayPal讨论关于添加它的问题,所以我想知道它是否最终得到实施。

无论如何,只需将用户重定向到以下网址,他们就会在完成后重定向回您的网站:

https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapproval?preapprovalKey=PA-XXXXX&expType=redirect

这里的区别在于使用expType=redirect而不是expType=mini。我不确定这是什么时候添加的,但经过一些逆向工程和一些实验后我们得到了一个非常简单的解决方案。

答案 3 :(得分:0)

没错 - 自适应支付用户界面不是针对移动设备优化的。但最接近它提供的是我们所说的MiniBrowser体验。您可以尝试查看是否符合您的需求。您可以在X.com上找到该方法指南:Implementing the Mini-Browser Option

相关问题