#Andrew Samir
1 messages · Page 1 of 1 (latest)
I have a page where users can pay with their existing payment methods i listed their payment methods and when i enter the page .... i create a payment intent from the backend .... and i need when the user click pay i confirm this payment from my backend .. so how can i handle this
That's correct! With which part of the flow you described you need help?
The last part when the user click pay the current behavior now is i confirm from my frontend with confirmCardPayment method ... but i dont need that because i pass the payment_method_id in network so its not secure .. and i need to confirm this payment intent in backend
When the customer selects the PaymentMethod:
- Your backend creates a new PaymentIntent with
confirm:trueto try to make the payment right away - If the status of the PaymentIntent is
succeeeded, then you are done. - If the status of the PaymentIntent is
require_action, then you need to callconfirmCardPaymenton the frontend with just the client secret: https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-attached
So you mean the scenario will be
When user enter payment page he create payment intent with confirm: true or user will create payment_intent when he click pay
You have a few options depending on the user experience you want. But I woudl recommend this:
- When the user select the PaymemtMethod, create the PaymentIntent (without
confirm:true) - Then when the user click on pay, call https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-attached with the client secret
and how can i select payment method in this case
- You list all payment method of the customer using https://stripe.com/docs/api/payment_methods/list
- Then once the user selected one, you pass the pm_xxx ID to your backend
- And the backend create a new PaymentIntent with that payment method https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method
So to wrap up what i understood:
- first user will see all his listed payment methods and he select one
- when the user click pay i make a payment intent and pass the pm_xxx id and create payment intent with this payment method id
- then the response of the client secret will be passed in the ConfirmCardPayment function in frontend
Is that flow correct ?
Exactly!
But how can i handle the authentication in that case ?
When you call ConfirmCardPayment on the frontend, the card authentification will be automatically handeled for you.
Oh okay nice
May i ask one last question
How the authentication process happen
I mean is the page i redirected to is the bank page ? and when the authentication finish ... which page will i return to ?
There should be a popup on the page that appear where the user can go through the 3DS flow.
And I think you can set the return URL like in this example: https://stripe.com/docs/js/payment_intents/confirm_payment
But I would recommend to do some tests to see exactly how the flow works. And you can use our test cards here: https://stripe.com/docs/testing