首页 > 解决方案 > PayPal 智能按钮交易显示错误

问题描述

我正在使用 PayPal 智能按钮在 JavScript 中进行付款。目前,我正在使用沙盒帐户进行测试。

此代码给出错误

function addPaypal()
{
    
     paypal.Buttons({
    
        createOrder: function(data, actions) {
          return actions.order.create({
            purchase_units: [{
              amount: {
              currency_code:'USD',
                value: '30.00'
              }
            }]
          });
        },
        onApprove: function(data, actions) {
          return actions.order.capture().then(function(details) {
          console.log(details);
          });
        },
         onCancel: function (data)  {
    
   }, 
  onError: function (err)  {
     console.log(err)
   }
      }).render('#paypal-button'); // Display payment options on your web page  
      
      }

我得到的错误是

details.purchase_units.amount 未定义

我正在使用两个沙盒帐户。我从中创建了一个应用程序并使用它的凭据。另一个是我支付测试费用的地方。

我检查了两个帐户。我没有得到更多关于错误的细节。

标签: javascriptpaypalpaypal-sandbox

解决方案


推荐阅读