node.js - 条纹:未知参数([object Object])。在已连接帐户上创建新计划时出错
问题描述
我正在使用带有 typescript 节点应用程序的条带 v7.6.0。我正在尝试在连接的帐户上创建一个新计划(用于订阅)。这是我的片段:
const stripeAccount = "acct_2Gk346Btfer3fzH9";
plan = await this.stripe.plans.create({
amount,
currency,
interval,
product: {
name: productName,
},
}, { stripeAccount });
可以将用于 Stripe Connect 的每个请求的 Stripe-Account 标头添加到任何方法中:
// List the balance transactions for a connected account: stripe.balanceTransactions.list( { limit: 10, }, { stripeAccount: 'acct_foo', } );
所有方法都可以接受包含以下一项或多项的可选选项对象:
...
stripe.charges.refund(chargeId, { amount: 500, }, { stripeAccount: connectedAccountId, });
根据上面的链接,我认为我的代码应该可以正常工作。但我收到一个错误:
(节点:9737)UnhandledPromiseRejectionWarning:错误:条纹:未知参数([object Object])。你的意思是传递一个选项对象吗?请参阅https://github.com/stripe/stripe-node/wiki/Passing-Options。(对 POST 的 API 请求
/plans
)
我该如何解决这个错误?
解决方案
这是巨大的。Snake case 而不是 camelCase。
工作示例:
plan = await this.stripe.plans.create({
amount,
currency,
interval,
product: {
name: productName,
},
}, { stripe_account: stripeAccount });