Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

Integrate the SDK Package

This topic covers how to easily integrate the Android SDK package with Maven and by manual operation.

Integrate the SDK Package with Maven

Please follow the steps below to integrate the SDK package with Maven.

  1. Add the Maven repository:

Add the Maven repository to your root build.gradle file using the code snippet below.

copy
allprojects {
    repositories {
        maven{
            credentials{
                username "antomsdk@aliyun.com"
                password "Admin1234"
            }
            url "https://globaltech.alipay.com/api/v1/file/repository/antom/"
        }
        // other repositories
        // -------
    }
}
  1. Add dependencies:

Add the dependencies in the build.gradle file using the code snippet below.

copy
// in app build.gradle
// if there are some conflicts with existing sdk, please exclude them
dependencies {
    implementation "com.alipay.antom.sdk:payment-component:${antom_version}"
}

Externalize the dependency version in the build.gradle file to easily manage upgrades with the "Externalize dependency version" code snippet. Replace the value of ANTOM_VERSION with the latest version 1.18.0.

copy
ext {
    antom_version = 'ANTOM_VERSION'
}
  1. (Optional) Integrate the security extension package:

Antom offers the SDK security extension package for a secure payment process. To integrate the security package, add the Maven dependencies in the build.gradle file with the code snippet below.

copy
dependencies {
    implementation "com.alipay.antom.sdk:securitysdk:1.0.0"
}

After integrating the security extension package, take note of the following:

  • Use Apache HttpClient
    • Declare the usage of the org.apache.http.legacy library in your project's root build.gradle file.
copy
android {
    useLibrary 'org.apache.http.legacy' // Support HttpClient
    ......
        }
    • Declare the usage of the org.apache.http.legacy library in the AndroidManifest.xml file.
copy
<application>
  <uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
copy
dependencies {
    implementation 'com.alibaba:fastjson:1.1.70.android'
}

Integrate the SDK Package manually

If you are not using Maven integration, you can follow the manual integration method provided by Antom.

  1. Download the latest SDK package in Alipay Global Partner Developer Center.

Go to Resources > Download Detail > Android, select the corresponding product package, and click on View the download address of this package to download. Accept the download agreement for the first download.

  1. Place the unzipped .aar file in the libs folder of your project.
  2. Declare the reference of the .aar file in the project's build.gradle file.
copy
dependencies {
    // Configure the SDK .aar package. Make sure to replace "xxxxx" with the actual version number of the downloaded package.
    implementation(name: 'ams-component-sdk-release-xxxxx', ext: 'aar')