#huncsuga_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/1417770767101329541
📝 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.
- huncsuga_best-practices, 1 day ago, 16 messages
- huncsuga_code, 1 day ago, 10 messages
Hello! Sorry for the wait, i dont see your code snippet, is it possible to send it?
Just curious, why did you decide to use confirmation tokens since you are collecting the payment method details on your own?
No worries about the delay - Yes, and here is my code snippet:
$client->paymentIntents->create([
'amount' => $amount,
'currency' => $currency,
'customer' => $customer->id,
'confirm' => true,
'confirmation_token' => $tokenId,
'payment_method_types' => ['card'],
'metadata' => [
'order_id' => (string) $orderId,
'cart_id' => (string) $cart->id,
],
'return_url' => $successUrl,
]);
Hey! Taking over for my colleague. Let me catch up.
Sorry I'm not sure I understand what is the issue you are facing actually ?
I’m working on a Stripe integration using the PaymentElement. In the docs (https://docs.stripe.com/payments/build-a-two-step-confirmation#create-ct), step 7 shows confirming the PaymentIntent on the frontend. When I checked the PaymentIntents API, I noticed there’s also an option to confirm the PaymentIntent directly on the backend using the confirmation token, without sending it back to the frontend again.
Is this considered a good/recommended approach?
Could you clarify what you mean by that? Wouldn’t it be enough if I collect the card details through the PaymentElement, send them to Stripe to get the confirmation token, and then pass that token to my backend where I create and confirm the PaymentIntent with it? Or would I still need to handle something on the frontend for 3DS/next actions?
No, creating confirmaion token doesn't authenticate the card.
Confirming the Payment in the frontend will handle 3DS, but when confirming the payment in the backend, you may need another call from your frontend to handle next actions (3DS)
If I’m already passing a return_url when confirming the PaymentIntent on the backend, isn’t that URL supposed to be where Stripe (or the bank) redirects the customer after completing the 3DS check? In that case, why would I still need to handle this on the frontend separately?
The return_url is used when the customer completes the 3DS on the frontend
But in order to trigger the flow, you need to call the Stripe JS and handles the next action
You can do a quick test using the 3DS cards and see the flow
After confirming the Payment in your backend, if the status of the returned payment intent is "requires_action", you need to make this JS call from your frontend in order to complete the 3DS action
Got it, thanks for clarifying. So if instead of confirming the PaymentIntent directly on the backend, I just return the PaymentIntent client_secret and confirm it on the frontend, then I don’t need to manually handle 3DS or next actions myself — I can just call stripe.confirmPayment(...) and then check the result for any errors, right?
Yeah, either that or you use the flow in the first guide you've shared
Thank you for the help