#.strawht
1 messages · Page 1 of 1 (latest)
I'm adding a user payment method using setup intents on iOS via the StripePaymentSheet; however, I'm noticing there's maybe a ~20-30 second delay between adding and fetching valid payment methods for the customer via the customer context (It is returning empty even though I had just added a payment method via setup intent). Are there recommendations you can provide to not have such a great delay?
Hmm yeah that delay shouldn't exist
How are you fetching the PaymentMethod exactly after the SetupIntent is confirmed?
Like it should be available immediately after successful confirmation
I'm fetching payment methods with:
https://stripe.dev/stripe-ios/stripe/documentation/stripe/stpcustomercontext/listpaymentmethodsforcustomer(completion:)
I'm adding a payment via the payment sheet configured with a setup intent
Huh okay so you call this immediately in your case .completed block?
self.paymentSheet?.present(from: self.rootViewController) { [weak self] paymentResult in
switch paymentResult {
case .completed:
self?.store.dispatch(.loggedInAppStatusAction(.hasSuccessfullyAddedPaymentMethod))
self?.progressToNextOnboardingFlow()
break
case .canceled:
break
case .failed(_):
break
}
}
yes, i try to present available payment methods to the user in the following screens
Gotcha. I haven't tested using that istPaymentMethodsForCustomer so I'll need to repro, but in the meantime can you test with calling your backend and listing via https://stripe.com/docs/api/payment_methods/customer_list and then returning that result? That should be ~instant.
confirmed, when using the curl, right after adding a card via a setup intent on the iOS Payment sheet, the results are correct
Thanks for testing
the iOS SDK returns invalid output up to 30 seconds
as in, it doesn't believe there's a valid payment method
and returns an empty list
Ah okay so my colleague just found https://stripe.dev/stripe-ios/stripe/documentation/stripe/stpcustomercontext/
yes, the listPaymentMethodsForCustomer is succeeding, but the output is incorrectly an empty list
Can you try clearing the cache first with https://stripe.dev/stripe-ios/stripe/documentation/stripe/stpcustomercontext/clearcache()/
So call that then call listPaymentMethodsForCustomer
great that resolved the issue
nice
Yeah if you want to list them immediately
thank you
Another question is , when adding a payment method via the payment sheet, how can it be set as the default payment method?
when retrieving via stripe cl:
stripe customers retrieve cus_OjKMhZNHyKYoAp
"invoice_settings": {
"custom_fields"
:
null
,
"default_payment_method"
:
null
,
"footer"
:
null
,
"rendering_options"
:
null
,
"supported_payment_methods"
:
{}
,
}
Hi there 👋 I'll need to double check whether it's possible to have the Payment Sheet update the default payment method for the Customer.
You can make a request to update the Customer object directly, and provide the ID of the newly created Payment Method to the invoice_settings.default_payment_method field.
okay, lmk when you can confirm!
Hm, not finding anything so far, one more place to look.