#Matt11-payment-intent
1 messages · Page 1 of 1 (latest)
👋 Happy to help
Can you share the payment intent ID and the difference you're facing?
Hi! these are the ids.
pi_3LGVQfApMCw5clA31c2Fujzb and pi_3LGVQZApMCw5clA315jE5dxf
The first one is still incomplete while the second one is failed
But I don't think that the customer failed the 3ds check at midnight. It seems that the bank failed the authentication almost automatically. is it possible?
Looking into them now
thanks!
In second one, the customer failed 3D Secure authentication
The first one is that the customer doesn't attempt to complete 3DS
The behaviours can be different due to different action taken by the customers
it is weird that the customer tried at midnight
There are various ways of 3DS authentication by the issuers. One common 3DS failure is that the customer enters incorrect one-time password (OTP) provided by the issuer. It doesn't matter when 3DS happens
Ok, can I ask you infos about a customer also?
cus_Jiv3l4PoHSzQDr
I see that when he had a subscription no 3ds was never requested, but now with payment_intent is requested. there's a motivation behind this?
For recurring payment in subscription, customer was not present and the issuer didn't expect 3DS, so no 3DS didn't happen.
For normal payment, the customer was in session and issuer expected 3DS and requested for it.
So it all depends on whether the issuer requires/requests for 3DS or not
what do you mean with "customer was not present"?
In my platform when I created a subscription the customer was in-session because he inserted card data into stripe elements.
Customer was in-session when inserting the card. However, customer was no longer around during the next payment/billing cycle which the invoice of a subscription was charged automatically
Either case, the decision whether 3DS will happen depends on the issuer
and is possible to achieve the same behaviour of a off-sessione subscription with a payment intent?
What kind of behaviour do you want to achieve?
that a payment_intent is charged without 3ds, as a off-session subscription
generally the first payment is on-session, and the recurring payments on the subscription are off-session. That's handled internally really if you're using our Subscriptions/Invoice APIs. If you're not and process the payments yourself directly, then you need to flag the recurring payments with the off_session boolean https://stripe.com/docs/api/payment_intents/create#create_payment_intent-off_session
if it's flagged off-session then we try to claim the appropriate exemptions from 3D Secure from the bank when we process the payment
I using this:setup_future_usage: 'off_session' flag
yep that's just for the first payment though
that's how you process the first payment and let us know that you intend to charge the card used in that first payment in an off-session way in the future
passing off_session:true on the later payments is how you actually tell us it's an off-session payment though
it's explained in detail at https://stripe.com/docs/payments/save-during-payment?platform=web#charge-saved-payment-method
so, setup_future_usage: 'off_session' and off_session: true acts in different way?
they're entirely different parameters
setup_future_usage is what you use on the first, on-session payment when you charge the customer for the first time. As the docs say :
The setup_future_usage parameter helps optimize future payments made with the same payment method. When both setup_future_usage and a customer are provided on a PaymentIntent, the payment details are automatically saved to the customer once the payment is confirmed.
Supplying an appropriate setup_future_usage value for your application may require your customer to complete additional authentication steps, but reduces the chance of future payments being rejected
then, on future payments you make on the saved card from that first payment, you use off_session:true to tell us the payment is off-session so that we know that and can apply appropriate exemptions from 3D Secure
and what if I pass setup_future_usage:off_session and off_session:true to all payments? because Im not able to identify first/next payment at the moment
then we treat every payment as off-session
because Im not able to identify first/next payment
I'm unsure how that could be possible, either your code is being called from the webpage where the customer is submitting their payment information, or it's being called from some recurring job you have set up to do recurring billing on saved cards or so on
yes but if I set setup_future_usage:off_session and off_session:true to all payment I'm sure that every payment will be treated as off_session no matter what
right?
this is the code I use for every payment I create, first time or later:
payment_intent = ::Stripe::PaymentIntent.create({
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
payment_method_types: ['card'],
setup_future_usage: 'off_session',
payment_method: payment_method_id
})
begin
::Stripe::PaymentIntent.confirm(
payment_intent.id,
{ payment_method: payment_method_id }
)
::Stripe::PaymentIntent.retrieve(payment_intent.id).to_h
rescue => e
puts e
end
so I can convert it in this way?
begin
payment_intent = ::Stripe::PaymentIntent.create({
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
payment_method_types: ['card'],
setup_future_usage: 'off_session',
confirm: true,
off_session: true,
payment_method: payment_method_id
})
rescue => e
puts e
end
you shouldn't flag a payment that is on-session as off-session since flagging off-session gets certain exemptions and is treated differently by banks, so you need to know which mode it is when you call our API to charge your customer
you should do what the docs and I have said, use setup_future_usage on the first on-session payment and then off_session:true on future off-session payments
well SetupIntents are used when instead of having an initial payment, you just save the card. For example if you save the card now but don't charge it until next month(like a classic trial period)
and yes when creating the SetupIntent you use the value of usage that matches what you intend to use the saved card for in future payments
ok thanks, I will look into it
I'm going to explain the customer platform for some advice if I can
I have two king of plans, one with 7 trial days + 365 days of subscription, the second only with 365 days of subscription.
A customer can pick one of these during the checkout flow.
So, if he selects the trial plan I need to create a setup_intent with usage: 'off_session' and then confirm it. If he selects the non-trial plan I need to create a payment_intent with only setup_future_usage: 'off_session' since he's paying immediately.
After 7 days, a renew script will occur to switch the trial users to subscription users. So in this case I need to create a payment_intent with off_session: true and confirm: true, right?
When 365 days passes the renew script needs to create a payment_intent with off_session: true and confirm: true, right?
yep that all sounds right
another question sorry
for next payments do I need to set always setup_future_usage: 'off_session'?
or is it unnecessary?
nope, you only need that on the first payment
ok so this is the first_payment case:
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
payment_method_types: ['card'],
setup_future_usage: 'off_session',
confirm: true,
payment_method: payment_method_id
})```
and this the next ones:
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
payment_method_types: ['card'],
confirm: true,
off_session: true,
payment_method: payment_method_id
})```
sure! usually though you do the confirmation on the frontend for the on-session payment but I assume you have reasons for doing it on the backend
ok thanks!
another question sorry
I have the case that could be the first payment but also off-session, what I need to do?
Hey, taking over here!
Using a pre-existing Payment Method?
using a payment method saved from setup_intent
payment_intent = ::Stripe::PaymentIntent.create({
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
payment_method_types: ['card'],
off_session: true,
confirm: true,
payment_method: payment_method_id
})
Would work then
Oops, hang on
It'd be no different from your 2nd payment example above
You can omit the payment_method_types param really
So, this is for the first payment on-session
{
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
setup_future_usage: 'off_session',
confirm: true,
payment_method: payment_method_id
}
this is for first payment off-session or next payments off-session
{
amount: amount,
customer: user.stripe_customer_id,
currency: 'eur',
confirm: true,
off_session: true,
payment_method: payment_method_id
}
Yup!