Reputation: 1
I have create payment intent for connected stripe account to our platform from backend and send client secret to frontend.Here problem is when i am trying to confirm that payment with client secret to stripe it is not working but if i pass stripe account id of that connected user it is working but it is not secure because here we have to add stripe account id of connected user in front end so that is any other way or i am making some mistake in collecting payments from stripe for connected user.
I am finding solution for collecting payment for our platform users who has been connected their stripe account to our platform.
Here is my frontend code where i have to pass stripe account id to confirm payment of our connected account user
const stripe = Stripe(stripePublishKey,{
stripeAccount: connectedUserStripeAccountId, //look like acct_****
});
Here is my frontend code for confirm payment where i pass client secret which is fetch from payment intent created from backend for connected user
const { paymentIntent, error } = await stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
billing_details: {
name: document.getElementById("name").value,
address: {
country: document.getElementById("country").value
}
}
},
});
Upvotes: 0
Views: 40
Reputation: 400
For something like Stripe Checkout, I use the endpoints and wait for the events.
For example:
app.get('/order/success', async (req, res) => {
console.log('order success');
// fetch session
const session = await stripePayment.checkout.sessions.retrieve(req.query.session_id)
.catch((err) => {
console.error(err);
})
;
// fetch customer deets
const customer = await stripePayment.customers.retrieve(session.customer)
.catch((err) => {
console.error(err);
})
;
This will allow you to get the customer information without it being in the clear.
Here is a link to Stripe's documentation that covers this example as a way to understand the handshake: https://docs.stripe.com/api/checkout/sessions/retrieve?lang=node
Edit: I'm adding another reference for you to see the front and back end examples of how Stripe reference docs explain it: https://docs.stripe.com/payments/quickstart
(make sure to choose the appropriate framework and languages at the top, in this case Javascript, HTML, Node.js)
Upvotes: 0