php - Paypal自适应支付迷你浏览器

标签 php codeigniter paypal

我正在尝试通过使用 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>

Controller :

     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 的安全要求在某些情况下会强制打开一个新窗口(并且 javascript 会强制执行此操作)。通常,当用户输入登录凭据时,他们需要这样做,这可能是您在问题中使用“登录”与“付款”按钮所指的内容?

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

一些较新的 PayPal 产品放宽了这些要求,但我相当肯定 Adaptive 坚定地遵循这种范式。

关于php - Paypal自适应支付迷你浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28104037/

相关文章:

php - 我如何在 CodeIgniter 中使用正确的面向对象模型和构造函数?

sql - 在 Codeigniter & Dwoo 中显示来自同名 MySQL 数据库字段的多个值

Paypal 小额支付

api - 如何格式化 SOAP 请求?

php - 用 PHP(和 HTML)更新 Mysql 的 HTML 表单

php - 如何使用 PHP 和 Open Graph API 发布到 Facebook 粉丝页面的墙上

javascript - PHP 和 Ajax : manage list update

javascript - 从本地服务器访问本地网络上的客户端打印机

php - 发送带有附件的自动电子邮件时,有时文件会重复

php - 编写我自己的电子商务网站是否会导致我的网站最有可能被黑客入侵?