#salim-bt_docs

1 messages · Page 1 of 1 (latest)

kindred lavaBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1288859604801032204

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

leaden stump
#

Hello

#

How can I help?

merry bridge
#

Hello!

I hope you're doing well.

I wanted to highlight two issues we're facing with the express checkout process:

Retrieving Selected Credit Card Data: So far, I haven’t found a way to access the selected credit card information directly from the express checkout. I need this data to verify if the card is already attached to the user.

If the card is attached, the backend can simply set it as the default.
If it’s not attached, I need to pass the card data from express checkout to the backend to create and attach the card.
Since I couldn’t retrieve the card data from express checkout, I’m currently creating the payment method on the frontend using stripe.createPaymentMethod(). After obtaining the payment method ID, I pass it to the backend to attach the card.

Stripe Payment Method Creation Issue: Unfortunately, I encountered a second issue: stripe.createPaymentMethod() does not work unless the paymentMethodCreation: 'manual' setting is applied. However, when this setting is enabled, the Amazon Pay button fails to render.
I wanted to bring these issues to your attention in case there are any suggestions or solutions to move forward.

Looking forward to your thoughts.

leaden stump
#

Let's back up

#

What are you trying to do?

#

Are you trying to take a payment and set up the payment method for future use using Express Checkout Element?

#

Or just collect the payment method and set it up for future use

leaden stump
#

Okay then you should not be using stripe.createPaymentMethod() at all. You should follow our docs at https://docs.stripe.com/elements/express-checkout-element/accept-a-payment and in step 6 (https://docs.stripe.com/elements/express-checkout-element/accept-a-payment#create-pi) you pass setup_future_usage (https://docs.stripe.com/api/payment_intents/create#create_payment_intent-setup_future_usage) which will automatically attach the PaymentMethod to your Customer when the PaymentIntent moves to succeeded.

#

In your backend you want to set up a Webhook handler and listen for payment_intent.succeeded to know when this occurs.

merry bridge
#

sec

#

but, the payment intent is created on the backend, so how will it automatically know which card to attach? 🤔

leaden stump
#

Because you confirm that PaymentIntent's client secret on the frontend

merry bridge
#

On the frontend, we only use the STRIPE_PUBLISHABLE_KEY to initialize the Stripe instance; we do not use the client secret or any other sensitive information in the frontend.

leaden stump
#

Did you read through the docs that I linked above?

#

That is the flow you need to use here

merry bridge
#

Our approach like that:

  1. insert stripe script, initializing stripe instance using publish key
  2. render express checkout
  3. creating payment method, getting pm id to pass it to backend and attach payment card
  4. creating sub
    there are no other requests to stripe at frontend

#

need to be changed or what?

leaden stump
#

Got it, so instead you want to create the Sub in step 3 using payment_behavior: 'default_incomplete' and expand the latest_invoice.payment_intent when you do that. That will provide you with the client secret that you need to pass back to your frontend for step 4 where you then call confirmPayment() as shown in the docs.

merry bridge
#

we can't pass client secret to the client-side

leaden stump
#

Why?

merry bridge
#

not secure no?

#

is it surely save use client secret on frontend?

leaden stump
#

Yes that is what client secrets are designed for

kindred lavaBOT
brazen palm
#

hello, got it, i need discuss it with backend developer, because he not agree to use a client secret at frontend, that's why at frontend we have minimum logic and requests to stripe

leaden stump
#

But really what I described above is the correct flow you should use and will be easier

merry bridge
#

thank you!
Is there a way to export this chat?

leaden stump
#

No there isn't but you can use the URL to refer back to it

merry bridge
#

Thanks a lot)