FILTER BY TAG

Configuring the Tap to Pay on Android SDK

Use the information in this section to configure the Tap to Pay on Android SDK.

Configure the Project
settings.gradle
File

Follow this step to configure your project's
settings.gradle
file.
  1. Add the repository to your project's
    settings.gradle
    file.
    dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() google() exclusiveContent { forRepository { maven { setUrl("https://repo.visa.com/mpos-releases/") } } filter { includeGroup("io.payworks") } } } }

Configure the Project
build.gradle
File

Follow this step to configure your project's
build.gradle
file.
  1. Add the Kotlin Gradle plug-in, which is required to use this solution. Note that Kotlin version 2.1 or later and Android Gradle version 8.2 or later are required.
    plugins { id("com.android.application") version "8.2.0" apply false id("org.jetbrains.kotlin.android") version "2.1.0" apply false }

Configure the Module
build.gradle
File

Follow these steps to configure your module
build.gradle
file.
  1. In the Android section, add these exclusion rules to your module's
    build.gradle
    file.
    android { ... packaging { resources { excludes.add("META-INF/*") excludes.add("LICENSE.txt") excludes.add("asm-license.txt") } } }
  2. In order for the app to support Java 17 features, you must set the compatibility levels.
    android { ... compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = "17" } }
  3. The Tap to Pay on Android Solution library publishes a release build type only. The debug build type is not available, so set the
    matchingFallbacks
    field value to
    release
    .
    android { ... buildTypes { ... debug { matchingFallbacks.apply { clear() add("release") } } } }
  4. IMPORTANT
    Stay current with the latest SDK. The SDK repository is continuously updated to make available the six latest versions. When a new version is released, the oldest is removed and can no longer be used for new application builds. Establish a regular process for updating to the newest available SDK version to avoid potential build failures and to ensure that your application runs with the latest features, performance enhancements, and security updates.
    Add the required Default UI and Tap to Pay on Android libraries to the Dependencies section of your module's
    build.gradle
    file.
    dependencies { ... // This is the Default UI dependency implementation("io.payworks:paybutton-android:2.113.0") // This is the Tap to Pay dependency implementation("io.payworks:mpos.android.taptophone:2.113.0") }

Update the
AndroidManifest.xml
File

To support a large heap size and ensure the necessary permissions for the Default UI, update your
AndroidManifest.xml
file. Enabling a larger heap is essential for scenarios where terminal updates require the handling and transfer of large volumes of data.
WARNING
Do not enable automatic backup in your app's
AndroidManifest
file. The Tap to Pay on Android SDK uses the Android Keystore to install and store cryptographic keys in your app. Using automatic backup restores the default encryption preferences and causes a functionality error in the Tap to Pay on Android SDK.
Follow these steps to update your
AndroidManifest.xml
file:
  1. Set the
    android:allowBackup
    attribute to
    false
    and the
    android:largeHeap
    attribute to
    true
    .
    <application ... android:allowBackup="false" android:largeHeap="true" > ... </application>
  2. Enable the needed permissions for the Default UI.
    <manifest ... > ... <!-- Needed for Default UI ! --> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> ... </manifest>

Configure ProGuard Rules to Enable Obfuscation

Follow these steps to configure ProGuard rules that enable obfuscation.
  1. To enable obfuscation for any of your build types, define the setting in the relevant
    build.gradle
    file for your app.
    buildTypes { release { isMinifyEnabled = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } }
  2. If you are using ProGuard as an obfuscation tool in your app, add these rules to the
    proguard-rules.pro
    file.
    # OkHttp -keepattributes Signature -keepattributes *Annotation* -dontwarn com.squareup.okhttp.** -keep class com.squareup.okhttp.* { *; } -dontwarn okio.** # Acceptance Devices -keep class io.mpos.** { *; } -dontwarn io.mpos.** -keep class com.visa.vac.tc.** {*;} -keep class com.nimbusds.jose.** {*;} -keep class org.bouncycastle.** {*;} -keep class retrofit2.** { *; } -keep interface retrofit2.** { *; } -keep class com.visa.auth.** { *; } -dontwarn com.visa.auth.** -keep class androidx.** { *; } # Visa Sensory Branding -keep class com.visa.SensoryBrandingView # Mastercard Sonic Branding -keep class com.mastercard.sonic.BuildConfig {*;}