Paypal自适应支付迷你浏览器

Paypal Adaptive payment minibrowser

我正在尝试使用 PHP 中使用 Codeigniter 框架的迷你浏览器选项为我的产品使用 Paypal 自适应支付。当我点击支付按钮时,迷你浏览器打开得很好,但是当我点击登录按钮时,新选项卡打开,但我想在现有的迷你浏览器中打开这个登录。

查看文件:

       <html>
       <head>
       <script src="https://www.paypalobjects.com/js/external/apdg.js" type="text/javascript"></script>
     </head>
     <body>
      <?php echo form_open_multipart('pay/splitPay','target="PPDGFrame"', 'class="standard"', 'id="mini-form"'); ?>
  <label for="buy">Buy Now:</label>
     <input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
    <input id="type" type="hidden" name="expType" value="mini">
    <input id="paykey" type="hidden" name="paykey" value="10">
    </form>
     <script type="text/javascript" charset="utf-8">
        var returnFromPayPal = function(){

        alert("Returned from PayPal");
     // Here you would need to pass on the payKey to your server side handle to call the PaymentDetails API to make sure Payment has been successful or not
  // based on the payment status- redirect to your success or cancel/failed urls
      }
     var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'submitBtn', expType: 'mini', callbackFunction: 'returnFromPayPal'});
     </script>

控制器:

     function splitPay() {
       $createPacket = array (
        "actionType" => "PAY",
        "currencyCode" => 'USD',
        "receiverList" => array(
                "receiver" => array(
                    array("amount"=>'2.00', "email"=>'bhomnath@salyani.com.np'),
                    array("amount"=>'4.00', "email"=>'infotechnab_api1@yahoo.com'),
                )
            ),
        "returnUrl" => 'http://localhost/paypal/index.php/pay/notify_payment',
        "cancelUrl" => 'http://localhost/paypal/index.php/pay/tempo',
        "requestEnvelope" => $this->envelope
    );

    $response = $this->_paypalSend($createPacket,"Pay");
    $payKey = $response['payKey'];
    $detailsPacket = array(
        "requestEnvelope" => $this->envelope,
        "payKey" => $payKey,
        "receiverOptions" => array(
            array(
                "receiver"=>array(
                    'email'=>'bhomnath@salyani.com.np'),
                    'invoiceData'=>array(
                    'item'=>array(
                        array(
                            "name"=>'product1',
                            "price"=>'1.00',
                            "identifier"=>'P1'
                        ),
                        array(
                             "name"=>'product2',
                            "price"=>'1.00',
                            "identifier"=>'P2'
                        )
                    )
            )),
            array(
                "receiver"=>array(
                    'email'=>'infotechnab_api1@yahoo.com'),
                    'invoiceData'=>array(
                    'item'=>array(
                        array(
                            "name"=>'product3',
                            "price"=>'2.00',
                            "identifier"=>'P1'
                        ),
                        array(
                             "name"=>'product4',
                            "price"=>'2.00',
                            "identifier"=>'P2'
                        )
                    )
            ))
        )
    );

    $response = $this->_paypalSend($detailsPacket,"SetPaymentOptions");

    $dets = $this->getPaymentOptions($payKey);

    header("Location: ".$this->paypalUrl.$payKey);
}

PayPal 的安全要求会在某些情况下强制执行新的 window(并且 javascript 强制执行此操作)。通常,当用户输入登录凭据时,他们需要这样做,这可能是您在问题中使用 "login" 与 "payment" 按钮所指的?

这样做是为了最大限度地降低通过跨站点脚本攻击窃取凭据的风险,并确保用户看到 "chrome"(例如安全连接符号和 PayPal URL)并可以验证 window 在输入凭据时安全地连接到 PayPal(出于反网络钓鱼的原因)。

一些较新的 PayPal 产品放宽了这些要求,但我相当确定 Adaptive 坚定地采用了这种模式。