From 5b7a0aadd2c4535c07307a1dd4b7939962daec15 Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Sat, 7 May 2022 15:31:54 -0700 Subject: [PATCH] doc: add database to payment component --- src/Checkout/Payment/Payment.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Checkout/Payment/Payment.js b/src/Checkout/Payment/Payment.js index 87b1913..d5e6f1d 100644 --- a/src/Checkout/Payment/Payment.js +++ b/src/Checkout/Payment/Payment.js @@ -5,7 +5,7 @@ import CheckoutProduct from "../CheckoutProduct"; import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js"; import CurrencyFormat from "react-currency-format"; import { getBasketTotal } from "../../redux/reducer"; - +import { db } from "../../Auth/firebaseInit"; import axios from "../../Auth/axios"; import "./Payment.css"; @@ -43,6 +43,15 @@ function Payment() { }, }) .then(({ paymentIntent }) => { + db.collection("users") + .doc(user?.id) + .collection("orders") + .doc(paymentIntent.id) + .set({ + basket: basket, + amount: paymentIntent.amount, + created: paymentIntent.created, + }); setSucceed(true); setError(null); setProcessing(false);