Getting Started with Android
To get a copy of our SDK, please contact our partner team at [email protected]
Check Your SDK Version
We have multiple versions of the PaySimple Legacy Android SDK. Version 1.5.0 utilizes the triPOS Mobile SDK version 1.5.0. Version 1.6.0 of the PaySimple Legacy Android SDK utilizes the triPOS Mobile SDK version 3.0.0. Version 1.7.0 of the PaySimple Legacy Android SDK utilizes the triPOS Mobile SDK version 4.0.0. The version 1.7.0 of the PaySimple Legacy Android SDK will be labeled "paysimpleandroidsdk-release-1.7.0.aar" .
Minimum and Maximum Supported Android Version
PaySimpleAndroidSdk 1.5.0: min Android 8.0 API 26; max Android 12 API 31
PaySimpleAndroidSdk 1.6.0: min Android 10 API 29; max Android 13 API 33
PaySimpleAndroidSdk 1.7.0: min Android 10 API 29; max Android 14 API 34
Import Libraries
Import Libraries
- Create folder named libs in base project directory.
- Copy and paste both provided aar's in libs folder.
- In your app level gradle file (Module: project.yourappname) add dependencies.
Gradle example for PaySimpleAndroidSdk version 1.5.0
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "io.realm:realm-gradle-plugin:4.2.0"
}
}
android {
compileSdk 31
defaultConfig {
applicationId "com.paysimple.TestApp"
minSdk 26
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildToolsVersion '31.0.0'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.google.code.gson:gson:2.8.9'
//tripos dependencies
implementation 'com.google.dagger:dagger:2.11'
implementation 'org.apache.commons:commons-lang3:3.5'
implementation 'commons-io:commons-io:2.5'
implementation files('../libs/paysimpleandroidsdk-release.aar')
implementation files('../libs/triposmobilesdk-release.aar')
}
Gradle example for PaySimpleAndroidSdk version 1.6.0
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "io.realm:realm-gradle-plugin:10.10.1"
}
}
android {
compileSdk 34
defaultConfig {
applicationId "com.paysimple.TestApp"
minSdk 29
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
resources.excludes.add("META-INF/*")
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '31.0.0'
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation 'com.android.volley:volley:1.2.1'
//tripos dependencies
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
implementation 'com.google.dagger:dagger:2.45'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'commons-io:commons-io:2.11.0'
implementation group: 'commons-validator', name: 'commons-validator', version: '1.7'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'com.google.android.material:material:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0', { exclude group: 'com.android.support', module: 'support-annotations' })
implementation 'org.simpleframework:simple-xml:2.7.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation files('../libs/paysimpleandroidsdk-release.aar')
implementation files('../libs/triposmobilesdk-v3-release.aar')
//stripe dependencies
implementation "com.stripe:stripeterminal-localmobile:3.2.1"
implementation "com.stripe:stripeterminal-core:3.2.1"
implementation files('../libs/EverCommercePaymentsAndroidSdk-release.aar')
// MS App Center
def appCenterSdkVersion = '4.3.1'
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
}
task prepareKotlinBuildScriptModel {
}
task wrapper(type: Wrapper){
gradleVersion = '7.4.2'
}
Gradle Example for PaySimpleAndroidSdk version 1.7.0
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "io.realm:realm-gradle-plugin:10.10.1"
}
}
android {
compileSdk 34
defaultConfig {
applicationId "com.paysimple.TestApp"
minSdk 29
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
debuggable false
}
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
resources.excludes.add("META-INF/*")
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '31.0.0'
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation 'com.android.volley:volley:1.2.1'
//tripos dependencies
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
implementation 'com.google.dagger:dagger:2.45'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'commons-io:commons-io:2.11.0'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'com.google.android.material:material:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0', { exclude group: 'com.android.support', module: 'support-annotations' })
implementation 'org.simpleframework:simple-xml:2.7.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
kapt 'com.google.dagger:dagger-android-processor:2.45'
kapt 'com.google.dagger:dagger-compiler:2.45'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.work:work-runtime:2.8.1'
implementation 'androidx.work:work-runtime-ktx:2.8.1'
implementation 'com.squareup.okhttp3:okhttp-tls:4.10.0'
implementation 'commons-validator:commons-validator:1.7'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.0'
implementation files('../libs/paysimpleandroidsdk-release-1.7.0.aar')
implementation files('../libs/triposmobilesdk-release.aar')
}
task prepareKotlinBuildScriptModel {
}
task wrapper(type: Wrapper){
gradleVersion = '7.4.2'
}
Processing a Sale Example
Here's a simplified version of completing a sale within a single Android activity. Use your device's name, copy and paste client token, and create a TextView named "textView" and a button with onClick set to payment.
package com.paysimpleandroid.sdktest;
import android.Manifest;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import com.google.gson.Gson;
import com.paysimpleandroid.paysimpleandroidsdk.IPaysimpleBBPOS;
import com.paysimpleandroid.paysimpleandroidsdk.PsDeviceType;
import com.paysimpleandroid.paysimpleandroidsdk.PsEnvironment;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.DeviceState;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PaysimpleBBPOS;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PaysimpleSDKError;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PaysimpleSDKResponse;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PaysimpleSaleRequest;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PaysimpleSaleResponse;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PsEnums.PsAmountConfirmationType;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PsListeners.PsDeviceInteractionListener;
import com.paysimpleandroid.paysimpleandroidsdk.bbpos.PsListeners.PsListener;
import java.math.BigDecimal;
public class MainActivity extends AppCompatActivity implements PsListener, PsDeviceInteractionListener {
IPaysimpleBBPOS paysimpleBBPOS;
private TextView responseView;
String clientToken = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
responseView = findViewById(R.id.textView);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.BLUETOOTH_CONNECT, Manifest.permission.BLUETOOTH_SCAN}, 1);
paysimpleBBPOS = PaysimpleBBPOS.getInstance(this, PsEnvironment.QA1, PsDeviceType.BbposEmv);
paysimpleBBPOS.subscribeToListener(this);
paysimpleBBPOS.subscribeToDeviceInteractionListener(this);
new Thread(() -> {
PaysimpleSDKResponse res = paysimpleBBPOS.initializeAndConnect(clientToken, "CHB202044007347");
}).start();
}
public void payment(View view) {
if (paysimpleBBPOS.isDeviceConnected()) {
new Thread(() -> {
try {
//Include all fees here
BigDecimal amount = BigDecimal.valueOf(Math.random() * 100).setScale(2,
BigDecimal.ROUND_DOWN);
PaysimpleSaleRequest saleRequest = new PaysimpleSaleRequest(amount);
paysimpleBBPOS.processSale(clientToken, saleRequest);
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
}
@Override
public void updateResponse(Double aDouble, String... strings) {
runOnUiThread(() -> responseView.setText(strings[0]));
}
@Override
public void onError(PaysimpleSDKError paysimpleSDKError) {
runOnUiThread(() -> responseView.setText(new Gson().toJson(paysimpleSDKError)));
}
@Override
public void onDeviceEvent(DeviceState deviceState, String s) {
runOnUiThread(() -> responseView.setText(s + " " + deviceState.name()));
}
@Override
public void onPaymentResponse(PaysimpleSaleResponse paysimpleSaleResponse) {
runOnUiThread(() -> responseView.setText(new Gson().toJson(paysimpleSaleResponse)));
}
@Override
public void onAmountConfirmation(PsAmountConfirmationType psAmountConfirmationType, BigDecimal bigDecimal, PsConfirmAmountListener psConfirmAmountListener) {
psConfirmAmountListener.psConfirmAmount(true);
}
@Override
public void onPromptUserForCard(String s) {
runOnUiThread(() -> responseView.setText(s));
}
@Override
public void onDisplayText(String s) {
runOnUiThread(() -> responseView.setText(s));
}
@Override
public void onRemoveCard() {
runOnUiThread(() -> responseView.setText("Remove Card"));
}
@Override
public void onCardRemoved() {
runOnUiThread(() -> responseView.setText("Card Removed"));
}
}
Updated 4 months ago