Javascript React and Stripe—从React接收数据并发送到Stripe时发生节点抛出错误

Javascript React and Stripe—从React接收数据并发送到Stripe时发生节点抛出错误,javascript,node.js,reactjs,stripe-payments,Javascript,Node.js,Reactjs,Stripe Payments,我正在学习如何设置react以向节点发送请求,与stripe的api通信以进行支付。我遵循了最近的教程,在节点服务器上遇到了一个错误: (node:81464) UnhandledPromiseRejectionWarning: Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/w

我正在学习如何设置react以向节点发送请求,与stripe的api通信以进行支付。我遵循了最近的教程,在节点服务器上遇到了一个错误:

(node:81464) 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`)
我去了选项页面,但没有看到太多内容:

https://github.com/stripe/stripe-node/wiki/Passing-Options
我不确定代码中的错误在哪里:

App.js

import React, {useState} from 'react';
import logo from './logo.svg';
import './App.css';
import StripeCheckout from "react-stripe-checkout";

function App() {

  const [product, setProduct] = useState({
    name: "React from FB",
    price: 10,
    productBy: "facebook"
  });

  const makePayment = token => {
    const body = {
      token,
      product
    }
    const headers = {
      "Content-Type": "application/json"
    }

    return fetch(`http://localhost:8282/payment`,{
      method: "POST",
      headers,
      body: JSON.stringify(body)
    }).then(response => {
      console.log("RESPONSE ", response)
      const { status } = response;
      console.log("STATUS ",status)
    })
    .catch(error => console.log(error))


  }


  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
       
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          
        </a>

        <StripeCheckout
        token={makePayment}
        amount={product.price * 100}
        stripeKey="MY KEY GOES HERE"
      />




      </header>
    </div>
  );
}

export default App;
const cors = require("cors")
const express = require("express")

const stripe = require("stripe")("MY KEY.....")
const { v4: uuidv4 } = require('uuid');

const app = express()
const port = 8282;


//middleware
app.use(express.json())
app.use(cors())

//routes
app.get("/", (req, res) => {
    res.send("IT'S ALIVEE!!!")
})

app.post("/payment", (req, res) => {

    const { product, token } = req.body;
    console.log("PRODUCT", product);
    console.log("PRODUCT", product.price);
    const idempontencyKey = uuidv4()

    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: `purchase of ${product.name}`
        }, {idempontencyKey})
    })
    .then(result =>res.status(200).json(result))
    .catch(err=> console.log(err) )
})




//listen
app.listen(port, ()=> console.log(`LISTENING AT PORT ${port}`))

您看到该错误是因为条带API希望您在
idemponencykey
属性下传递幂等键,而在代码中则作为
idemponencykey
传递:

这看起来是一个简单的打字错误,其余的集成看起来不错