Class MeaTokenPlatform


  • public final class MeaTokenPlatform
    extends java.lang.Object
    Provides API for interaction with the MeaTokenPlatform library using static methods.
    • Method Detail

      • initialize

        public static void initialize​(@NonNull
                                      android.content.Context context)
                               throws InitializationFailedException
        Initializes the MeaTokenPlatform library. It is required to call this method before interacting with any other of the MeaTokenPlatform API's.
        Parameters:
        context - The Application Context.
        Throws:
        InitializationFailedException - if the library initialization fails. Use MeaCheckedException.getErrorCode() to get failure reason error code.
      • initialize

        public static void initialize​(@NonNull
                                      android.content.Context context,
                                      @Nullable
                                      MeaListener listener)
        Initializes the MeaTokenPlatform library, initialization is done on a background thread. It is required to call this method before interacting with any other of the MeaTokenPlatform API's.

        Event callbacks are invoked on the Main / UI thread after the initialization on background thread finishes.

        Parameters:
        context - The Application Context.
        listener - The listener as MeaListener interface.
      • isInitialized

        public static boolean isInitialized()
        Indicates whether the MeaTokenPlatform library has been initialized.
        Returns:
        true if initialized, false if not initialized.
      • register

        public static void register​(@NonNull
                                    java.lang.String pushServiceInstanceIdToken,
                                    @NonNull
                                    java.lang.String consumerLanguage,
                                    @Nullable
                                    MeaListener listener)
        Checks device eligibility and registers app to Wallet Service Provider. Device eligibility check includes whether or not the device is a Mastercard type-approved device, hardware and software compatibility and any applicable Issuer policies related to the device.
        Parameters:
        pushServiceInstanceIdToken - Remote Notification Service ID to be used to deliver credentials to the target application instance.
        consumerLanguage - Language preference selected by the consumer. Formatted as an ISO-639-1 two-letter language code. Length 2.
        listener - The listener as MeaListener interface.
      • initializeAdditionalAuthenticationForDigitization

        public static void initializeAdditionalAuthenticationForDigitization​(@NonNull
                                                                             java.lang.String cardId,
                                                                             @NonNull
                                                                             java.lang.String authenticationMethodId,
                                                                             @Nullable
                                                                             MeaListener listener)
        In situations where the Issuer is not sure about users presences during digitization, the Issuer can choose to request additional authentication. Method requests an 'Activation Code' to be sent to authenticate the Card Holder. This can be done for any Authentication Method involving a user-entered Authentication Code.

        When additional authentication is initialized, MeaCardYellowPathState is set to MeaCardYellowPathState.AUTHENTICATION_INITIALIZED.

        Parameters:
        cardId - Card Id (Token Unique Reference).
        authenticationMethodId - ID of the Authentication Method selected by the user.
        listener - The listener as MeaListener interface.
      • getAsset

        public static void getAsset​(@NonNull
                                    java.lang.String assetId,
                                    @Nullable
                                    MeaGetAssetListener listener)
        Gets static Assets from MDESs and VTSs repositories, such as: Card art, Brand logos, Issuers logos, Terms and Conditions. Every Asset in the repository is referenced using an Asset ID. Once an Asset has been assigned to an Asset ID, the contents of the Asset will not change.
        Parameters:
        assetId - Asset ID value used to reference an Asset.
        listener - The listener as MeaGetAssetListener interface.
      • isRegistered

        public static boolean isRegistered()
                                    throws NotInitializedException
        Checks if application instance is registered with wallet server.
        Returns:
        Mea Token Platform registration status value as Boolean.
        Throws:
        NotInitializedException - if library is not initialized.
      • markAllCardsForDeletion

        public static void markAllCardsForDeletion​(@Nullable
                                                   MeaListener listener)
        Changes all cards states to MeaCardState.MARKED_FOR_DELETION and schedules card deletion job. When network connection will be available card deletion job will be executed and all cards with state MeaCardState.MARKED_FOR_DELETION will be deleted.
        Parameters:
        listener - The listener as MeaListener interface, success callback is invoked when cards are marked for deletion.
      • deleteAllCards

        public static void deleteAllCards​(@Nullable
                                          MeaListener listener)
        Delete all cards, network has to be available when invoke this method.
        Parameters:
        listener - The listener as MeaListener interface, success callback is invoked when cards are deleted both remotely and from local storage.
      • isDefaultPaymentApplication

        public static boolean isDefaultPaymentApplication​(@NonNull
                                                          android.content.Context context)
        Check if the application is set as default application for payments.
        Parameters:
        context - Context instance
        Returns:
        True/False if the application is set as default application for payments.
      • setDefaultPaymentApplication

        public static void setDefaultPaymentApplication​(@NonNull
                                                        android.app.Activity activity,
                                                        int requestCode)
        Starts Android system activity to set default application for payments.
        Parameters:
        activity - Calling activity.
        requestCode - Request Code to be used in onActivityResult.
      • setAuthenticationListener

        public static void setAuthenticationListener​(@Nullable
                                                     MeaAuthenticationListener listener)
        Sets cardholder authentication listener class from the wallet level.
        Parameters:
        listener - Authentication callback listener.
      • removeAuthenticationListener

        public static void removeAuthenticationListener()
        Removes cardholder authentication listener.
      • requestCardholderAuthentication

        public static void requestCardholderAuthentication()
                                                    throws NotInitializedException
        Requests cardholder authentication. This can be called before or during the transaction to determine the correct authentication. This method will trigger one of MeaAuthenticationListener method callbacks.
        Throws:
        NotInitializedException - if library is not initialized.
      • registerDeviceUnlockReceiver

        public static void registerDeviceUnlockReceiver()
                                                 throws NotInitializedException,
                                                        MeaException
        Starts android service which registers BroadcastReceiver to detect ACTION_USER_PRESENT (device unlock) broadcast intent, required only for wallets using device unlock authentication.

        Starting from Android 8.0 or higher apps can no longer register broadcast receivers for implicit broadcasts (ACTION_USER_PRESENT) in the Android Manifest, apps have to register receiver at runtime to receive broadcast.

        Service should be started in app activity onResume() method, because starting from Android 8.0 service can be stopped even if app its self is not stopped.

        Throws:
        NotInitializedException - if library is not initialized.
        MeaException - if any other error occurred while processing method.
      • authenticateWithDeviceUnlock

        public static void authenticateWithDeviceUnlock()
                                                 throws NotInitializedException
        Informs MTP library that user was successfully authenticated using Device Unlock method.
        Throws:
        NotInitializedException - if library is not initialized.
      • authenticateWithWalletPin

        public static void authenticateWithWalletPin​(@NonNull
                                                     java.lang.String pin,
                                                     @Nullable
                                                     MeaWalletPinAuthenticationListener listener)
        Authenticate user for payment using wallet PIN.
        Parameters:
        pin - Wallet PIN.
        listener - Wallet PIN authentication listener.
      • authenticateWithFingerprint

        public static void authenticateWithFingerprint​(@NonNull
                                                       android.app.FragmentManager fragmentManager,
                                                       @Nullable
                                                       MeaListener listener)
        Authenticate user for payment using biometric (fingerprint) authentication
        Parameters:
        fragmentManager - Fragment manager - used to show fingerprint dialog fragment.
        listener - Listen for fingerprint authentication results.
      • clearAuthenticationForPayment

        public static void clearAuthenticationForPayment()
                                                  throws NotInitializedException
        Resets the current authentication state. If authentication was previously granted, this will remove it.
        Throws:
        NotInitializedException - if library is not initialized.
      • delete

        public static void delete​(@Nullable
                                  MeaListener listener)
        Deletes all local MTP storage files.
        Parameters:
        listener - MeaListener object instance.
      • removeCardProvisionListener

        public static void removeCardProvisionListener()
        Removes cards provision listener.
      • setCardReplenishListener

        public static void setCardReplenishListener​(@Nullable
                                                    MeaCardReplenishListener listener)
        Sets listener to receive card replenish payment tokens events.
        Parameters:
        listener - MeaCardReplenishListener listener
      • removeCardReplenishListener

        public static void removeCardReplenishListener()
        Removes card replenish payment tokens listener.
      • removeDigitizedCardStateChangeListener

        public static void removeDigitizedCardStateChangeListener()
        Removes digitized card state change listener.
      • removeDeleteStorageDirectoryListener

        public static void removeDeleteStorageDirectoryListener()
        Removes delete storage directory listener.
      • setWalletPinListener

        public static void setWalletPinListener​(@Nullable
                                                MeaWalletPinListener listener)
        Sets listener to receive wallet PIN events.
        Parameters:
        listener - Wallet PIN listener as MeaWalletPinListener interface.
      • removeWalletPinListener

        public static void removeWalletPinListener()
        Removes wallet PIN reset event listener.
      • clearListeners

        public static void clearListeners()
        Remove all library listeners, including all card listeners.
      • registerTransactionReceiver

        public static void registerTransactionReceiver​(android.content.Context context,
                                                       MeaTransactionReceiver transactionReceiver)
        Registers BroadcastReceiver to allow the application to react to the transaction events even when it is not in the foreground. The MTP library contains abstract MeaTransactionReceiver helper class, which application developers should extend and override abstract methods to simplify intent data handling.
        Parameters:
        context - Context instance
        transactionReceiver - instance of class extending MeaTransactionReceiver
      • registerPinRequestReceiver

        public static void registerPinRequestReceiver​(android.content.Context context,
                                                      MeaPinRequestReceiver pinRequestReceiver)
        Registers BroadcastReceiver to handle request for PIN reset or change events. The MTP library contains abstract MeaPinRequestReceiver helper class, which application developers should extend and override abstract methods to listen for events.
        Parameters:
        context - Context instance
        pinRequestReceiver - instance of class extending MeaPinRequestReceiver
      • unregisterTransactionReceiver

        public static void unregisterTransactionReceiver​(android.content.Context context,
                                                         MeaTransactionReceiver transactionReceiver)
        Unregisters previously registered MeaTransactionReceiver from listening transaction events.
        Parameters:
        context - Context instance
        transactionReceiver - instance of class extending MeaTransactionReceiver
      • unregisterPinRequestReceiver

        public static void unregisterPinRequestReceiver​(android.content.Context context,
                                                        MeaPinRequestReceiver pinRequestReceiver)
        Unregisters previously registered MeaPinRequestReceiver from listening request for PIN reset or change events.
        Parameters:
        context - Context instance
        pinRequestReceiver - instance of class extending MeaPinRequestReceiver
      • setAllowPaymentsWhenLocked

        public static void setAllowPaymentsWhenLocked​(boolean enabled)
                                               throws NotInitializedException,
                                                      MeaDeviceLockedException
        Change the allow payments when phone is locked setting (disabled by default). If this is enabled, payments which do not require on-device authentication can be performed even if the screen is locked.

        Although this has no impact in device state when the screen of the device is turned off, because current Android implementations turn the NFC controller and the application processor off completely.

        Parameters:
        enabled - value for contactless payment availability when device screen is locked as Boolean.
        Throws:
        NotInitializedException - if library is not initialized.
        MeaDeviceLockedException - if device is locked.
      • getAllowPaymentsWhenLocked

        public static boolean getAllowPaymentsWhenLocked()
                                                  throws NotInitializedException
        Return current value of allow payments when phone is locked setting.
        Returns:
        value for contactless payment availability when device screen is locked as Boolean.
        Throws:
        NotInitializedException - if library is not initialized.
      • updateDeviceInfo

        public static void updateDeviceInfo​(@Nullable
                                            java.lang.String pushServiceInstanceIdToken,
                                            @Nullable
                                            java.lang.String consumerLanguage,
                                            @Nullable
                                            MeaListener listener)
        Updates device information after registration, for example when Remote Notification Service token is refreshed.
        Parameters:
        pushServiceInstanceIdToken - Remote Notification Service ID to be used to deliver credentials to the target application instance.
        consumerLanguage - Language preference selected by the consumer. Formatted as an ISO-639-1 two-letter language code. Length 2.
        listener - The listener as MeaListener interface.
      • isSecureNfcSupported

        public static boolean isSecureNfcSupported()
                                            throws NotInitializedException
        Checks if the device supports Secure NFC functionality.
        Returns:
        boolean True if device supports Secure NFC, false otherwise
        Throws:
        NotInitializedException - if library is not initialized.
      • isSecureNfcEnabled

        public static boolean isSecureNfcEnabled()
                                          throws NotInitializedException
        Checks Secure NFC feature is enabled.
        Returns:
        boolean True if Secure NFC is enabled, false otherwise
        Throws:
        NotInitializedException - if library is not initialized.
      • openSecureNfcSettings

        public static void openSecureNfcSettings​(@NonNull
                                                 android.app.Activity activity)
        Starts Android system activity to change Secure NFC settings.
        Parameters:
        activity - Calling activity.
      • setAccessToken

        public static void setAccessToken​(@Nullable
                                          java.lang.String accessToken)
        Sets access token value.
        Parameters:
        accessToken - access token value as String.
      • addTransactionLimit

        public static void addTransactionLimit​(@NonNull
                                               MeaTransactionLimit transactionLimit,
                                               @Nullable
                                               MeaListener listener)
        Add or update currency transaction limit.
        Parameters:
        transactionLimit - Transaction limit.
        listener - The listener as MeaListener interface.
      • addTransactionLimits

        public static void addTransactionLimits​(@NonNull
                                                java.util.List<MeaTransactionLimit> transactionLimits,
                                                @Nullable
                                                MeaListener listener)
        Add or update multiple currency transaction limits.
        Parameters:
        transactionLimits - Transaction limits.
        listener - The listener as MeaListener interface.
      • getTransactionLimit

        @Nullable
        public static MeaTransactionLimit getTransactionLimit​(@NonNull
                                                              java.util.Currency currency)
                                                       throws NotInitializedException
        Get transaction limit for the currency.
        Parameters:
        currency - Currency as instance of Currency object to get limit for.
        Returns:
        The transaction limit as instance of MeaTransactionLimit object.
        Throws:
        NotInitializedException - if library is not initialized.
      • removeTransactionLimit

        public static void removeTransactionLimit​(@NonNull
                                                  java.util.Currency currency,
                                                  @Nullable
                                                  MeaListener listener)
        Remove transaction limit for the currency.
        Parameters:
        currency - The currency, which limit should be removed.
        listener - The listener as MeaListener interface.
      • getDefaultTransactionLimit

        @Nullable
        public static java.lang.Integer getDefaultTransactionLimit()
                                                            throws NotInitializedException
        Returns default transaction limit amount, amount value includes decimals. The last two digits of value are decimals. 10000 = 100.00 EUR. Default transaction limit is used always when currency don't have its explicitly defined transaction limit. If both currency specific limit and default limit are not set, then for this currency library will not check transaction amount.
        Returns:
        Returns default transaction limit max amount, amount value includes decimals.
        Throws:
        NotInitializedException - if library is not initialized.
      • setDefaultTransactionLimit

        public static void setDefaultTransactionLimit​(int amount,
                                                      @Nullable
                                                      MeaListener listener)
        Set default transaction limit. Default transaction limit is used always when currency don't have its explicitly defined transaction limit. If both currency specific limit and default limit are not set, then for this currency library will not check transaction amount.
        Parameters:
        amount - Default transaction limit max amount, amount value includes decimals. 10000 = 100.00 EUR.
        listener - The listener as MeaListener interface.
      • removeDefaultTransactionLimit

        public static void removeDefaultTransactionLimit​(@Nullable
                                                         MeaListener listener)
        Removes default transaction limit. Default transaction limit is used always when currency don't have its explicitly defined transaction limit.
        Parameters:
        listener - The listener as MeaListener interface.
      • clearAllTransactionLimits

        public static void clearAllTransactionLimits​(@Nullable
                                                     MeaListener listener)
        Clear both currency specific transaction limits and default transaction limit value.
        Parameters:
        listener - The listener as MeaListener interface.
      • isMainProcess

        @Deprecated
        public static boolean isMainProcess​(@NonNull
                                            android.content.Context context)
        Deprecated.