admin管理员组

文章数量:1292749

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
                        }
                    }
                },
            });

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
                        }
                    }
                },
            });
Share Improve this question edited Feb 13 at 6:21 Yuvaraj M 4,6163 gold badges10 silver badges19 bronze badges asked Feb 13 at 6:12 vivek bhimanivivek bhimani 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

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/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/payments/quickstart

(make sure to choose the appropriate framework and languages at the top, in this case Javascript, HTML, Node.js)

本文标签: nodejsHow to confirm payment intent of connected account in stripe from our platformStack Overflow