#nikhil.k.t-cards
1 messages ยท Page 1 of 1 (latest)
Hey, Thanks for replying
Details such as card type
am using Android SDK
so how can i retrieve card type details after payment
Do you mean the funding type? Like credit vs debit? Or do you mean the card brand (like mastercard)
Card brands
You're trying to get this AFTER payment right? If you have the full Payment Method object you should be able to get it in the Android SDK (https://stripe.dev/stripe-android/payments-core/com.stripe.android.model/-payment-method/-card/index.html) vs if you want to get it server side (https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-brand)
sir, we are using this method
and to fetch the details from backend, from where we will get this details
"id": "pm_1LPqSC2eZvKYlo2C0OSzEdB5"
So you just have the ID right now? Then you need to retrieve the Payment Method to get the full details (https://stripe.com/docs/api/payment_methods/retrieve)
ok, so basically i just need to call this api
yup!
It would be included in your Payment Intent
Let's back up for a minute and start over - what call are you making client-side that you're making which you would like the PaymentMethod from?
we are using payment intent to create payment order
then we pass that response in android sdk
Yeah so what are the exact calls you're making client-side?
๐ So I assume you want the Payment Method/Card brand as soon as the Payment is complete client-side, right?
yes
Gotcha - since you're just using the standard payment sheet integration, I think you're best option would be that after you get confirmation that the payment was complete (by getting PaymentSheetResult.Completed) you make a request to your own server which will then retrieve the Payment Intent and PaymentMethod
The alternative would be to switch to the customer payment sheet integration, but that requires way more integration changes
https://stripe.com/docs/api/payment_intents/create#create_payment_intent-amount
in server end we use this method to create the payment intent
Yes, but if you're following the android guide you linked then that's expected - you create the Payment Intent initially, send the client secret back to your Android app, and then use the Payment Sheet to complete payment
Once the Payment Sheet is done accepting payment you need to re-retrieve the Payment Intent + Payment Method to verify the status or get the brand (the alternative is to wait for the webhook event to be triggered and you'll get the intent there, but you said you wanted it client-side so you'll have to retrieve it)
yes after completing payment, we need to fetch card type in backend.
how can we retrieve the Payment Intent + Payment Method
In your Android App you'd keep track of which Payment Intent is being paid for and then send that to your server to retrieve the Payment Intent (in that same request you'd expand payment_method to get it back in the same call)
I need to head out but @faint wave is around to answer any other questions
ok
As we are using standard payment sheet, will stripe automatically create payment method
Yes. Once the payment details are collected, a payment method is created
so how can we get the detail of that payment method(i mean payment method ID or something)
from which api response we get that?
I think that depends on what you need it for. You should already have the Customer ID before they enter their payment details and the Payment Method ID can be retrieved from that object once the customer has provided the payment method details.
Not sure if that adequately answers your question though, so feel free to let me know if I overlooked something.
i think you are refereeing to this right ?
"customer": null,
i mean while creating payment intent we get this variable in its response
"customer": null,
What are you using the Payment Method ID for?
to get the card type
of that specific transaction
our motive is to get the card brand type for that particular transaction
And do you want it before payment or after payment?
after payment success and need to fetch from backend
Ah, in that case I would either (a) listen for the payment_intent.succeeded webhook and look at the Payment Intent object's payment_method field, or (b) retrieve the Payment Intent, using its ID, from the retrieve endpoint: https://stripe.com/docs/api/payment_intents/retrieve and look at its payment_method field
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
https://stripe.com/docs/api/payment_intents/retrieve
but by using this method we are not getting which type card customer used for that transaction
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Right, you would need to expand the payment_method field to get the card hash from it, which should have all the data you need
By default, some API endpoints return just the object ID associated. So in this case, you get the Payment Intent object with a field called payment_method. That field will only contain the ID of the payment method unless you expand it. Expansion essentially makes sure that all the fields/data associated with the payment_method property are returned: https://stripe.com/docs/api/expanding_objects
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
payment_method is the thing you're trying to expand right? So pass payment_method
Here's a good example if you're confused: https://stripe.com/docs/expand#how-it-works
/v1/payment_intents/:id
StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
var service = new PaymentIntentService();
service.Get("pi_1DrOsp2eZvKYlo2CGYAdR6IL");
options.AddExpand("payment_method");
so, basically i have to use this api and pass like this to get the card brand type for a specific transaction
That code isn't entirely complete, so I can't say if that will or won't work, but you do have to retrieve the Payment Intent via its ID and expand the Payment Intent payment_method hash in order to get the card details.
Correct
There are a few examples in the docs I sent you. I cannot write the expand call for you unfortunately
ok