#sai-rez_two-step-confirmation
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/1235965154219397160
๐ 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.
- sai-rez_best-practices, 2 hours ago, 15 messages
Hi ๐ a Payment Method will be created automatically when processing a Payment Intent or Setup Intent. It isn't something you need to explicitly do unless you plan to use details about the Payment Method to decide whether you want to progress with processing a payment. In those scenarios, you use the flow shown in this guide to get the Payment Method details, via a Confirmation Token, first:
https://docs.stripe.com/payments/build-a-two-step-confirmation
So I am trying to update our flow from card elements to payment elements, in our current flow we pass the payment method id to our backend to use in some logic. Is it possible to still create a payment method from payment elements?
Yes, as I mentioned, the above guide walks through that.
Thanks I did have a look but not sure it satisfies the use case I'm describing as if I'm understanding correctly it suggest we create a confirmation token instead of a payment method to pass to the backend, however atm our backend specifically needs a payment method as we retrieve it using the id from the frontend.
I have also been looking at the docs here which seems to suggest it's possible but not sure where elements.submit() comes into it
https://docs.stripe.com/js/payment_methods/create_payment_method_elements
That's correct, you would use a Confirmation Token instead, and would need to adapt your backend to be able to handle those and retrieve their payment_method_preview hash:
https://docs.stripe.com/api/confirmation_tokens/object#confirmation_token_object-payment_method_preview
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
sai-rez_two-step-confirmation
Right, so say we use the payment method to get card fingerprints or to attach to a customer, would the new flow be something like this?
- Load elements
- create confirmation token and send to backend
- In backend use payment method value of confirmation token object to retrieve payment method
- use payment method in backend logic
Almost, the first two parts are right.
In backend use payment method value of confirmation token object to retrieve payment method
use payment method in backend logic
These parts are off, as there won't be an actual Payment Method object to use. You will use the information contained withinpayment_method_previewin the Confirmation Token for your backend logic.
Ah right, so I can see there is a fingerprint value in the card preview, could payment_method_preview be used to attach a card to a customer?
No, you won't explicitly attach the Payment Method to your customer, that will be handled automatically by the intent you process.
Ok and to double check that happens when you use .confirmPayment() correct?