0
我想實現PayPal支付按鈕,使用此教程:PayPal支付錯誤 - 的ReferenceError:動作沒有定義
我有checkout.js頁面上的文件:
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
按鈕的代碼是:
<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!
// You can now show a confirmation message to the customer
});
}
}, '#paypal-button');
</script>
但是當我點擊butto n在控制檯中出現「ReferenceError:actions is not defined」並且沒有任何反應。我是否應該包含另一個Javascript文件,因爲它在本教程中未提及?
媽的,我怎麼錯過。不知道我如何設法複製並粘貼錯誤,但非常感謝! – user3592246
我認爲貝寶文檔示例沒有反映出這一點。謝謝你,這也幫助了我。 – jremi