我正在尝试使用此处的教程实现Paypal结帐按钮:
我在页面上有checkout.js文件:
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
Run Code Online (Sandbox Code Playgroud)
按钮代码是:
<div id="paypal-button"></div>
<script>
paypal.Button.render({
env: 'sandbox', // 'sandbox' Or 'production',
client: {
sandbox: '<sandbox id>',
production: ''
},
locale: 'en_GB',
commit: true, // Show a 'Pay Now' button
payment: function() {
// Set up the payment here
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'GBP' }
}
]
}
});
},
onAuthorize: function(data, actions) {
// Execute the payment here
return actions.payment.execute().then(function(payment) {
// The payment is complete!
// …
Run Code Online (Sandbox Code Playgroud)