【问题标题】:PayPal integration 400 Bad Request / Order could not be capturedPayPal 集成 400 错误请求/订单无法捕获
【发布时间】:2021-01-20 16:33:13
【问题描述】:

我正在尝试集成 PayPal,但出现以下错误

您可以在此处使用任何 PayPal 沙盒买家帐户测试代码: Codepen

这是我正在使用的代码

    paypal.Buttons({
  createOrder: function (data, actions) {
    // This function sets up the details of the transaction, including the amount and line item details.
    return actions.order.create({
      purchase_units: [{
        amount: {
          value: '5.00'
        }
      }]
    });
  },
  onApprove: function (data, actions) {
    // This function captures the funds from the transaction.
    return actions.order.capture().then(details => {
      // This function shows a transaction success message to your buyer.
      alert('Transaction completed by ' + details.payer.name.given_name);
    });
  }
}).render('#paypal-button-container');

关于错误的更多信息

【问题讨论】:

  • 您可能应该关注之前发生的错误请求 400 错误...
  • 是的,我认为是相关的
  • 是的,URL 以 capture 结尾,所以可以肯定地说它是相关的 :)
  • 正如 Chris 所说,您应该展开 POST 400 Bad Request,并发布所有详细信息。
  • @PrestonPHX 完成,更新了我的问题

标签: javascript paypal paypal-sandbox


【解决方案1】:

从“网络”选项卡测试您的 Codepen,您会收到 COMPLIANCE_VIOLATION - 可能是由于您正在测试的帐户所在的国家/地区没有在沙盒中正确设置。

尝试在沙盒中简单地使用不同的国家/地区进行测试。在 https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts%2F 创建一个新的企业帐户,然后使用新的 ClientID/Secret 创建一个新的 REST 应用程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-29
    • 1970-01-01
    • 2012-08-02
    • 1970-01-01
    • 2013-04-28
    • 2017-05-31
    • 2018-04-27
    • 2015-08-12
    相关资源
    最近更新 更多