#rjt_best-practices
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/1217190629453336686
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
Sounds like you're currently creating PaymentIntents prior to rendering the Element.
I believe you'd benefit from following flow instead:
https://docs.stripe.com/payments/accept-a-payment-deferred
It allows you to collect PaymentMethod details before creating an Intent. This way you can look at the tokenized PaymentMethod prior to creating the intent and set the fees accordingly
Interesting, I will take a look at this
๐
I will need to check this to make sure it supports all the features of our current checkout page
I can see that this uses the same .confirmPayment() method that our current implementation is using. If the client is calling this method, what would prevent the client from changing the used payment method before confirming?
Not sure what you mean by that. Can you elaborate?
I am imagining a situation like
- Client enters a payment method through the payment element
- Client submits the payment form to the server
- Server creates
PaymentIntent - Server sends
client_secretto client - Client, now holding the
client_secret, selects a different payment method in the element - Client calls
stripe.confirmPayment()
sorry, I should've been more clearer with the exact link I wanted you to refer to ๐
The flow I'm referring to is this optional step in the URL I shared above: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment#create-pm
Which links to this: https://docs.stripe.com/payments/build-a-two-step-confirmation
In the two step confirmation flow, you attach the PaymentMethod to the PaymentIntent
Looking at the two-step confirmation flow, the client is still calling confirmPayment(). Does setting payment_method on the server prevent the client from modifying it?
I have not been able to find this confirmed in docs but my understanding is that possessing the client_secret gives the client the ability to choose the payment method (from the list of enabled types)
Actually, Elements give the customer ability to choose payment method type. Client-secret is just used to link the collected payment method to a payment.
Once you've called confirmPayment, the elements won't let the customer attach any other payment method to the same PaymentIntent afaik.
I'd recommend giving the flow a go in test mode. That should simplify things a bit.
Once you've called
confirmPayment, the elements won't let the customer attach any other payment method to the same PaymentIntent afaik.
Maybe I'm misunderstanding the flow here, but isn't there a period after thePaymentIntentis created (therefore after the application fee is set) but before the client callsconfirmPayment?
I'd recommend giving the flow a go in test mode
Will do
I think the piece missing in the docs (at least I couldn't find it) is that you could use stripe.createPaymentMethod(...) function to create a payment method prior to confirming the PaymentIntent
https://docs.stripe.com/js/payment_methods/create_payment_method_elements
And then pass it to confirmPayment via confirmParams
https://docs.stripe.com/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-payment_method
Which is the flow I was thinking about but it looks like we've updated our docs to not recommend that flow for some reason.