2017-07-30 99 views
0

我想实现PayPal支付按钮,使用此教程:PayPal支付错误 - 的ReferenceError:动作没有定义

https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/client-side-REST-integration/

我有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文件,因为它在本教程中未提及?

回答

5
payment: function() { 

应该

payment: function(data, actions) { 
+0

妈的,我怎么错过。不知道我如何设法复制并粘贴错误,但非常感谢! – user3592246

+0

我认为贝宝文档示例没有反映出这一点。谢谢你,这也帮助了我。 – jremi

相关问题