0

ミニ ブラウザ オプションを使用して組み込みのアダプティブ ペイメントを実装しました。これは、Android フォンでは問題なく動作しますが、iPhone ブラウザ (Safari および Chrome) では問題があります。

Safari の場合:-ユーザーが手動で PayPal ポップアップを閉じる必要がありますが、自動的に閉じる必要があります。(ポップアップを手動で閉じた後、注文を更新するために使用している JavaScript コールバック関数がトリガーされます)

Chromeの場合:- ユーザーが [Pay] ボタンをクリックして Paypal 認証ミニ ブラウザーを開くと、支払いが成功した後、または支払いをキャンセルした後、ポップアップが自動的に閉じられず、手動で閉じたときにコールバックがトリガーされません。

次のコードを使用しています

<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame">
<input id="type" type="hidden" name="expType" value="mini">
<input id="paykey" type="hidden" name="paykey" value="AP-XXXXXXXXXXX"> 
<input type="submit" id="PPsubmitBtn" value="Pay">
</form>
<script src="https://www.paypalobjects.com/js/external/apdg.js"></script>
<script>
var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'PPsubmitBtn', callbackFunction: 'updateOrder'});

function updateOrder() {
     //My order stuff update code goes here
}
</script>
4

1 に答える 1

1

これにより、PayPal アダプティブ ペイメントの問題や次の問題に関して、あらゆる種類の問題が解決されるはずです。

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

これにより、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-13T20:18:39.460 に答える