Adyen / adyen-android

Adyen Android Drop-in and Components
https://docs.adyen.com/checkout/android
MIT License
126 stars 66 forks source link

[NEED ASSIST] Getting first and last 4 digits of card number in Drop-in component #1790

Closed marioamgad9 closed 1 month ago

marioamgad9 commented 1 month ago

Background

In our app, we're trying to implement a pre-auth fraud detection tool. In order to do that, we need to pass the BIN and last 4 digits to it to do its thing.

Problem

I've tried reading the documentation and searching everywhere for this, but couldn't find a way to do it. On iOS, we use cardComponentDelegate to listen for BIN and last 4 digits.

Is there an equivilant to this on Android? If so can you please refer me to documentation where this is mentioned?

OscarSpruit commented 1 month ago

Hi @marioamgad9, thank you for your question! There are a few ways to get this data depending on your integration. Are you using drop-in or components? And at what point in time do you need this data? For example, when the pay button is clicked or right away while the user is typing.

marioamgad9 commented 1 month ago

Hi @OscarSpruit, thanks for the quick response.

Are you using drop-in or components?

We're using drop-in.

at what point in time do you need this data?

To be honest, it doesn't really matter. We can pass it when the button is clicked or listen for it. The simplest solution would be the preferred one in this case.

OscarSpruit commented 1 month ago

@marioamgad9 for drop-in the easiest way is to use the onSubmit callback of your implementation of DropInService. Here you will get CardComponentState which contains the binValue and lastFourDigits fields

marioamgad9 commented 1 month ago

Hi @OscarSpruit,

I found an issue with this implementation and was hoping you can help us with it.

This works perfectly when submitting a payment with a card, but doesn't work if the card was saved. Is this behavior intentional? And if so, is there a way to get the BIN and last four digits when the user submits a payment with a saved card?

OscarSpruit commented 1 month ago

@marioamgad9 unfortunately, for saved cards we don't have access to the BIN due to tokenisation. However, the lastFourDigits should still be available and cardBrand is also available (might be useful depending on what you need the BIN for).