【问题标题】:PayPal Checkout JS Error HandlingPayPal Checkout JS 错误处理
【发布时间】:2018-08-13 14:06:46
【问题描述】:

我正在阅读 PayPal Checkout 文档的这一小节:https://developer.paypal.com/docs/checkout/how-to/customize-flow/#manage-funding-source-failure。这里他们包括这个代码sn-p:

paypal.Button.render({
  //Configure environment
  env: 'production', // To test, set to `sandbox`
  payment: function () {
    // Set up the payment here, when the buyer clicks on the button
  },
  onAuthorize: function (data, actions) {
    // Call your server to execute the payment
    if (error === 'INSTRUMENT_DECLINED') {
      actions.restart();
    }
  }
}, '#paypal-button');

有谁知道该文档是否正确? PayPal checkout.js 是否在全局范围内管理错误变量?如果没有,您如何正确实施该指南?

注意:交叉发布https://github.com/paypal/paypal-checkout/issues/790

【问题讨论】:

    标签: javascript paypal


    【解决方案1】:

    该文档不正确。 checkout.js 代码为您处理一个 /payment 错误 - INSTRUMENT_DECLINED - 通过自动重启交易,您可以通过调用“actions.restart()”自行完成。

    所有其他错误消息,包括 HTTP 错误,都转到您需要设置的错误消息处理程序。例如:

    paypal.Button.render({
    env: 'sandbox',
    payment: function () {
      // Set up the payment here, when the buyer clicks on the button
    },
    onAuthorize: function (data, actions) {
      // Execute the payment here, when the buyer approves the transaction
    },
    onError: function (err) {
      // Show an error page here, when an error occurs
    }
    }, '#paypal-button');
    

    请注意,如果您正在执行服务器集成,则服务器将处理错误,而不是按钮。

    【讨论】:

      猜你喜欢
      • 2012-12-21
      • 2013-11-20
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 2017-08-18
      • 2017-07-20
      • 2011-08-17
      • 2017-05-31
      相关资源
      最近更新 更多