#BeardMan-setup intents

1 messages ยท Page 1 of 1 (latest)

radiant island
#

๐Ÿ‘‹ happy to help

#

just give me a moment please

grim pike
#

I just want to be sure

radiant island
#

this is one way of doing that yes

#

note that even for off_session payments if the card needs 3DS auth you will have to get your customer back to perform an on_session payment

grim pike
#

Sorry, just trying to wrap my head around this.

#

So, on our mobile app, user creates account (by extension, a Customer account is created). Later, the user adds card (payment method) and this is set as the default invoice payment method.

#

This is the point I'm at atm.

radiant island
#

perfect

grim pike
#

From here, a setup intent should be created checking for 3ds

#

This setup intent, should it be stored at some point?

radiant island
#

the user adds card (payment method) and this is set as the default invoice payment method.
sorry I though you already used the Setup Intent for this step

#

if not, how are you accomplishing this?

grim pike
#

Sec

#

This is the crux of it

/// Create payment method with card details
return StripeApi.getInstance.stripeInstance.paymentMethods.create({
    type: "card",
    card: {
        cvc: cardData.card.cvc,
        number: cardData.card.number,
        exp_month: cardData.card.expMonth,
        exp_year: cardData.card.expYear,
    },

/// attach payment method to customer
}).then(value => StripeApi.getInstance.stripeInstance.paymentMethods.attach(value.id, {
    customer: customerId

/// optionally set as default payment method
})).then(async (value) => {
    if (cardData.primary) {
        await StripeApi.getInstance.stripeInstance.customers.update(customerId, {
            source: value.id,
            invoice_settings: {
                default_payment_method: value.id,
            },
        });
    }

    /// continue on...
})
#

If that is what you were asking

#

That is what I meant with, customer adds card to account and is set as default payment method

#

Since we're talking about setup intents, etc - this is where things gets a bit murky for me.

radiant island
#

Instead of creating a PM and then attaching it to the Customer you could automatically use the Setup Intent instead

grim pike
#

Right. This way provides a mechanism to allow the customers (app users) to view/manage/delete their cards

#

To my knowledge, setup intents won't allow this?

radiant island
#

allow the customers (app users) to view/manage/delete their cards
If you want that why not use our Customer Portal?

grim pike
#

This is a mobile app, Flutter ๐Ÿ˜‰

radiant island
#

you could always redirect to a WebView

grim pike
#

Hmm, I'll look at that

#

Redirecting out of app feels like it breaks a bit of UX.

#

But going with this approach of payment methods, etc for sake of keeping things in-app, is there an alternative to using the customer portal?

radiant island
#

You could always create your view to "view/manage/delete" and still use the SetupIntent

grim pike
#

I'm checking that out atm, upon creating a setup intent a payment method is required. I'll surely be back a bit later to pick your brains further. Thanks for the assistance

#

If you can maybe clarify something for me, in the use of payment methods & invoices, I can't see a use for setup intents (rather, I see setup intents as just a 'confirmation of payment information' i.e. confirm 3ds cards).

In that sense, I don't see any field/requirement for setup intents to be used in invoicing, only payment methods & ids. What am I missing?

mint kernel
#

you use a SetupIntent whenever you need to accept a card without directly charging it right now.

#

like if you're going to accept the card now and issue an invoice 2 days later to charge it, or something.

grim pike
#

Right, that makes sense.

#

Do you have documentation, or references to using this setup intent for payment of an invoice or do I simply use that payment method (attached to the setup intent) for paying the invoice(s)?

#

(that last part is the one that's not entirely clear to me i.e. setup intent but no place to put that setup intent's id ๐Ÿ˜‰ )

mint kernel
grim pike
#

Awesome, that makes sense. The concept of a setup intent wasn't quite clear but thanks for clarifying.

#

My plan going forward is retaining the current PaymentMethod API call adding the payment method to the customer, followed by creating a SetupIntent (using the newly added PaymentMethod id ) with a card type and handling any 3ds authentication.

Does that sound right?

mint kernel
#

you shouldn't attach a PaymentMethod to a customer directly if that's what you mean

grim pike
#

Oh

#

Right

mint kernel
grim pike
#

I'm using that ๐Ÿคฃ

#

Setup intent should handle that

#

with its customer field

mint kernel
#

instead you create a SetupIntent and set the customer field. When you confirm the SetupIntent successfully by passing card details, it will automatically attach the card to the customer.

#

as you say, yes.

grim pike
#

Awesome

mint kernel
#

you very rarely would use that

#

you usually create the SetupIntent on the backend, return the client_secret to the frontend, and the frontend confirms the SetupIntent using card details inputted there.

#

the frontend library creates the PaymentMethod object for you and processes the setup

grim pike
#

Sorry, I'm using Flutter (no native stripe impl for it)

#

Makes things a bit more tricky while keeping everything in-app (not redirecting to browsers)

mint kernel
grim pike
#

Yup, published 9 days ago

#

Not using that in production

#

Too soon

mint kernel
#

it was released last year

grim pike
#

I had a look at it back then, there was a reason I opted not to go down that route but glad you showed it to me again.

#

I'll take another look at it