#BeardMan-setup intents
1 messages ยท Page 1 of 1 (latest)
It seems this would be the way I should proceed: https://stripe.com/docs/payments/save-and-reuse
I just want to be sure
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
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.
perfect
From here, a setup intent should be created checking for 3ds
This setup intent, should it be stored at some point?
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?
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.
Instead of creating a PM and then attaching it to the Customer you could automatically use the Setup Intent instead
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?
allow the customers (app users) to view/manage/delete their cards
If you want that why not use our Customer Portal?
This is a mobile app, Flutter ๐
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
you could always redirect to a WebView
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?
You could always create your view to "view/manage/delete" and still use the SetupIntent
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?
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.
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 ๐ )
you don't use the SetupIntent to pay the Invoice, you use the PaymentMethod pm_xxxx. The SetupIntent sets up the PaymentMethod and attaches it to the customer, and the invoice will charge that PaymentMethod (either you set it as default_payment_method and the invoice charges it automatically, or you can call https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-existing in a frontend page using the Invoice's PaymentIntent for example)
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?
you shouldn't attach a PaymentMethod to a customer directly if that's what you mean
like https://stripe.com/docs/api/payment_methods/attach shouldn't really be used
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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.
Awesome
I see the SetupIntent's field payment_method is optional, what happens if I leave it blank while requesting a card type payment?https://stripe.com/docs/api/setup_intents/create#create_setup_intent-payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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)
then you'd use https://pub.dev/packages/flutter_stripe really, it should wrap the native functions our mobile SDKs have that do the same thing
it was released last year