Skip to content

Commit

Permalink
Merge pull request #1811 from Adyen/feature/public_validators
Browse files Browse the repository at this point in the history
Expose card input field validation functionality to public
  • Loading branch information
ozgur00 authored Oct 10, 2024
2 parents d8c6f59 + 90d44ed commit 40c3a26
Show file tree
Hide file tree
Showing 66 changed files with 1,392 additions and 930 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Up. Payment method type: **mealVoucher_FR_groupeup**.
- Natixis. Payment method type: **mealVoucher_FR_natixis**.
- Sodexo. Payment method type: **mealVoucher_FR_sodexo**.
- For API only merchants, `CardNumberValidator`, `CardExpiryDateValidator` and `CardSecurityCodeValidator` classes are added to make validation functionality for the corresponding fields available to public.
- For Twint, storing payment details and paying with them is now supported. See the documentation [here](/docs/payment-methods/TWINT.md).
- You can now use [Adyen Test Cards Android](https://github.com/Adyen/adyen-testcards-android) to prefill test payment method information, making testing your integration easier.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ package com.adyen.checkout.bcmc.internal.ui.model

import com.adyen.checkout.bcmc.BcmcConfiguration
import com.adyen.checkout.bcmc.getBcmcConfiguration
import com.adyen.checkout.card.CardBrand
import com.adyen.checkout.card.CardType
import com.adyen.checkout.card.KCPAuthVisibility
import com.adyen.checkout.card.SocialSecurityNumberVisibility
import com.adyen.checkout.card.internal.ui.model.CVCVisibility
Expand All @@ -23,6 +21,8 @@ import com.adyen.checkout.components.core.internal.ui.model.CommonComponentParam
import com.adyen.checkout.components.core.internal.ui.model.CommonComponentParamsMapper
import com.adyen.checkout.components.core.internal.ui.model.DropInOverrideParams
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.core.CardBrand
import com.adyen.checkout.core.CardType
import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
import java.util.Locale

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ package com.adyen.checkout.bcmc.internal.ui.model

import com.adyen.checkout.bcmc.BcmcConfiguration
import com.adyen.checkout.bcmc.bcmc
import com.adyen.checkout.card.CardBrand
import com.adyen.checkout.card.CardType
import com.adyen.checkout.card.KCPAuthVisibility
import com.adyen.checkout.card.SocialSecurityNumberVisibility
import com.adyen.checkout.card.internal.ui.model.CVCVisibility
Expand All @@ -29,6 +27,8 @@ import com.adyen.checkout.components.core.internal.ui.model.CommonComponentParam
import com.adyen.checkout.components.core.internal.ui.model.DropInOverrideParams
import com.adyen.checkout.components.core.internal.ui.model.SessionInstallmentConfiguration
import com.adyen.checkout.components.core.internal.ui.model.SessionParams
import com.adyen.checkout.core.CardBrand
import com.adyen.checkout.core.CardType
import com.adyen.checkout.core.Environment
import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
import org.junit.jupiter.api.Assertions.assertEquals
Expand Down
109 changes: 18 additions & 91 deletions card/api/card.api
Original file line number Diff line number Diff line change
Expand Up @@ -161,34 +161,6 @@ public final class com/adyen/checkout/card/BuildConfig {
public fun <init> ()V
}

public final class com/adyen/checkout/card/CardBrand : android/os/Parcelable {
public static final field CREATOR Landroid/os/Parcelable$Creator;
public static final field Companion Lcom/adyen/checkout/card/CardBrand$Companion;
public fun <init> (Lcom/adyen/checkout/card/CardType;)V
public fun <init> (Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;)Lcom/adyen/checkout/card/CardBrand;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/CardBrand;Ljava/lang/String;ILjava/lang/Object;)Lcom/adyen/checkout/card/CardBrand;
public fun describeContents ()I
public fun equals (Ljava/lang/Object;)Z
public final fun getTxVariant ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public fun writeToParcel (Landroid/os/Parcel;I)V
}

public final class com/adyen/checkout/card/CardBrand$Companion {
public final fun estimate (Ljava/lang/String;)Ljava/util/List;
}

