Javascript PayPal签出JS错误处理

Javascript PayPal签出JS错误处理,javascript,paypal,Javascript,Paypal,我正在阅读PayPal结帐文档的这一小部分:。此处包括以下代码段: 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: func

我正在阅读PayPal结帐文档的这一小部分:。此处包括以下代码段:

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是否在全局范围内管理错误变量?如果没有,您如何正确实施本指南


注意:交叉张贴的文档不正确。checkout.js代码通过自动重新启动事务来为您处理一个/payment错误-INSTRUMENT_谢绝-您可以通过调用“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');
请注意,如果您正在进行服务器集成,那么服务器将处理错误,而不是按钮