node.js在进行查询时显示未处理的PromisejectionWarning (节点:26431)未处理的PromisejectionWarning:错误:条带:未知参数([object])。你是想传递一个选项对象吗?看见https://github.com/stripe/stripe-node/wiki/Passing-Options. (根据API的要求发布`/charges`) 在getRequestOpts(/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\modules/stripe/lib/makeRequest.js:37:11) 在/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\u modules/stripe/lib/makeRequest.js:68:18 在新的承诺() 在makeRequest(/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\u modules/stripe/lib/makeRequest.js:66:10) 在Constructor.create(/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\u modules/stripe/lib/StripeMethod.js:31:7) 在/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/server.js:50:20 在处理和拒绝时(内部/process/task_queues.js:97:5) (节点:26431)未处理的PromisejectionWarning:未处理的承诺拒绝。此错误源于在没有catch块的异步函数中抛出,或者拒绝未使用.catch()处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用CLI标志“---unhandled rejections=strict”(请参阅https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (拒绝id:1) (节点:26431)[DEP0018]弃用警告:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将使用非零退出代码终止Node.js进程。 应用程序发布(“/付款)”,(请求、回复)=>{ const{product,token}=req.body; const{idempontencyKey}=product.idempontencyKey; 返回stripe.customers.create({ 电子邮件:token.email, 来源:token.id })。然后(客户=>{ stripe.charges.create({ 金额:产品价格*100, 货币:“美元”, 客户:customer.id, 收据\电子邮件:token.email, description:product.name, 装运:{ 名称:token.card.name, 地址:{ 国家:token.card.address\u国家 } } },{idempontencyKey}) }) .then(result=>res.status(200).json(result)) .catch(err=>console.log(err)) })
在这里,我尝试使用node.js中的stripe进行集成和支付(测试模式) 但是,在提出质疑时,我发现了以上错误 这个错误对我来说是完全站不住脚的node.js在进行查询时显示未处理的PromisejectionWarning (节点:26431)未处理的PromisejectionWarning:错误:条带:未知参数([object])。你是想传递一个选项对象吗?看见https://github.com/stripe/stripe-node/wiki/Passing-Options. (根据API的要求发布`/charges`) 在getRequestOpts(/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\modules/stripe/lib/makeRequest.js:37:11) 在/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\u modules/stripe/lib/makeRequest.js:68:18 在新的承诺() 在makeRequest(/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\u modules/stripe/lib/makeRequest.js:66:10) 在Constructor.create(/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/node\u modules/stripe/lib/StripeMethod.js:31:7) 在/home/fractaluser/Desktop/upwork/dylan/facebook\u marketing/marketing\u backend/server.js:50:20 在处理和拒绝时(内部/process/task_queues.js:97:5) (节点:26431)未处理的PromisejectionWarning:未处理的承诺拒绝。此错误源于在没有catch块的异步函数中抛出,或者拒绝未使用.catch()处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用CLI标志“---unhandled rejections=strict”(请参阅https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (拒绝id:1) (节点:26431)[DEP0018]弃用警告:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将使用非零退出代码终止Node.js进程。 应用程序发布(“/付款)”,(请求、回复)=>{ const{product,token}=req.body; const{idempontencyKey}=product.idempontencyKey; 返回stripe.customers.create({ 电子邮件:token.email, 来源:token.id })。然后(客户=>{ stripe.charges.create({ 金额:产品价格*100, 货币:“美元”, 客户:customer.id, 收据\电子邮件:token.email, description:product.name, 装运:{ 名称:token.card.name, 地址:{ 国家:token.card.address\u国家 } } },{idempontencyKey}) }) .then(result=>res.status(200).json(result)) .catch(err=>console.log(err)) }),node.js,stripe-payments,Node.js,Stripe Payments,在这里,我尝试使用node.js中的stripe进行集成和支付(测试模式) 但是,在提出质疑时,我发现了以上错误 这个错误对我来说是完全站不住脚的 请看一下我犯错误的地方我注意到这里的文档不正确,幂等键的键名实际上是幂等键而不是幂等键 传递给Charge create的第二个参数是以下参数 {幂等键:幂等键} (node:26431) UnhandledPromiseRejectionWarning: Error: Stripe: Unknown arguments ([object Objec
请看一下我犯错误的地方我注意到这里的文档不正确,幂等键的键名实际上是
幂等键
而不是幂等键
传递给Charge create的第二个参数是以下参数
{幂等键:幂等键}
(node:26431) UnhandledPromiseRejectionWarning: 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 `/charges`)
at getRequestOpts (/home/fractaluser/Desktop/upwork/dylan/facebook_marketing/marketing_backend/node_modules/stripe/lib/makeRequest.js:37:11)
at /home/fractaluser/Desktop/upwork/dylan/facebook_marketing/marketing_backend/node_modules/stripe/lib/makeRequest.js:68:18
at new Promise (<anonymous>)
at makeRequest (/home/fractaluser/Desktop/upwork/dylan/facebook_marketing/marketing_backend/node_modules/stripe/lib/makeRequest.js:66:10)
at Constructor.create (/home/fractaluser/Desktop/upwork/dylan/facebook_marketing/marketing_backend/node_modules/stripe/lib/StripeMethod.js:31:7)
at /home/fractaluser/Desktop/upwork/dylan/facebook_marketing/marketing_backend/server.js:50:20
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:26431) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:26431) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
app.post("/payment", (req, res) => {
const { product, token } = req.body;
const { idempontencyKey } =product.idempontencyKey;
return stripe.customers.create({
email: token.email,
source: token.id
}).then(customer => {
stripe.charges.create({
amount: product.price * 100,
currency: "usd",
customer: customer.id,
receipt_email: token.email,
description: product.name,
shipping: {
name: token.card.name,
address: {
country: token.card.address_country
}
}
}, {idempontencyKey})
})
.then(result => res.status(200).json(result))
.catch(err => console.log(err))
})