21

モバイル Web サイトにPaypal Adaptive Payment APIを統合しています。しかし、私が支払いを提出するとき

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

(サンドボックスの場合: https://www.sandbox.paypal.com/cgi-bin/webscr )

その常に Paypal メイン Web にリダイレクトします。Paypal Mobile ウェブサイトではありません。クライアントをペイパル モバイル Web にリダイレクトする方法は?

4

4 に答える 4

6

私が見つけた最良のアプローチは、ミニ ブラウザー エクスペリエンスでした。しかし、それを実装するモバイル デバイスにはさまざまな問題がありました (これがそもそもの目的でした)。アダプティブ ペイメントや、ライトボックスやミニ ブラウザー エクスペリエンスの使用に関するあらゆる種類の問題について、同様の質問が多数寄せられます。

しかし、ついに...何時間も何日も何日も経って、私はそれを理解しました! これにより、PayPal アダプティブ ペイメントの問題や次の問題に関して、あらゆる種類の問題が解決されるはずです。

  1. リダイレクトされたデフォルトのペイパル ページはモバイル対応ではなく、モバイル デバイスでは見栄えが悪くなります。
  2. ライトボックスが「ハングアップ」し、一部のモバイル デバイスで閉じません。
  3. 決済完了後やキャンセル後、ミニブラウザが閉じない。
  4. ミニ ブラウザは、paypal apdg.js スクリプトから callBackFunction にリダイレクトしません。
  5. 決済完了後(またはキャンセル時)に returnUrl と cancelUrl にリダイレクトしない
  6. Chrome for ios (iphones) はコールバック関数を開始しないため、支払いの完了またはキャンセルの後、PayPal 支払いページを起動したページにとどまり、支払いの成功または失敗を検証できなくなります。

ドラムロールください....ここにあります!! これにより、PayPal JavaScript ファイルなどの必要性が置き換えられます。必要なのは、リダイレクト URL に追加する PayKey を取得する独自の方法とともに、以下に示すものだけです。以下のコードを使用してアダプティブペイメントが正しく機能している私のライブ Web サイトはhttps://www.trackaill.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>
于 2015-05-13T21:42:11.993 に答える
6

サイトをリダイレクトしてみてください

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

AP-XYZ の代わりに支払いキーを入力します

それが機能するかどうか教えてください。

于 2012-10-03T01:45:05.590 に答える
1

実際には、どこにも文書化されていない、これに対する簡単な解決策があります。少し前に追加することについてPayPalと話し合っていたので、最終的に実装されるかどうか疑問に思っています.

とにかく、ユーザーを次の URL にリダイレクトするだけで、完了時にサイトにリダイレクトされます。

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

ここでの違いは、expType=redirectむしろそれを使用することexpType=miniです。これがいつ追加されたのかはわかりませんが、少しのリバース エンジニアリングといくつかの実験の後、驚くほど簡単な解決策が得られました。

于 2015-10-16T10:11:02.500 に答える
0

that's right - the Adaptive Payments UI is not Mobile optimized. But the closest to that it offers is what we call the MiniBrowser experience. You can try and see if that serves your needs. You can find the how-to guide here on X.com: Implementing the Mini-Browser Option

于 2012-10-01T16:15:49.627 に答える