【问题标题】:Stripe: Unknown arguments ([object Object]). Error on creating a new plan on a connected account条纹:未知参数([object Object])。在已连接帐户上创建新计划时出错
【发布时间】:2020-06-12 19:36:39
【问题描述】:

我正在使用带有 typescript 节点应用程序的条带 v7.6.0。我正在尝试在连接的帐户上创建一个新计划(用于订阅)。这是我的 sn-p:

  const stripeAccount = "acct_2Gk346Btfer3fzH9";
  plan = await this.stripe.plans.create({
    amount,
    currency,
    interval,
    product: {
      name: productName,
    },
  }, { stripeAccount });

Github says

与 Stripe Connect 一起使用的每个请求的 Stripe-Account 标头可以是 添加到任何方法中:

// List the balance transactions for a connected account:
stripe.balanceTransactions.list(
  {
    limit: 10,
  },
  {
    stripeAccount: 'acct_foo',
  }
);

Stripe-node wiki

所有方法都可以接受一个可选的选项对象,其中包含一个或 更多以下内容:

...

stripe.charges.refund(chargeId, {
  amount: 500,
}, {
   stripeAccount: connectedAccountId,
});

根据上面的链接,我认为我的代码应该可以正常工作。但我得到一个错误:

(节点:9737)UnhandledPromiseRejectionWarning:错误:条纹:未知 参数([对象对象])。你的意思是传递一个选项对象吗? 见https://github.com/stripe/stripe-node/wiki/Passing-Options。 (在 API 请求 POST /plans)

我该如何解决这个错误?

【问题讨论】:

  • 您能分享一下金额、货币、间隔和产品名称的值吗?如果这些都是字符串,并且假设 this.stripe 是 Stripe 对象的一个​​实例,那么这段代码应该可以工作。我有一种感觉,其中一个是对象而不是字符串。
  • @w1zeman1p 我正在使用打字稿,所以在此过程中进行了大量类型检查,并使用枚举和 getter 提取这些值。我尝试直接对所有值进行硬编码。还是非常感谢你的建议。我花了几个小时在这上面,我刚刚找到了答案。有兴趣可以看我的帖子。

标签: node.js typescript stripe-payments


【解决方案1】:

这是巨大的。 Snake case 而不是 camelCase

工作示例:

  plan = await this.stripe.plans.create({
    amount,
    currency,
    interval,
    product: {
      name: productName,
    },
  }, { stripe_account: stripeAccount });

【讨论】:

  • 这节省了我几个小时!
  • Stripe: 'api_key' 已弃用;请改用“apiKey”。
猜你喜欢
  • 2020-01-16
  • 2018-12-12
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-29
  • 2021-07-20
  • 1970-01-01
相关资源
最近更新 更多