#bugkiller.

1 messages ยท Page 1 of 1 (latest)

stone wadiBOT
stuck coral
#

Can you please help me to figure out the issue

crude geyser
stuck coral
#

I'm not sure what you're askign

#

month ago, we migrated stripe payment (popup style) into stripe checkout session

#

we have ui user to be able to add their card

#

once user clicks the add card, we're doing this api call in backend and redirect them to stripe

#

so user did it, and then user now have payment sourse

crude geyser
#

Just to preface this, I'm just another Stripe user. ๐Ÿ™‚

I'm suggesting that you could review the logs to understand why the subscription wasn't created.

stuck coral
#

once user click subscribe button after that, we're trying to mkae subscription with. stripe.Subscription.create

#

Can you please check this?

crude geyser
#

Stripe does a really great job capturing all sorts of logs for the various lifecycle steps and reviewing the logs is a great first step. Since I'm just another Stripe customer, like you, I won't be able to check specific resources you link to, but you might check the logs yourself in the meantime.

stuck coral
#

you're not stripe support?

#

I'm here to meet stripe guy

blissful mango
#

๐Ÿ‘‹ Let me take a look

stuck coral
#

in the prev, once I give id, they checked it to find a reason

#

I can see this message , but not sure where user needs to do it.

#

we're creating subscription inside backend when user clciks button in frontend (because user already added payment source by this api)

