我正在为移动网站集成Paypal Adaptive Payment API 。但是当我提交付款给
https://www.paypal.com/webscr?cmd=_ap-payment&paykey=value
(对于沙盒:https ://www.sandbox.paypal.com/cgi-bin/webscr )
它总是重定向到贝宝主网。不是贝宝移动网站。如何将客户端重定向到贝宝移动网络?
我正在为移动网站集成Paypal Adaptive Payment API 。但是当我提交付款给
https://www.paypal.com/webscr?cmd=_ap-payment&paykey=value
(对于沙盒:https ://www.sandbox.paypal.com/cgi-bin/webscr )
它总是重定向到贝宝主网。不是贝宝移动网站。如何将客户端重定向到贝宝移动网络?
尝试将您的网站重定向到
https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-XYZ&expType=mini
填写您的支付密钥代替 AP-XYZ
让我知道它是否有效。
我发现最好的方法是迷你浏览器体验。但是我在实现它的移动设备上遇到了各种不同的问题(这就是它的初衷)。您会看到许多关于自适应支付的类似问题以及使用灯箱和迷你浏览器体验的各种问题。
但最后......我在几个小时之后,几天之后才弄清楚!当涉及到 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>
实际上有一个简单的解决方案,在任何地方都没有记录。我们正在与 PayPal 讨论添加它,所以我想知道它是否最终得到实施。
无论如何,只需将用户重定向到以下 URL,完成后他们将被重定向回您的站点:
https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapproval?preapprovalKey=PA-XXXXX&expType=redirect
The difference here is using expType=redirect
rather that expType=mini
. I'm not sure when this was added but after a bit of reverse engineering and some experimenting we have a surprisingly simple solution.
没错 - 自适应支付 UI 未针对移动设备进行优化。但最接近它提供的是我们所说的 MiniBrowser 体验。您可以尝试看看这是否满足您的需求。您可以在 X.com 上找到操作指南:实现迷你浏览器选项