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移动网络?
尝试将您的网站重定向到
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>
Run Code Online (Sandbox Code Playgroud)