#
session = stripe.checkout.Session.create(
                payment_method_types=['card'],
                mode='setup',
                customer=stripe_customer.id,
                # setup_intent_data={
                # },
                success_url=os.getenv('BACKEND_HOST') + '/api/execute-add-card-stripe-session/?session_id={CHECKOUT_SESSION_ID}',
                cancel_url=os.getenv('BACKEND_HOST') + '/api/cancel-add-card-stripe-session/'
crude geyser
# stuck coral

It sounds like you're on the right track.

Some payment cards require 3D Secure validation as an added form of confirmation of the payment. For a normal credit card, you just get the result immediately. But some cards require 3D Secure validation where the customer is redirected to the card issuer's site for validation before it redirects to you.

Did the customer mention anything about that?

stuck coral
#

no, when it will be redirected to the card issue?

#

how can I make user to be redirected to the card issuer`s site if needed

#

I when user add card , no any issue

#
session = stripe.checkout.Session.create(
                payment_method_types=['card'],
                mode='setup',
                customer=stripe_customer.id,
                # setup_intent_data={
                # },
                success_url=os.getenv('BACKEND_HOST') + '/api/execute-add-card-stripe-session/?session_id={CHECKOUT_SESSION_ID}',
                cancel_url=os.getenv('BACKEND_HOST') + '/api/cancel-add-card-stripe-session/'```
#

once I try to create subscrption in backend it didn't complete

#

so I'm not sure what I need to do

blissful mango
#

I appreciate you trying to help @crude geyser ๐Ÿ™‚
I'm juggling in between a few threads so I'll remove you so that I can help @stuck coral when I get bandwidth, it would be difficult for me to maintain context otherwise

#

So it seems like the creation request failed as customer did not complete 3DS

#

You have a couple of options here

stone wadiBOT
blissful mango
stuck coral
#

I'm creating subscription by

#

stripe.Subscription.create

#

how can I know if there's a required action or not

maiden raptor
#

The subscription will have a latest_invoice property with the ID of the current invoice, that Invoice will have a payment_intent property and that PaymentIntent status is what you want to check to see if the status is requires_action

If you are talking about webhook events, you can listen for the invoice.payment_action_required event https://stripe.com/docs/api/events/types#event_types-invoice.payment_action_required

stuck coral
#

how can I simulate this 3ds required testing in my local

maiden raptor
stuck coral
#

Can you please leave this chat to be opened ?

#

I want to test quickly and be back asap

#

which one is best for my test then?

#

I guess 2nd one

maiden raptor
#

Yeah second one is usually the one to use with subscriptions. It will cause 3DS requests on each renewal

stuck coral
#

is there any way user to complete 3ds when he setup 'adding card'?

#

not at point creating subscription

maiden raptor
#

Not sure what you mean. Can you explain what you want to test a bit more?

stuck coral
#

what user is doing first i

#

is

#
session = stripe.checkout.Session.create(
                payment_method_types=['card'],
                mode='setup',
                customer=stripe_customer.id,
                # setup_intent_data={
                # },
                success_url=os.getenv('BACKEND_HOST') + '/api/execute-add-card-stripe-session/?session_id={CHECKOUT_SESSION_ID}',
                cancel_url=os.getenv('BACKEND_HOST') + '/api/cancel-add-card-stripe-session/'
            )
#

adding card

#

so can I make user to complete 3ds at this stage ?

maiden raptor
#

If you use that 3184 card, it will ask them to complete 3DS on setup and on every subsequent payment that uses that card

stuck coral
#

I can see this.

#

but user shared video and when user trying to add card, it didn't ask 3ds

maiden raptor
#

Was this for a live payment?

stuck coral
#

my test is local

#

but user's reported failure on live payment

#

we simply migrated to new stripe checkout session, so no any code to handle 3ds case exactly

#

I thought it will be handled by stripe so no action is needed from me

#

but now, it looks like I need to do something for it

maiden raptor
#

Whether 3DS is requested or not is ultimately up to the bank so this may be a case of the bank not requesting 3DS. You can talk to our support team to look in to that specific transaction if you have the ID of their live payment.
https://support.stripe.com/?contact=true
If 3DS is working for your test flow with that 3184 card, it should be able to handle 3DS for your live payments. So this may be something with the specific live transaction but definitely test your integration thoroughly with those test cards

stuck coral
#

3184, doesn't work

#

adding card, it works, create checkout session for mode='setup', and redirect to the strpie, and then stripe is displaying 3ds popup there. so good

#

but once user click 'subscribe' button our our fronend, we're doing stripe.subscription.create, and it failed due to 3ds

#

for now, we're doing like

#

s = stripe.Subscription.create(..)
if s status is active status then compled page in frontend
if not, check card warning modal

#

It means, if user needs exatra action, we're not handling it

#

so wanted to know what's teh best way to handle it

#

after creating subscription with stripe.Subscription.create(), I need to check invoice by retreiving it by calling another stripe api (get invoice), and need to check if addtional. action needed or not?

maiden raptor
#

Can you send me the ID of the request where you got an error when trying to make a subscription like that? (req_1234)
https://dashboard.stripe.com/test/logs
You may need to set the payment_behavior to one of the settings that lets subscriptions be created even if the first payment cannot be completed immediately https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior

stuck coral
#

so

#

here, is there anyway to get link to redirect for extra action?

maiden raptor
#

To the hosted invoice page? Yes similar to before, your subscription will have the newest invoice ID as its latest_invoice parameter, that Invoice object will have a hosted_invoice_url parameter that you can direct your users to https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url

stuck coral
#

so subscription object will have latest_invoice, and from it, I need to get invoice object ?

#

I'm asking this to know if there's way to get latest_invoice as object not key value

maiden raptor
stuck coral
#

when creating subscription (like expanding result)

maiden raptor
#

Yeah if you expand latest_invoice the API will return the full Invoice object as the Subscription's latest_invoice property

stuck coral
#

sorry for my dummy questions

#

so I can use expand on this api call ? stripe.Subscription.create

maiden raptor
#

No worries, happy to help. And yes, the expand parameter is a parameter on all of our API calls basically

stuck coral
#

stripe.Subscription.create(...., expand=['latest_invoice'])

#

this is correct syntax then?

maiden raptor
#

Yep, should be

stuck coral
#

so hosted_invoice_url will be there even if subscription succeed?

#

if I make user redirect to hosted_invoice_url, how user will be back to our website

#

?

#

I mean, if I make user to be redirected to the hosted_invoice_url, then how user will be back to our website after completing it

maiden raptor
stuck coral
#

how to display it?

#

wait a moment, maybe then I need to expand the payment_intent not latest invoice right?

maiden raptor
#

Correct, for showing the modal on your page you would expand the payment intent, use its client_secret and then use that client secret with Stripe.js to display the modal

stuck coral
#

should I import stripe.js in my frontend?

maiden raptor
#

Sorry I jumped ahead a bit there. That page has three options:

  1. Do a full page redirect (will check in to how to set return_url if you want to do this one)
  2. Display the 3DS modal on your site (this requires Stripe.js)
  3. Display 3DS in an iframe (would require custom logic to detect when 3DS is done)
stuck coral
#
  1. is hwat I like
maiden raptor
#

Then use import Stripe.js and use the code from that doc to display the modal

stone wadiBOT
stuck coral
#

yes, I have imported it already

#

let me check payment intent object

#

@maiden raptor

#

I got this error

#

This property cannot be expanded (payment_intent).

paper mason
#

๐Ÿ‘‹ stepping in here as Pompey needs to step away

stuck coral
#

want to expand

paper mason
#

Can you clarify why you are expanding a PaymentIntent here?

stuck coral
#

so how payment_intent is inside latest invoice. then how to expand

#
subscription = stripe.Subscription.create(
                    customer=stripe_customer.id, trial_from_plan=trial_from_plan, coupon=coupon_code,
                    items=[{'plan': product_code, 'quantity': seat_counts}],
                    expand=['payment_intent', 'latest_invoice'])```
paper mason
#

expand=['latest_invoice.payment_intent']

stuck coral
#

then latest invoice will also expanded?

paper mason
#

You must expand the latest_invoice in order to access the payment_intent property to expand that

stuck coral
#

ok, then it's time to show popup infrontend

#

๐Ÿ˜ญ

paper mason
#

Why are you handling 3DS yourself here as opposed to just letting Stripe.JS handle all of this for you?

paper mason
#

Yeah you don't have to host the modal yourself though

#

If you confirm a PaymentIntent with Stripe.JS and 3DS is required then we will display the necessary modal for you

stuck coral
#

how to confirm

#

general flow in our website, user add stripe card first in profile, and click subscribe,

#

once user clicke subscribe, we do stripe.Subscription.create (because user already added card in stripe by stripe checkout session with mode='setup')

#

but for few users, they're failing (actually we're failing creating subscriptino) due to like 3ds

#

so now I got subscription object which is not succeed (payment_intent is expanded)

#

now how to display 3ds by stripe.js?

paper mason
#

Well let's back up. Why are you using setup mode to begin with instead of subscription mode with Stripe Checkout?

#

Then Checkout would handle 3DS for you as well

stuck coral
#

that's our work flow

#

we have ui to manage card

#

so once user click the subscribe in somewhere, we will display modal like 'use cards on file'

#

then added card will be used

#

?

#

hi

#

?

paper mason
#

Ah okay so this is for starting Subscriptions with previously saved cards

stuck coral
#

yes yes

#

correct

paper mason
#

You are going to need to be patient, I'm helping multiple folks at once.

#

So I won't always respond immediately.

stuck coral
#

ah, ok

paper mason
#

So it isn't going to be that they set up the card then immediately start the Subscription

#

They set up the card in the past, then they return to your site and start the Subscription later on, correct?

stuck coral
#

yes, like that,

#

even some users will add card today, and today will try subscribe with that card added

paper mason
#

Ok well I'd recommend using subscription mode if the user is going to start a new Subscription immediately without using a card saved in the past.

stuck coral
#

@paper mason not about if,

#

I'd like to know how to resolve in my scenario

paper mason
#

Regardless, what you want to do is you want to pass the PaymentIntent's client_secret to your client and use confirmCardPayment() to reconfirm the PaymentIntent client-side if 3DS is required.

#

That will then allow Stripe.JS to display the 3DS modal.

stuck coral
#

how can I know if 3ds is required or not

#

from payment_intent

paper mason
#

The initial payment attempt will fail with authentication_required

stuck coral
#

please consider that I'm so dummy ๐Ÿ™‚

#

where can I get that info if addtional action needed (like 3ds) in

#

from result stripe.Subscription.create()

paper mason
#

Yep

stuck coral
#

yep means? how?

paper mason
#

From stripe.Subscription.create()

#

Best thing to do is test this scenario out in test mode

#

You want to use the 4000002760003184 test card

#

Which always reuires 3DS

stuck coral
#

yes yes.

#

my question is not abou tit

#

how to know if 3ds is needed

#

from subscription object I got by 'stripe.Subscription.create'

#

??

paper mason
#

Go test it out. I can't walk you through every single step here. Run a test and look at your Dashboard and the objects that are returned to you, their statuses and properties.

#

The Subscription creation request will fail here with a 4xx and return you an error response about authentication being required.

#

So it should be pretty clear

#

But the best thing to do is to actually test it.

stuck coral
#

I already have it but not sure how

#

so asking

paper mason
#

Your PaymentIntet is in a status of requires_action

#

That indicates 3DS is needed