#tonybhai
1 messages · Page 1 of 1 (latest)
Hi, that response means you would need stripe.js or other SDKs (ie. iOS/Android) since it says use_stripe_sdk
How are you confirming client-side? If you use stripe.js already it should be able to handle all the authentication process
I am bit confused how to confirm from client side I have sent client secret from backend but how to use it on client side
Okie, so here is and end-to-end Doc https://stripe.com/docs/payments/accept-a-payment
This is PaymentElement, and you will use its client secret to confirm using the confirmPayment method. It will handle 3DS for you seamlessly
I already using this
const { error , paymentIntent } = await stripe.confirmPayment({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
// return_url: ${window.location.origin}/my-tasks,
receipt_email: email,
},
redirect:"if_required"
});
<PaymentElement id="payment-element" options={paymentElementOptions} />
But in this it is showing full card element to enter card details but I have already given payment method in Creatent and now have to authorize BS 3D secure
I see, that means you are mixing things up. If you already have PaymentElement on clientside, don't pass confirm=true server-side.
Otherwise, is that because you already have a Customer Id and a PaymentMethod Id?
How did you collect that PaymentMethod Id earlier?
I had the user's cards saved which I did when he made the first time payment I gave the option to the user that with which card he wants to make the payment Send the payment method of the card the user selected to the server side given and create new payment intent on server side
\Stripe\PaymentIntent::create([
'amount' => 1099,
'currency' => 'inr',
'customer' => '{{CUSTOMER_ID}}',
'payment_method' => '{{PAYMENT_METHOD_ID}}',
]);
and after that i got the status of require confirmation then i called
$stripe->paymentIntents->confirm(
'pi_1GszZg2eZvKYlo2C2X6lMOre',
['payment_method' => 'pm_card_visa']
);
and i got this status "status" => "requires_action"
and this
next_action" => array:2 [
"type" => "use_stripe_sdk"
"use_stripe_sdk" => array:3 [
"source" => "src_1NI2HDSGMxcvQmIS18zcbv9w"
"stripe_js" => "https://hooks.stripe.com/redirect/authenticate/src_1NI2HDSGMxcvQmIS18zcbv9w?client_secret=src_client_secret_xWCy7XY6PegFZZnHlpeBJPtF&source_redirect_slug=test_YWNjdF8xTWYxUUtTR014Y3ZRbUlTLF9PNEFjdUk5MTkwdVhPZEYyV3U5dEVJTmhIOWlyZzlo0100aYgrLJbt"
"type" => "three_d_secure_redirect"
]
]
Now I want user to confirm 3D secure from client side and I get this status "require_capture"
All I want to do is that if the user has already saved his cards then I should give him the option from which card he wants to pay.
Ah okie
so what to do ?
There are 2 ways:
- on the state, go back to your client and use the
handleCardActionmethod https://stripe.com/docs/js/payment_intents/handle_card_action - when you create PaymentIntent server-side, pass in a
return_urlto force its type toredirect_to_urlinstead ofuse_stripe_sdk, then you can simply perform a HTML redirection using the URL like https://stripe.com/docs/payments/3d-secure#manual-redirect
first step give this error The PaymentIntent supplied does not require manual server-side confirmation. Please use confirmCardPayment instead to complete the payment.
Hmm can you share the errored request id from https://dashboard.stripe.com/test/logs ? req_xxx
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
req_gMy6gA2GcMnT9Y
my serverside code:-
first we create paymentIntent ->>
$data = $stripe->paymentIntents->create([
// 'amount' => 100,
// 'currency' => 'AUD',
// 'customer' => 'cus_O3rsqfdfdsfsdcd1zr1QPL',
// 'payment_method' => 'pm_1NHk9WSdfdsfdsfdsGMxcvQmISZR06qF6n',
// ]);
2:--- confirm
$data = $stripe->paymentIntents->confirm(
'pi_3NI4qcSGMxcvQmISdsfds0iZbdwwo',
['payment_method' => 'pm_1NHk9dadasdsaWSGMxcvQmISZR06qF6n']
);
I only see succeed requests. Did you get the error on client-side? Any screenshot?
No see error in my browser then i call handlecardAction function
Could you screenshot?
Not sure but if you can just try the 2nd approach of using an URL, it would be faster
browser Errror
can i add this 'confirm' => true,
// // 'error_on_requires_action' => true,
in paymentIntentCreate in serversise
Hey! Taking over for my colleague. Let me catch up.
Can you please share a complete flow of your payment please? and share a PaymentIntent Id ?
pi_3NI5itSGMxcvQmIS0VwyjpJp
This is my flow :--
can u tell why this error occured
Ok so after you did the confirmation of the payment method in server side (req_wWNjdlwwrQjNFg) you got a 3ds action.
in frontend you were using handle_card_action and you got that error in the screenshot right ?
try passing confirm: "true" when creating the PaymentIntent
already try but give same error
Ah wait you account is in India.
Did you try the manual redirect?
https://stripe.com/docs/payments/3d-secure#manual-redirect
no
I got this
next_action" => array:2 [
"type" => "use_stripe_sdk"
"use_stripe_sdk" => array:3 [
"source" => "src_1NI2HDSGMxcvQmIS18zcbv9w"
"stripe_js" => "https://hooks.stripe.com/redirect/authenticate/src_1NI2HDSGMxcvQmIS18zcbv9w?client_secret=src_client_secret_xWCy7XY6PegFZZnHlpeBJPtF&source_redirect_slug=test_YWNjdF8xTWYxUUtTR014Y3ZRbUlTLF9PNEFjdUk5MTkwdVhPZEYyV3U5dEVJTmhIOWlyZzlo0100aYgrLJbt"
"type" => "three_d_secure_redirect"
]
]
but then i click on this url it is not working
Now url is working and give this screeen
That means the PaymentIntent is now authenticated.
but it is not show card 3d secure window
This is because your account in india, that 3ds action is just a frontend redirection.
can you tell me how to check customer default payment method and change default payment mehtod