doc: add database to payment component

This commit is contained in:
Leon Xu committed 2022-05-07 15:31:54 -07:00
1 parent aabbe3a95c
commit 5b7a0aadd2
1 file changed
+10 -1
+10 -1
View File
@@ -5,7 +5,7 @@ import CheckoutProduct from "../CheckoutProduct";
import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js"; import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
import CurrencyFormat from "react-currency-format"; import CurrencyFormat from "react-currency-format";
import { getBasketTotal } from "../../redux/reducer"; import { getBasketTotal } from "../../redux/reducer";
import { db } from "../../Auth/firebaseInit";
import axios from "../../Auth/axios"; import axios from "../../Auth/axios";
import "./Payment.css"; import "./Payment.css";
@@ -43,6 +43,15 @@ function Payment() {
}, },
}) })
.then(({ paymentIntent }) => { .then(({ paymentIntent }) => {
db.collection("users")
.doc(user?.id)
.collection("orders")
.doc(paymentIntent.id)
.set({
basket: basket,
amount: paymentIntent.amount,
created: paymentIntent.created,
});
setSucceed(true); setSucceed(true);
setError(null); setError(null);
setProcessing(false); setProcessing(false);