【问题标题】:Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object?错误:条纹:未知参数([object Object])。你的意思是传递一个选项对象吗?
【发布时间】:2022-01-18 23:18:50
【问题描述】:

我的后端出现此错误,任何人都可以看看这个并帮助我。谢谢

router.post("/event/payment", auth, async (req, res) => {
    
    const { event, token } = req.body;
    const idempontencyKey = uuidv4()

    console.log(token.id);
    console.log(idempontencyKey);

    return stripe.customers.create({
        email: token.email,
        source: token.id
    })
        .then(customer => {
            stripe.charges.create(
                {
                    amount: event.priceOfPass * 100,
                    currency: 'usd',
                    customer: customer.id,
                    receipt_email: token.email,
                    description: `purchase of ${event.eventName} passes`,
                    shipping: {
                        name: token.card.name,

                    }
                }, { idempontencyKey })
        })
        .then(result => res.status(200).json(result))
        .catch(err => res.status(400).json(err))
})

【问题讨论】:

    标签: node.js reactjs stripe-payments


    【解决方案1】:

    这是来自您的charges.create 电话。错误是说选项对象(调用中的第二个顶级参数)需要一个键值格式。在这里,您可以将幂等键作为值传递给名为idempotencyKey的键

    stripe.charges.create(
    {
      amount: event.priceOfPass * 100,
      currency: 'usd',
      customer: customer.id,
      receipt_email: token.email,
      description: `purchase of ${event.eventName} passes`,
      shipping: {
        name: token.card.name,
      }
    }, { idempotencyKey: idempotencyKey })
    

    【讨论】:

    • 成功了!谢谢哥们救了我!
    猜你喜欢
    • 2020-01-16
    • 1970-01-01
    • 1970-01-01
    • 2022-12-14
    • 2012-09-21
    • 1970-01-01
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多