#salim-bt_docs
1 messages · Page 1 of 1 (latest)
👋 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.
- salim-bt_docs, 1 day ago, 22 messages
- salim-bt_docs, 5 days ago, 86 messages
- salim-bt_docs, 5 days ago, 14 messages
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.
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
this
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.
sec
but, the payment intent is created on the backend, so how will it automatically know which card to attach? 🤔
Because you confirm that PaymentIntent's client secret on the frontend
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.
Did you read through the docs that I linked above?
That is the flow you need to use here
Our approach like that:
- insert stripe script, initializing stripe instance using publish key
- render express checkout
- creating payment method, getting pm id to pass it to backend and attach payment card
- creating sub
there are no other requests to stripe at frontend
need to be changed or what?
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.
we can't pass client secret to the client-side
Why?
Yes that is what client secrets are designed for
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
Gotcha, the other option is to use a Confirmation Token here like shown in https://docs.stripe.com/elements/express-checkout-element/accept-a-payment#create-ct
But really what I described above is the correct flow you should use and will be easier
thank you!
Is there a way to export this chat?
No there isn't but you can use the URL to refer back to it
Thanks a lot)