adyen-ios icon indicating copy to clipboard operation
adyen-ios copied to clipboard

[BUG] CardType detection is not working as expected

Open sumitbansalcse opened this issue 1 year ago • 5 comments

Describe the bug

CardType detection is not working as expected. Any Visa card with limit 16 digits is detected as CarteBancaire and Visa. Or we can say any card that starts with 4,5,6 with limit upto 16 digits is detected as CarteBancaire even if it is not. I've tried all the test cards provided on your portal , plus I've tried all my personal cards as well

A clear and concise description of what the bug is. Any credit/dedit card that starts with 4,5,6 with limit upto 16 digits is detected as CarteBancaire even if it is not. I've tried all the test cards provided on your portal , plus I've tried all my personal cards as well.

To Reproduce Steps to reproduce the behavior: Call your below method with any relevant card number starts with 4,5,6, it will detect it as CarteBancaire.

func types(forCardNumber cardNumber: String) -> [CardType] { base.filter { $0.matches(cardNumber: cardNumber) } }

Expected behavior It should check the bin and return relevant card type. you should update your carteBancaire regex from "^[4-6][0-9]{0,15}$" to something more specific and relevant

Relevant source code func types(forCardNumber cardNumber: String) -> [CardType] { base.filter { $0.matches(cardNumber: cardNumber) } }

Additional context Update carteBancaire regex from "^[4-6][0-9]{0,15}$" to something more specific and relevant

sumitbansalcse avatar Jan 31 '24 07:01 sumitbansalcse

@sumitbansalcse thanks for the find! We will look into improving its regex. However please note that the SDK side detection is not to be used for accuracy, it's an estimate and fallback until the binlookup call detects the card more accurately.

What issue exactly are you facing? The SDK should detect the card correctly when binlookup call is triggered. I tested with the cards from our test cards page and binlookup call returns correctly for them.

erenbesel avatar Jan 31 '24 10:01 erenbesel

@erenbesel : Thanks for your commitment regarding improving the regex. Can you please tell about the ETA for this change?

Secondly, regarding binlookup method, I can see it is an internal function in your SDK. Is there any example/reference code you have to implement that binlookup method call which we can use directly in our code?

sumitbansalcse avatar Feb 01 '24 05:02 sumitbansalcse

Hey @sumitbansalcse can't share any ETA yet but could you tell me your use case as to why you may need this function? It's an internal call not to be used by developers. The card component will call the internal bin lookup and get the correct brand logo after 11 digits are entered.

There is also the external counterpart of this call if you are using API only approach

erenbesel avatar Feb 02 '24 10:02 erenbesel

We are using API only integration. We want to detect the card type and show the relevant logo to the end user. As the user enter the card details, using this below method, we update the card type logos.

func types(forCardNumber cardNumber: String) -> [CardType] { base.filter { $0.matches(cardNumber: cardNumber) } }

But as I mentioned in the first place, It is detecting all the cards as CarteBancaire which starts with 4,5,6 and less than 16 digits.

sumitbansalcse avatar Feb 08 '24 11:02 sumitbansalcse

Hey @sumitbansalcse sorry for missing this.

As I mentioned above, the function you refer to is not meant for external use (it's @spi_internal for use between Adyen SDK modules). We don't recommend using SDK's internal functions as they are subject to change.

There is an actual endpoint that will return you most accurate results, we recommend using it.

erenbesel avatar Feb 28 '24 13:02 erenbesel