#obo-indiarbi-setupintent

1 messages · Page 1 of 1 (latest)

full harborBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

slim chasm
#

obo-indiarbi-setupintent

#

@open mist Can you provide detailed information about what you are doing exactly (exact relevant code + exact request id and relevant object ids) so that I can help you debug this?
Also make sure to carefully read https://stripe.com/docs/india-recurring-payments as this is quite complex to set up right and with SetupIntent you need to ensure you have the exact mandate_options needed

open mist
#

yes absolutely, one moment, it appears I posted the wrong error message from previous testing: here's the error code I'm receiving: "Only active mandates can be used with PaymentIntents."

#

here's my setup intent code, which I receive the 3ds2 modal for, click accept, then try to upgrade the account:

        const intent = await stripe.setupIntents.create({
            customer: user.stripe_customer.stripe_customer_id,
            // In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default.
            automatic_payment_methods: {enabled: true},
            usage: 'off_session',
            // payment_method_types: ['card'],
            payment_method_options: {
                card: {
                    mandate_options: {
                        reference: uuidv4(),
                        description: 'sanitized description',
                        currency: 'USD',
                        amount: 15000,
                        start_date: convertDateToStripeEpoch(new Date()),
                        amount_type: 'maximum',
                        interval: 'month',
                        interval_count: 1,
                        supported_types: ['india'],
                    },
                },
            },
        });
#

@slim chasm I apologize it appears this things are going through with a second attempt, is that a testing environment only thing or something I should expect to see in production as well?

slim chasm
#

Hmmmm hard to say without more actionable information

#

Were you properly waiting for the Mandate to be active?

open mist
#

we don't have code that specifically waits for it, I just clicked accept on the modal, waited a few seconds then clicked "upgrade plan" (which kicks off the subscription update attempt)

slim chasm
#

yeah you have to wait for the Mandate to be active before trying to use it

#

Also you really shouldn't be doing a SetupIntent if you immediately have them upgrade their plan

open mist
#

"Also you really shouldn't be doing a SetupIntent if you immediately have them upgrade their plan" can you explain this a bit more, i think we just did this so it was set up for all future subscription changes (as our customers can switch between plans without changing their card)

#

basically part of our upgrade flow is "if you don't have a card on file we prompt you for one before we let you click the upgrade button" however if they have a card they can just click upgrade and confirm

modest summit
#

Real quick, before we get side-tracked, are there any outstanding questions re. the Mandates? It looks like you were answered already, but I wanted to make sure

open mist
#

I don't think so...? Unless it somehow relates to the SetupIntent issue ethat koopajah mentioned

modest summit
#

I'm not sure what they were referring to and Discord is very busy, so I can't get clarification, but Setup Intent before an upgrade seems like an okay workflow to me

open mist
#

got it, thank you

#

I actually have one more question if you're able to. Is it possible to join setup intent objects with the payment method objects returned from the API?

modest summit
#

What do you mean by "join"?

open mist
#

or am I correct in assuming that I have to first grab the default payment method id then make a separate call

#

basically I call stripe right now, and return the customer object, which includes the default payment method in the invoice_settings object. However I can't seem to get information about whether that payment method has a setup intent that's active

#

I'm curious if i'm looking in the wrong spot, or if I do indeed have to make two separate api calls to stripe

#

(first extract the payment_method_id and then use that to query the setup intent api)

modest summit
#

Why not get the Payment Method from the setup_intent.succeeded webhook?

open mist
#

we're currently not storing payment methods in our db (keeping stripe as the "source of truth"). So basically I'd like to just ask stripe "does this customer have an active setup intent before trying to upgrade them

modest summit
#

I see. I would definitely recommend setting up a DB, but understandably that's a lot of work.

As for finding out if the Payment Method is setup for future usage, you can check this attribute for cards: https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-generated_from-setup_attempt

open mist
#

interesting. I'm not seeing that returned for some reason.

modest summit
#

Huh, interesting. In that case, you would have to make 2 API calls as you mentioned above, unfortunately. That or spin up a database