#Matt11-payment-intent

1 messages · Page 1 of 1 (latest)

plush arch
#

👋 Happy to help

#

Can you share the payment intent ID and the difference you're facing?

mossy stump
#

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?

plush arch
#

Looking into them now

mossy stump
#

thanks!

plush arch
#

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

mossy stump
#

it is weird that the customer tried at midnight

plush arch
#

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

mossy stump
#

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?

plush arch
#

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

mossy stump
#

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.

plush arch
#

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

mossy stump
#

and is possible to achieve the same behaviour of a off-sessione subscription with a payment intent?

plush arch
#

What kind of behaviour do you want to achieve?

mossy stump
#

that a payment_intent is charged without 3ds, as a off-session subscription

unique thunder
#

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

mossy stump
#

I using this:setup_future_usage: 'off_session' flag

unique thunder
#

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

mossy stump
#

so, setup_future_usage: 'off_session' and off_session: true acts in different way?

unique thunder
#

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

mossy stump
#

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

unique thunder
#

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

mossy stump
#

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
unique thunder
unique thunder
mossy stump
#

ok, and I need to do the same for setup_intents?

#

using the usage: off_session?

unique thunder
#

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

mossy stump
#

ok thanks, I will look into it

mossy stump
#

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?

unique thunder
#

yep that all sounds right

mossy stump
#

another question sorry

#

for next payments do I need to set always setup_future_usage: 'off_session'?

#

or is it unnecessary?

unique thunder
#

nope, you only need that on the first payment

mossy stump
#

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
})```
unique thunder
mossy stump
#

ok thanks!

#

another question sorry

#

I have the case that could be the first payment but also off-session, what I need to do?

violet citrus
#

Hey, taking over here!

violet citrus
mossy stump
#

using a payment method saved from setup_intent

violet citrus
#
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

mossy stump
#

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
}
violet citrus
#

Yup!