Ars*_*yan 18 paypal paypal-sandbox
如何触发PayPal Checkout按钮点击?我们有一个网站旁边的信用卡,我们将接受PayPal付款,我已决定为客户提供单选按钮,以选择客户将支付的方式以及PayPal Checkout按钮:

PayPal Checkout按钮单击本身打开PayPal安全窗口,其余工作正常.当客户点击第一个单选按钮我想再次打开PayPal安全窗口,即触发点击PayPal结账按钮.如果按钮本身出现在iframe中并且我无法触发该按钮跨域的点击事件,我该怎么办呢?有没有办法触发结账按钮点击?
这是HTML代码:
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script type="text/javascript" src="paypal.js">
</script>
<body>
<div>
<span style="vertical-align: 50%"><input id="rd" name="aaa" type="radio"/></span>
<div id="paypal-button-container" style="display: inline-block"></div><hr/>
<input id="rd1" name="aaa" type="radio"/>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和Javascript代码:
// paypal.js
// Render the PayPal button
$(function(){
paypal.Button.render({
// Set your environment
//TODO: Dynamically provide sandbox or production
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
//TODO: Dynamically provide clientID
client: {
sandbox: 'ZZZZZZ',
production: '//TODO: Provide this later'
},
// Wait for the PayPal button to be clicked
payment: function() {
// Make a client-side call to the REST api to create the payment
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: { total: '13.10', currency: 'USD' }
}
]
});
},
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) {
return actions.payment.get().then(function(paymentData) {
$('#paypal-button-container').style.display = 'none'; //hide button
//TODO: Show user payment details
//TODO: Create input hidden fields and set payerID, paymentID, etc..for later authoriza/capture
});
},
onClick: function(){
$('#rd').trigger('click');
},
}, '#paypal-button-container');
});
Run Code Online (Sandbox Code Playgroud)
编辑:作为一个工作的例子我会建议这个网站,但这有点不同我需要https://developer.paypal.com/demo/checkout/#/pattern/mark
blu*_*ume 10
这不是现在PayPal按钮支持的.官方政策是,只需点击按钮本身即可打开结帐窗口.
| 归档时间: |
|
| 查看次数: |
9902 次 |
| 最近记录: |