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

NPE in the BinLookupRepository

Open christianfindsen opened this issue 3 years ago • 2 comments

Describe the bug We have just upgrade from checkout v3.8.x to v4.4.0 and after that we saw crashes in production. Below is the stacktrace.

Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'java.lang.String com.adyen.checkout.card.data.CardType.getTxVariant()' on a null object reference

After some investigation I narrowed it down to the supportedCardTypes we are passing into the cardConfigurationBuilder. We are getting a list from the backend containing the supported cardTypes and we are then parsing them into a CardType() with the CardType.getByBrandName() and passing it into an array and passing into the builder.

When the user starts to write their cardDetails the app crashes as it is trying to call Adyen with a null CardType.

In the previous version there were a check before the call to Adyen but on the v4.x.x it is now an unchecked call.

The workaround has been to do the check on our side before passing it to the cardConfigurationBuilder.

To Reproduce Steps to reproduce the behavior:

  1. Add GiroCard as a supported payment card
  2. Add it as a CardType.getbyBrandName()
  3. Start writing cardDetails
  4. See error

Expected behavior Not crashing but filter out the null as in previous versions

christianfindsen avatar Jan 17 '22 11:01 christianfindsen

Thx a lot for the detailed investigation and report! We will look into fixing this for the next release.

caiofaustino avatar Jan 17 '22 12:01 caiofaustino

Hi @christianfindsen! Can you share the full stacktrace of the exception so we can investigate in more detail?

ozgur00 avatar Feb 04 '22 13:02 ozgur00

Closing for inactivity, please reopen this issue if you are still experiencing problems.

jreij avatar Sep 29 '22 08:09 jreij

Hi again @christianfindsen , this is quite an old thread so might be irrelevant now but we think that the latest release might have fixed this.

CardType.getbyBrandName() was indeed not behaving as expected so we added a new way to specify supported card brands which are not part of the CardType enum class, using the CardBrand class.

So suppose you want to support mastercard and giro card you could do this:

CardConfiguration.Builder(...)
    .setSupportedCardTypes(CardBrand("GIRO_TX_VARIANT"), CardBrand(CardType.MASTERCARD))
    .build()

jreij avatar Feb 16 '23 14:02 jreij