#sashabelonogov-save-and-reuse
1 messages · Page 1 of 1 (latest)
great, thanks!
Just to be even more precise, the reference of the setupIntent in iOS is sent with the setup result, on Android, it just pretty much says "Completed" and doesn't attach a setupIntent reference, even though the documentation says that I can get the paymentMethodId from there
setupIntent.getPaymentMethodId() is part of the backend code
and assigning that PaymentMethod to the customer is something that happens automatically without having to do any other action that confirming the SetupIntent
I'm sorry, but nope it's not
getPaymentMethodId() is a java method
the documentation for Ruby would even have a different style. And I can see this method for the Android SDK library SetupIntent class
in fact, in the similar iOS documentation, there is a Swift variable mentioned at the same spot, e.g. setupIntent.paymentMethodID
I hear you, but what I'm trying to say is that you don't need to use it
it's great that the assigning of the PaymentMethod happens automatically, but in our implementation, we keep the track of the payment method ids to query them separately, therefore we save the payment_method_id on the backend.
It works perfectly on iOS
but when it comes to Android, I believe, the only way is to redo it all using websockets or some fancy mechs on backend
you can use webhooks for both
so, is there no way to simply fetch the paymentMethodId for Android to simplify the flow?
you could listen to setup_intent.succeeded https://stripe.com/docs/api/events/types#event_types-setup_intent.succeeded
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I don't have the answer on top of my head
Alrighty! Thanks anyways! Then I will keep cracking the Android SDK to make sense of it, not relying on the documentation
but IMO it's better not to duplicate the logic across your apps, and if you can handle saving the PM directly using the webhooks it's already neater since you don't have to do a call
@thick trellis I will try to find a solution for you, but I was just suggesting another route that seems to me a better solution
please give me a moment
webhooks mean that the backend payments service will be opened to the public and that's something we don't want to do because of the security reasons. And webhooks is a completely different complexity
that's not really true
because we already provide a way of verifying the signature of our events
ah, true, makes sense
this means that any request that fails this verification isn't coming from Stripe and thus you can ignore
I'll try to poke around for the Android SDK thing and I'll be back shortly with an answer
Thanks a lot for poking it with me!
If you see on line 125 this is how you get your Setup Intent
Oh, I see the alternative flow.
Thank you very much!
no worries, but again, I would strongly advise you to consider webhooks, it's really easier and more scalable than having to maintain the same logic in both of your apps and it removes this processing from the mobile app to your server
but feel free to adopt either, both approaches work