#momomonkey_android-setupintent-expandpm

1 messages ยท Page 1 of 1 (latest)

zenith kestrelBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1275201984969838794

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

gleaming ermine
#

Hi there

regal solar
#

hi

gleaming ermine
#

Give me a few minutes, I think retrieving PaymentMethods can only be done server side

#

Okay, confirmed. When you retrieve the SetupIntent, we'll return the PaymentMethod ID but nothing else. You'll need to retrieve the SetupIntent server side and expand payment_method or directly retrieve the PaymentMethod server side if you need last 4 and exp date.

#

Assuming you're creating a SetupIntent for a specific customer, you could also rely on webhooks and listen for payment_method.attached ; the payload for the event will include the PaymentMethod object and the customer ID

regal solar
#

ok, I am just a bit confused because my coworker working on iOS is able to retrieve that information client side:
func setupIntentCompletion(status: STPPaymentHandlerActionStatus, setupIntent: STPSetupIntent?, error: NSError?) {

    if status == .succeeded, let paymentMethodID = setupIntent?.paymentMethodID, let card = setupIntent?.paymentMethod?.card {

        let paymentCard = StripePaymentMethodCard(brand: card.brand.description,
                                                  last4: card.last4 ?? "",
                                                  expMonth: card.expMonth,
                                                  expYear: card.expYear,
                                                  countryCode: "CA")
snow fossil
#

Hi ๐Ÿ‘‹

I'm jumping in because I've got a little more experience with our mobile SDKs.

Both our iOS https://stripe.dev/stripe-ios/stripepayments/documentation/stripepayments/stpsetupintent and Android https://stripe.dev/stripe-android/payments-core/com.stripe.android.model/-setup-intent/index.html SDKs define the SetupIntent.paymentMethod as a nullable object. The way the iOS SDK describes it, makes it sound like this is something you need to request

The optionally expanded PaymentMethod used in this SetupIntent.

regal solar
#

Button("Save Card") {
setupIntentParams.paymentMethodParams = paymentMethodParams
setupIntentParams.paymentMethodParams?.type = .card
isConfirmingSetupIntent = true
}
the iOS app uses this when saving the card

snow fossil
#

Hmmm ๐Ÿค”

#

Give me a couple minutes to spin up an Android repo. Shouldn't take too long

zenith kestrelBOT
snow fossil
#

Okay I've been able to repro but I'm also getting paymentMethod=null when I retrieve the Setup intent

#

๐Ÿคฆโ€โ™‚๏ธ

#

All you need to do is pass the expand parameter in the retrieveSetupIntent to get the full Payment Method

#
 val setupIntent = stripe.retrieveSetupIntent(clientSecret,   expand = listOf("payment_method"))
                Log.d(TAG, "SetupIntent: $setupIntent")

This code worked for me

regal solar
#

will try it out now

snow fossil
#

I just feel dumb for building the whole thing into my Android integration and not noticing that earlier

regal solar
#

that works, thank you so much

snow fossil
#

Great ๐ŸŽ‰ Happy to help ๐Ÿ™‚