The purpose of this example app is to demonstrate how to implement and use the Trustly Android SDK.
Follow the steps below to run this example app with your own Trustly API credentials.
- Android Studio Electric Eel (2022.1.1) or higher
- Trustly API credentials and Merchant ID (provided by Trustly)
- Open Android Studio
- File -> Open -> "trustly-android-example"
- Wait for project to finish building
- Open the Establish Data file and insert your credentials into the placeholders:
object EstablishData {
fun getEstablishDataValues(): Map<String, String> {
val establishDataValues: MutableMap<String, String> = HashMap()
establishDataValues["accessId"] = "YOUR_ACCESS_ID"
establishDataValues["requestSignature"] = "YOUR_REQUEST_SIGNATURE"
establishDataValues["merchantId"] = "YOUR_MERCHANT_ID"
establishDataValues["description"] = "Android SDK Demo"
establishDataValues["currency"] = "USD"
establishDataValues["merchantReference"] = "MERCHANT_REFERENCE"
establishDataValues["paymentType"] = "Retrieval"
establishDataValues["metadata.urlScheme"] = "sdkdemo://"
establishDataValues["env"] = "sandbox"
return establishDataValues
}
}
- Setup a target device or emulator and "Run" the application
In order to generate dynamically the requestSignature
attribute into your EstablishData
object, follow the steps below:
- Clone and run the trustly-nestjs-example, in case you don't have a request signature server set
- Add or change the request signature endpoint (e.g.
http://localhost:8080/api/
) intoBASE_URL
variable of theRetrofitClient.kt
file - Change to
true
theDYNAMIC_REQUEST_SIGNATURE
variable in theEstablishData.kt
file - Run your app
Documentation: Securing Requests
You can participate in this project by submitting bugs and feature requests in the Issues tab. Please, add @lukevance as an assignee.
If you are interested in fixing issues and contributing directly to the code base, feel free to open a Pull Request with your changes. Please, make sure to fulfill our Pull Request Template and add @lukevance as code reviewer.