【问题标题】:Stripe stopped working after migrating to heroku迁移到 Heroku 后,Stripe 停止工作
【发布时间】:2016-08-15 01:13:24
【问题描述】:

我刚刚迁移到 heroku,当我尝试向客户收费时,我收到了这个错误。

Unhandled rejection Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.

下面是我的云代码

Parse.Cloud.define("charge", function(request, response){
Stripe.charges.create({
amount: 100*100,
currency: "usd",
customer: request.params.customerId,
card: request.params.cardId
},{
  success: function(httpResponse) {
    response.success("success");
  },
  error: function(httpResponse) {
    response.error(httpResponse)
  }
 });
});

【问题讨论】:

  • 你的所有库都安装了吗。
  • 是的,我可以执行其他条带功能,只是充电导致了这个错误。
  • 奇数。您确定您的堆栈跟踪表明此代码是问题所在吗?另外,这是您的确切代码,还是您在粘贴到 SO 之前修改了任何内容?
  • 2016-08-14T05:22:15.382882+00:00 app[web.1]: Unhandled rejection Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to POST function (outputs) { 2016-08-14T05:22:15.382895+00:00 app[web.1]: return cleanString.replace(/\{([\s\S]+?)\}/g, function($0, $1) { 2016-08-14T05:22:15.382896+00:00 app[web.1]: return encodeURIComponent(outputs[$1] || ''); 2016-08-14T05:22:15.382898+00:00 app[web.1]: }); 2016-08-14T05:22:15.382898+00:00 app[web.1]: })
  • 没有修改任何东西

标签: node.js stripe-payments


【解决方案1】:

问题是您不再使用 Parse 的云代码,因此您无法再访问 Parse 的 Stripe 库。现在你使用的是真正的 Stripe 库,它不接受这样的参数。

Stripe 库使用标准节点回调,例如:

Stripe.charges.create({
  amount: 100*100,
  currency: "usd",
  customer: request.params.customerId,
  card: request.params.cardId
}, function(error, charge) {
  // do something
});

【讨论】:

    猜你喜欢
    • 2019-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多