#nikhil.k.t-cards

1 messages ยท Page 1 of 1 (latest)

jade mango
#

Hello! What other details are you referring to?

silver cradle
#

Hey, Thanks for replying

#

Details such as card type

#

am using Android SDK

#

so how can i retrieve card type details after payment

jade mango
#

Do you mean the funding type? Like credit vs debit? Or do you mean the card brand (like mastercard)

silver cradle
#

Card brands

jade mango
silver cradle
#

sir, we are using this method

#

and to fetch the details from backend, from where we will get this details

#

"id": "pm_1LPqSC2eZvKYlo2C0OSzEdB5"

jade mango
silver cradle
#

ok, so basically i just need to call this api

jade mango
#

yup!

silver cradle
#

but my question is from where i can get this ID

#

pm_1LPe2O2eZvKYlo2CT2WslWC2

#

?

jade mango
#

It would be included in your Payment Intent

silver cradle
#

ok

#

will we get from android sdk?

jade mango
#

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?

silver cradle
#

we are using payment intent to create payment order

#

then we pass that response in android sdk

jade mango
#

Yeah so what are the exact calls you're making client-side?

jade mango
#

๐Ÿ‘ So I assume you want the Payment Method/Card brand as soon as the Payment is complete client-side, right?

silver cradle
#

yes

jade mango
#

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

silver cradle
jade mango
#

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)

silver cradle
#

yes after completing payment, we need to fetch card type in backend.

#

how can we retrieve the Payment Intent + Payment Method

jade mango
#

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

silver cradle
#

ok

#

As we are using standard payment sheet, will stripe automatically create payment method

faint wave
#

Yes. Once the payment details are collected, a payment method is created

silver cradle
#

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?

faint wave
#

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.

silver cradle
#

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,

faint wave
#

What are you using the Payment Method ID for?

silver cradle
#

to get the card type

#

of that specific transaction

#

our motive is to get the card brand type for that particular transaction

faint wave
#

And do you want it before payment or after payment?

silver cradle
#

after payment success and need to fetch from backend

faint wave
#

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

silver cradle
faint wave
#

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

silver cradle
#

expand the payment_method

i didn't understand this

#

means what should we do ?

faint wave
#

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

silver cradle
#

ok,

#

to expand card has which parameter should we pass ?

#

*hash

faint wave
#

payment_method is the thing you're trying to expand right? So pass payment_method

silver cradle
#

/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

faint wave
#

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.

silver cradle
#

ok

#

ID means payment intent ID right ?

faint wave
#

Correct

silver cradle
#

ok

#

can you please share a correct format or complete code for reference ?

faint wave
#

There are a few examples in the docs I sent you. I cannot write the expand call for you unfortunately

silver cradle
#

ok