#perf-react-paymentelement
1 messages · Page 1 of 1 (latest)
Hi 👋
If you are using Stripe.js to confirm payments on the client side it will handle 3DS for you but we do have more details about it here:
https://stripe.com/docs/payments/3d-secure
ah ok, is "requires_source_action" status not the same thing?
It is except for the outdated Sources API
Does the stripe.js package use the outdated api?
It can be used to confirm a Source (we're not going to break old integrations). But we recommend moving to the Payment Methods API for both handling more payment methods as well as more robust error handling
is using this method not recommended?
* Use `stripe.confirmCardPayment` when the customer submits your payment form.
* When called, it will confirm the [PaymentIntent](https://stripe.com/docs/api/payment_intents) with `data` you provide and carry out 3DS or other next actions if they are required.
*
* If you are using [Dynamic 3D Secure](https://stripe.com/docs/payments/3d-secure#three-ds-radar), `stripe.confirmCardPayment` will trigger your Radar rules to execute and may open a dialog for your customer to authenticate their payment.
*
* When you confirm a `PaymentIntent`, it needs to have an attached [PaymentMethod](https://stripe.com/docs/api/payment_methods).
* In addition to confirming the `PaymentIntent`, this method can automatically create and attach a new `PaymentMethod` for you.
* It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data.
*
* @docs https://stripe.com/docs/js/payment_intents/confirm_card_payment
*/
confirmCardPayment(
clientSecret: string,
data?: paymentIntents.ConfirmCardPaymentData,
options?: paymentIntents.ConfirmCardPaymentOptions
): Promise<PaymentIntentResult>;
No, that is the canonical approach to confirming payments using the Card Element
so the card elements can not use that updated api ?
i am confused, sorry. I am not wording my question correctly. You stated above " But we recommend moving to the Payment Methods API for both handling more payment methods as well as more robust error handling".
Does that mean not using stripe elements at all?
No no no. It just means not creating Payment Methods using the Sources API
You can still use the Card Element or the Payment Element just fine
oh ok, so the source API is used within the stripe.js lib by default right?
because we are using confirmSetup currently in the stripe.js lib.
/**
* Use `stripe.confirmSetup` to confirm a SetupIntent using data collected by the [Payment Element](https://stripe.com/docs/js/element/payment_element).
* When called, `stripe.confirmSetup` will attempt to complete any [required actions](https://stripe.com/docs/payments/intents), such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
* Your user will be redirected to the return_url you pass once the confirmation is complete.
*
* By default, stripe.`confirmSetup` will always redirect to your return_url after a successful confirmation.
* If you set `redirect: "if_required"`, then `stripe.confirmSetup` will only redirect if your user chooses a redirect-based payment method.
* Setting `if_required` requires that you handle successful confirmations for redirect-based and non-redirect based payment methods separately.
*
* @docs https://stripe.com/docs/js/setup_intents/confirm_setup
*/
confirmSetup(options: {
elements: StripeElements;
confirmParams?: Partial<paymentIntents.ConfirmPaymentData>;
redirect: 'if_required';
}): Promise<SetupIntentResult>;
Nope
Okay lets back up
- What are you trying to do
- What APIs are you using the collect payment ?
I am using the following two packages
"@stripe/react-stripe-js": "^2.1.0",
"@stripe/stripe-js": "^1.52.1",
and confirming a setup-intent with the following
const elements = useElements();
...
const result = await stripe.confirmSetup({
elements,
confirmParams: {
return_url: `${HOST}/account/wallet`,
},
redirect: 'if_required',
});
where useElements and stripe is from
import { PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js';
Okay so you are using Setup Intents. And confirmSetup will use the Payment Method. So this should handle 3DS for you just fine.
yea adding a card is fine, however when using the payment-intent confirmation it does not. So let me continue.
once we know how much to charge we do the following
import { useStripe } from '@stripe/react-stripe-js';
...
const stripe = useStripe()
...
stripe
?.confirmCardPayment(
paymentIntentClientSecret,
{ payment_method: paymentMethodID },
{ handleActions: false },
).then((resp) => { ... })
which returns a payload looking like
{
...
next_action: {
type: "use_stripe_sdk",
use_stripe_sdk: {
...
three_ds_method_url: "",
...
},
...
},
status: "requires_source_action"
...
}
Does that make sense or do you need more information ?
"pi_3MxvppFdV4bT3T5F1TFIusBn"
Thanks, looking
Okay so in this case you should be transitioning to the 3DS authentication flow
The status is requires_action
shouldn't there be a url to follow within the response payload?
the three_ds_method_url?
perf-react-paymentelement
@kind pecan I'm sorry I don't really understand what the issue is and what you are trying to solve
Sorry for the confusion. I am attempting to confirm a payment intent with the stripe.js library using a 3DS requried test card.
I was trying to find documentation on how to do so properly. @night whale linked me this document on the website ( https://stripe.com/docs/payments/3d-secure).
which gives the references that the payload should return something like
next_action: {
type: 'redirect_to_url',
redirect_to_url: {
url: 'https://hooks.stripe.com/...',
return_url: 'https://mysite.com'
}
}
and to do the following
var action = intent.next_action;
if (action && action.type === 'redirect_to_url') {
window.location = action.redirect_to_url.url;
}
but I don't see that field is my response payload.
How are you integrating exactly. Because that doc is for extremely advanced users that don't want to use Stripe.js at all usually. In your situation you should be using PaymentElement and calling confirmPayment() and let us do everything
sorry I will get back to you in a bit.