Ingenico Direct - Android SDK
The Ingenico Direct Android SDK provides a convenient way to support a large number of payment methods inside your Android app. It supports Jelly Bean (Android version 4.1.x) and up out-of-the box. The Android SDK comes with an example app that illustrates the use of the SDK and the services provided by Ingenico ePayments on the Ingenico ePayments platform.
See the Ingenico Direct Developer Hub for more information on how to use the SDK.
Installation via Gradle
Add a requirement to the SDK to your build.gradle file, where x.y.z is the version number:
dependencies {
// other dependencies
implementation 'com.ingenico.direct:direct-sdk-client-android:x.y.z'
}
Manual installation
To install the Android SDK and the example app, first download the code from GitHub.
$ git clone https://github.com/Ingenico/direct-sdk-client-android.git
Afterwards, you can open the project you just downloaded in Android Studio to execute the example app.
To use the Android SDK in your own app, you need to add the ingenicodirect-sdk gradle module to the build path of your project as follows:
- Open your app in Android Studio.
- Select
File,New,Import Module. - Select source directory by clicking on the
...button. - Browse to the downloaded Android SDK project, select the folder
ingenicodirect-sdkwhich contains all the SDK source code, and clickOK. - Click on
Finishto add theingenicodirect-sdkmodule to your project. - Wait until Android Studio is done building/cleaning the project, and you see a module named
ingenicodirectappear in your Android Studio project browser. - The last step is now to tell your App to use the added module.
- Select your app, and click
File,Project Structure. In theModulessection select your app, and go to the tabDependencies. - Click on the
+sign and selectModule dependency. 10.Select theingenicodirect-sdkmodule and pressOK. - You now have access to use all the Android SDK classes.
Running tests
The Android SDK comes with a set of integration tests. To run these tests, you will first need to modify file ingenicodirect-sdk-integrationtest/src/test/resources/itconfiguration.properties. This file is mostly complete, but you need to fill in the actual values for the following keys:
direct.api.apiKeyIdfor the API key id to use. This can be retrieved from the Configuration Center.direct.api.secretApiKeyfor the secret API key to use. This can be retrieved from the Configuration Center.direct.api.merchantIdfor your merchant ID.
Besides these settings, you can also modify the settings for the Java SDK, which is used to create the sessions and tokens needed to run the tests.
Afterwards, you can run the tests as follows:
- Open the SDK in Android Studio. If you haven't opened it before, choose to import a project and browse to the Android SDK project.
- On the
Projecttab, openingenicodirect-sdk-integrationtest, thenjava. Right click on thecom.ingenico.direct.gateway.sdk.client.android.integrationtestpackage, and click onRun 'Tests in 'com.ingenicodirect.ga...'.