【问题标题】:Paypal REST API error 400 : Invalid start datePaypal REST API 错误 400:开始日期无效
【发布时间】:2019-06-04 05:23:51
【问题描述】:

当我将用户重定向到贝宝支付页面时,我的应用程序经常崩溃。我有以下错误:

Error: Response Status : 400

[ { field: 'start_date', issue:
 'start date is required, should be valid and greater than the current date. Should be consistent with ISO 8601 Format' } ] 

但是,我按照 Github 示例文件中的格式设置日期

 var isoDate = new Date(Date.now())
    isoDate.setSeconds(isoDate.getSeconds() + 4);
    isoDate.toISOString().slice(0, 19) + 'Z';

我什至添加了几秒钟以确保日期大于当前日期

var isoDate = new Date(Date.now()+10000) isoDate.setSeconds(isoDate.getSeconds() + 4); isoDate.toISOString().slice(0, 19) + 'Z';

console.log(isoDate);

我不明白这个错误不是每次都会发生,而是经常发生,所以我真的无法在不修复它的情况下发布我的应用程序。

【问题讨论】:

  • 您调用的是哪种 PayPal API 方法?
  • 您是否尝试对 URL 进行编码?

标签: javascript node.js paypal


【解决方案1】:

请修改如下代码:

 var isoDate = new Date(Date.now())
    isoDate.setHours(isoDate.getHours() + 4);
    isoDate = isoDate.toISOString().slice(0, 19) + 'Z';

【讨论】:

    猜你喜欢
    • 2016-09-23
    • 2013-03-12
    • 2021-10-28
    • 1970-01-01
    • 2014-04-19
    • 2014-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多