问题描述
我正在尝试使用微型浏览器选项(使用PHP中的Codeigniter框架)为我的产品使用Paypal自适应支付.当我单击付款"按钮时,迷你浏览器会打开很好,但是当我单击登录"按钮时,会打开新标签,但我想在现有的迷你浏览器中打开此登录.
I'm trying to use Paypal adaptive payment using mini browser option using Codeigniter framework in PHP for my products. When I click on pay button, the mini browser opens nice but when I click on Login buttons new tab opens but I want to open this login open in existing mini browser.
视图文件:
<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"=>'[email protected]'),
array("amount"=>'4.00', "email"=>'[email protected]'),
)
),
"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'=>'[email protected]'),
'invoiceData'=>array(
'item'=>array(
array(
"name"=>'product1',
"price"=>'1.00',
"identifier"=>'P1'
),
array(
"name"=>'product2',
"price"=>'1.00',
"identifier"=>'P2'
)
)
)),
array(
"receiver"=>array(
'email'=>'[email protected]'),
'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强制执行此操作).通常,他们在用户输入登录凭据时要求这样做,这可能就是您在问题中使用登录"还是付款"按钮所指的内容?
PayPal has security requirements that force a new window under some circumstances (and javascript to enforce this). Generally, they require this when the user is entering login credentials, which may be what you are referring to with the "login" vs "payment" button in your question?
这样做是为了最大程度地减少跨站点脚本攻击造成的凭据被盗的风险,并确保用户看到"chrome"(例如安全连接符号和PayPal URL),并可以在输入密码时确认窗口已安全连接到PayPal.凭据(出于反网络钓鱼的原因).
This is done to minimize risk of credential theft through cross-site scripting attacks and to ensure the user sees the "chrome" (e.g. secure connection symbols and PayPal URL) and can verify the window is securely connected to PayPal when entering their credentials (for anti-phishing reasons).
某些较新的PayPal产品正在放宽这些要求,但我可以肯定Adaptive在此范例中很可靠.
Some of the newer PayPal products are relaxing these requirements, but I'm fairly certain Adaptive is solidly in this paradigm.
这篇关于贝宝自适应支付微型浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!