gpt4 book ai didi

javascript - 使用客户端 REST api 的 Laravel 中不显示 PayPal 按钮

转载 作者:太空宇宙 更新时间:2023-11-03 16:22:33 25 4
gpt4 key购买 nike

我已将 PayPal 支付选项添加到我的网站。我已经集成了 PayPal 支付的代码如下:

<div class="col-md-6 col-xs-12">
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div class="sec_pay_hd">
Payment Method
</div>
<div id="paypal-button-container"></div>
<div id="confirm" class="hidden">
<div>Ship to:</div>
<div><span id="recipient"></span>, <span id="line1"></span>, <span id="city"></span></div>
<div><span id="state"></span>, <span id="zip"></span>, <span id="country"></span></div>

<button id="confirmButton">Complete Payment</button>
</div>
<div id="thanks" class="hidden">
Thanks, <span id="thanksname"></span>!
</div>
<!-- <div class="pay_mode_img1 visa_imgsasa"> -->
<!-- </div> -->
<script>
paypal.Button.render({

env: 'sandbox', // sandbox | production

client: {
sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
production: '<insert production client id>'
},

payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '0.01', currency: 'USD' }
}
]
}
});
},

// Wait for the payment to be authorized by the customer

onAuthorize: function(data, actions) {

// Get the payment details

return actions.payment.get().then(function(data) {

// Display the payment details and a confirmation button

var shipping = data.payer.payer_info.shipping_address;

document.querySelector('#recipient').innerText = shipping.recipient_name;
document.querySelector('#line1').innerText = shipping.line1;
document.querySelector('#city').innerText = shipping.city;
document.querySelector('#state').innerText = shipping.state;
document.querySelector('#zip').innerText = shipping.postal_code;
document.querySelector('#country').innerText = shipping.country_code;

document.querySelector('#paypal-button-container').style.display = 'none';
document.querySelector('#confirm').style.display = 'block';

// Listen for click on confirm button

document.querySelector('#confirmButton').addEventListener('click', function() {

// Disable the button and show a loading message

document.querySelector('#confirm').innerText = 'Loading...';
document.querySelector('#confirm').disabled = true;

// Execute the payment

return actions.payment.execute().then(function() {

// Show a thank-you note

document.querySelector('#thanksname').innerText = shipping.recipient_name;

document.querySelector('#confirm').style.display = 'none';
document.querySelector('#thanks').style.display = 'block';
});
});
});
}

}, '#paypal-button-container');

</script>

<div class="visa_imgsasa">
<img src="{{asset('assets/resources/images/visa-image.png')}}" alt="">
</div>

我在页面顶部添加了 paypal 脚本。但是现在我反复收到这个错误

screenshot for error part-1

enter image description here

感谢任何形式的帮助,我已经在网上搜索了这个错误,但找不到任何帮助。这是 paypal 网站演示中的示例代码。但这在我的本地服务器上也不起作用。

最佳答案

$('nav#menu').mmenu();

^ 从您的页面中删除它可以解决问题。我的猜测是从 DOM 中删除 iframe 然后重新添加它,这会导致 iframe 的内部窗口关闭。

关于javascript - 使用客户端 REST api 的 Laravel 中不显示 PayPal 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47004516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com