public final class com/adyen/checkout/card/CardBrand$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/adyen/checkout/card/CardBrand;
public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
public final fun newArray (I)[Lcom/adyen/checkout/card/CardBrand;
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public class com/adyen/checkout/card/CardComponent : androidx/lifecycle/ViewModel, com/adyen/checkout/action/core/internal/ActionHandlingComponent, com/adyen/checkout/components/core/internal/AddressLookupComponent, com/adyen/checkout/components/core/internal/ButtonComponent, com/adyen/checkout/components/core/internal/PaymentComponent, com/adyen/checkout/ui/core/internal/ui/ViewableComponent {
public static final field Companion Lcom/adyen/checkout/card/CardComponent$Companion;
public static final field PAYMENT_METHOD_TYPES Ljava/util/List;
Expand All @@ -215,18 +187,18 @@ public final class com/adyen/checkout/card/CardComponent$Companion {
}

public final class com/adyen/checkout/card/CardComponentState : com/adyen/checkout/components/core/PaymentComponentState {
public fun <init> (Lcom/adyen/checkout/components/core/PaymentComponentData;ZZLcom/adyen/checkout/card/CardBrand;Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (Lcom/adyen/checkout/components/core/PaymentComponentData;ZZLcom/adyen/checkout/core/CardBrand;Ljava/lang/String;Ljava/lang/String;)V
public final fun component1 ()Lcom/adyen/checkout/components/core/PaymentComponentData;
public final fun component2 ()Z
public final fun component3 ()Z
public final fun component4 ()Lcom/adyen/checkout/card/CardBrand;
public final fun component4 ()Lcom/adyen/checkout/core/CardBrand;
public final fun component5 ()Ljava/lang/String;
public final fun component6 ()Ljava/lang/String;
public final fun copy (Lcom/adyen/checkout/components/core/PaymentComponentData;ZZLcom/adyen/checkout/card/CardBrand;Ljava/lang/String;Ljava/lang/String;)Lcom/adyen/checkout/card/CardComponentState;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/CardComponentState;Lcom/adyen/checkout/components/core/PaymentComponentData;ZZLcom/adyen/checkout/card/CardBrand;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/adyen/checkout/card/CardComponentState;
public final fun copy (Lcom/adyen/checkout/components/core/PaymentComponentData;ZZLcom/adyen/checkout/core/CardBrand;Ljava/lang/String;Ljava/lang/String;)Lcom/adyen/checkout/card/CardComponentState;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/CardComponentState;Lcom/adyen/checkout/components/core/PaymentComponentData;ZZLcom/adyen/checkout/core/CardBrand;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/adyen/checkout/card/CardComponentState;
public fun equals (Ljava/lang/Object;)Z
public final fun getBinValue ()Ljava/lang/String;
public final fun getCardBrand ()Lcom/adyen/checkout/card/CardBrand;
public final fun getCardBrand ()Lcom/adyen/checkout/core/CardBrand;
public fun getData ()Lcom/adyen/checkout/components/core/PaymentComponentData;
public final fun getLastFourDigits ()Ljava/lang/String;
public fun hashCode ()I
Expand Down Expand Up @@ -276,8 +248,8 @@ public final class com/adyen/checkout/card/CardConfiguration$Builder : com/adyen
public final fun setSocialSecurityNumberVisibility (Lcom/adyen/checkout/card/SocialSecurityNumberVisibility;)Lcom/adyen/checkout/card/CardConfiguration$Builder;
public fun setSubmitButtonVisible (Z)Lcom/adyen/checkout/card/CardConfiguration$Builder;
public synthetic fun setSubmitButtonVisible (Z)Lcom/adyen/checkout/components/core/internal/ButtonConfigurationBuilder;
public final fun setSupportedCardTypes ([Lcom/adyen/checkout/card/CardBrand;)Lcom/adyen/checkout/card/CardConfiguration$Builder;
public final fun setSupportedCardTypes ([Lcom/adyen/checkout/card/CardType;)Lcom/adyen/checkout/card/CardConfiguration$Builder;
public final fun setSupportedCardTypes ([Lcom/adyen/checkout/core/CardBrand;)Lcom/adyen/checkout/card/CardConfiguration$Builder;
public final fun setSupportedCardTypes ([Lcom/adyen/checkout/core/CardType;)Lcom/adyen/checkout/card/CardConfiguration$Builder;
}

public final class com/adyen/checkout/card/CardConfiguration$Companion {
Expand All @@ -297,51 +269,6 @@ public final class com/adyen/checkout/card/CardConfigurationKt {
public static synthetic fun card$default (Lcom/adyen/checkout/components/core/CheckoutConfiguration;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/adyen/checkout/components/core/CheckoutConfiguration;
}

public final class com/adyen/checkout/card/CardType : java/lang/Enum {
public static final field AMERICAN_EXPRESS Lcom/adyen/checkout/card/CardType;
public static final field ARGENCARD Lcom/adyen/checkout/card/CardType;
public static final field BCMC Lcom/adyen/checkout/card/CardType;
public static final field BIJENKORF_CARD Lcom/adyen/checkout/card/CardType;
public static final field CABAL Lcom/adyen/checkout/card/CardType;
public static final field CARTEBANCAIRE Lcom/adyen/checkout/card/CardType;
public static final field CODENSA Lcom/adyen/checkout/card/CardType;
public static final field CUP Lcom/adyen/checkout/card/CardType;
public static final field Companion Lcom/adyen/checkout/card/CardType$Companion;
public static final field DANKORT Lcom/adyen/checkout/card/CardType;
public static final field DINERS Lcom/adyen/checkout/card/CardType;
public static final field DISCOVER Lcom/adyen/checkout/card/CardType;
public static final field ELO Lcom/adyen/checkout/card/CardType;
public static final field FORBRUGSFORENINGEN Lcom/adyen/checkout/card/CardType;
public static final field HIPER Lcom/adyen/checkout/card/CardType;
public static final field HIPERCARD Lcom/adyen/checkout/card/CardType;
public static final field JCB Lcom/adyen/checkout/card/CardType;
public static final field KARENMILLER Lcom/adyen/checkout/card/CardType;
public static final field LASER Lcom/adyen/checkout/card/CardType;
public static final field MAESTRO Lcom/adyen/checkout/card/CardType;
public static final field MAESTRO_UK Lcom/adyen/checkout/card/CardType;
public static final field MASTERCARD Lcom/adyen/checkout/card/CardType;
public static final field MCALPHABANKBONUS Lcom/adyen/checkout/card/CardType;
public static final field MIR Lcom/adyen/checkout/card/CardType;
public static final field NARANJA Lcom/adyen/checkout/card/CardType;
public static final field OASIS Lcom/adyen/checkout/card/CardType;
public static final field SHOPPING Lcom/adyen/checkout/card/CardType;
public static final field SOLO Lcom/adyen/checkout/card/CardType;
public static final field TROY Lcom/adyen/checkout/card/CardType;
public static final field UATP Lcom/adyen/checkout/card/CardType;
public static final field VISA Lcom/adyen/checkout/card/CardType;
public static final field VISAALPHABANKBONUS Lcom/adyen/checkout/card/CardType;
public static final field VISADANKORT Lcom/adyen/checkout/card/CardType;
public static final field WAREHOUSE Lcom/adyen/checkout/card/CardType;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getTxVariant ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lcom/adyen/checkout/card/CardType;
public static fun values ()[Lcom/adyen/checkout/card/CardType;
}

public final class com/adyen/checkout/card/CardType$Companion {
public final fun getByBrandName (Ljava/lang/String;)Lcom/adyen/checkout/card/CardType;
}

public final class com/adyen/checkout/card/InstallmentConfiguration : android/os/Parcelable {
public static final field CREATOR Landroid/os/Parcelable$Creator;
public fun <init> ()V
Expand Down Expand Up @@ -378,16 +305,16 @@ public abstract class com/adyen/checkout/card/InstallmentOptions : android/os/Pa

public final class com/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions : com/adyen/checkout/card/InstallmentOptions {
public static final field CREATOR Landroid/os/Parcelable$Creator;
public fun <init> (IZLcom/adyen/checkout/card/CardBrand;)V
public fun <init> (Ljava/util/List;ZLcom/adyen/checkout/card/CardBrand;)V
public fun <init> (IZLcom/adyen/checkout/core/CardBrand;)V
public fun <init> (Ljava/util/List;ZLcom/adyen/checkout/core/CardBrand;)V
public final fun component1 ()Ljava/util/List;
public final fun component2 ()Z
public final fun component3 ()Lcom/adyen/checkout/card/CardBrand;
public final fun copy (Ljava/util/List;ZLcom/adyen/checkout/card/CardBrand;)Lcom/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions;Ljava/util/List;ZLcom/adyen/checkout/card/CardBrand;ILjava/lang/Object;)Lcom/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions;
public final fun component3 ()Lcom/adyen/checkout/core/CardBrand;
public final fun copy (Ljava/util/List;ZLcom/adyen/checkout/core/CardBrand;)Lcom/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions;Ljava/util/List;ZLcom/adyen/checkout/core/CardBrand;ILjava/lang/Object;)Lcom/adyen/checkout/card/InstallmentOptions$CardBasedInstallmentOptions;
public fun describeContents ()I
public fun equals (Ljava/lang/Object;)Z
public final fun getCardBrand ()Lcom/adyen/checkout/card/CardBrand;
public final fun getCardBrand ()Lcom/adyen/checkout/core/CardBrand;
public fun getIncludeRevolving ()Z
public fun getValues ()Ljava/util/List;
public fun hashCode ()I
Expand Down Expand Up @@ -565,14 +492,14 @@ public final class com/adyen/checkout/card/internal/ui/DefaultCardDelegate$Compa
}

public final class com/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions : com/adyen/checkout/card/internal/ui/model/InstallmentOptionParams {
public fun <init> (Ljava/util/List;ZLcom/adyen/checkout/card/CardBrand;)V
public fun <init> (Ljava/util/List;ZLcom/adyen/checkout/core/CardBrand;)V
public final fun component1 ()Ljava/util/List;
public final fun component2 ()Z
public final fun component3 ()Lcom/adyen/checkout/card/CardBrand;
public final fun copy (Ljava/util/List;ZLcom/adyen/checkout/card/CardBrand;)Lcom/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions;Ljava/util/List;ZLcom/adyen/checkout/card/CardBrand;ILjava/lang/Object;)Lcom/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions;
public final fun component3 ()Lcom/adyen/checkout/core/CardBrand;
public final fun copy (Ljava/util/List;ZLcom/adyen/checkout/core/CardBrand;)Lcom/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions;
public static synthetic fun copy$default (Lcom/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions;Ljava/util/List;ZLcom/adyen/checkout/core/CardBrand;ILjava/lang/Object;)Lcom/adyen/checkout/card/internal/ui/model/InstallmentOptionParams$CardBasedInstallmentOptions;
public fun equals (Ljava/lang/Object;)Z
public final fun getCardBrand ()Lcom/adyen/checkout/card/CardBrand;
public final fun getCardBrand ()Lcom/adyen/checkout/core/CardBrand;
public fun getIncludeRevolving ()Z
public fun getValues ()Ljava/util/List;
public fun hashCode ()I
Expand Down
35 changes: 5 additions & 30 deletions card/src/main/java/com/adyen/checkout/card/CardBrand.kt
Original file line number Diff line number Diff line change
@@ -1,38 +1,13 @@
/*
* Copyright (c) 2019 Adyen N.V.
* Copyright (c) 2024 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by arman on 16/9/2019.
* Created by ozgur on 8/10/2024.
*/
package com.adyen.checkout.card

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
* This class represents a card scheme. The constructor allows for creating a [CardBrand] with a scheme that is not in
* the predefined list of [CardType]. Can be used to configure the supported card schemes with
* [CardConfiguration.Builder.setSupportedCardTypes].
*/
@Parcelize
data class CardBrand constructor(val txVariant: String) : Parcelable {
package com.adyen.checkout.card

/**
* Use this constructor when defining the supported card brand predefined inside [CardType] enum
* inside your component
*/
constructor(cardType: CardType) : this(txVariant = cardType.txVariant)
import com.adyen.checkout.core.CardBrand

companion object {
/**
* Estimate all potential [CardBrands][CardBrand] for a given card number.
*
* @param cardNumber The potential card number.
* @return All matching [CardBrands][CardBrand] if the number was valid, otherwise an empty [List].
*/
fun estimate(cardNumber: String): List<CardBrand> {
return CardType.values().filter { it.isEstimateFor(cardNumber) }.map { CardBrand(cardType = it) }
}
}
}
typealias CardBrand = CardBrand
Loading

0 comments on commit 40c3a26

Please sign in to comment.