I am still a beginner in Firebase and I am working on an application in ReactJs where users have to buy some products using Stripe Payment. I have followed the flow of how stripe implementation works;
I have created a form in reactJs to accept billing information and I have used the CardElement from @stripe/react-stripe-js package to securely initialize a payment in ReactJs.
import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js" const stripeConst = useStripe()............................ const paymentIntent = await stripeValue.paymentIntents.create({ amount, currency: "usd" });
I need to use the initialization to to make a request which will return a client_Secret which I need to confirm the payment. I do not know whether there is a method in Firebase that can allow me integrate this process directly on my reactJs application without using another Node.js api to generate this secret client key. I have my stripe Private key with me and I know I need to use it at this level as well.
//I haven't seen any resource that can assist me in this task but I know it has to return a client Secret
I have used the confimCardPayment to process a payment.
const { error } = await stripeConst.confirmCardPayment(clientSecret, { payment_method: paymentMethod.id });
The only way to do this securely is to process the payment on the server side, and wait for Stripe to confirm that you've been paid. There are older APIs that allow you to complete a payment from the client, but they're less secure.
The "initialization" doesn't return the clientSecret
, the paymentIntent
call does. You don't need to generate the secret, Stripe does this for you.
Exactly how to do this is up to you, but here's an example.
On the server:
const {client_secret} = await stripe.paymentIntents.create(intentParams)
On the client:
confirmPayment
call.On the server:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.