1. Overview
SunmiPaySDK is a financial SDK based on SP(secure processor). SDK provide interfaces to client App by Android AIDL. SDK contains modules: Basic info module, Card module, EMV module, PinPad module, Security module, ETC module, Tax module, etc. Client APP could access Sunmi financial service interfaces conveniently after integrating this SDK.
1.1 Function introduction
Module functions of SunmiPaySDK:
(1) Basic info module: provide system info related interfaces, such as set/get system param, system buzzer, LED light control, etc.
(2) Card module: provide card operation related interfaces, such as check card, APDU exchange, card off, etc. Meanwhile, also provide interfaces of mifare card, AT24C serials card, SLE serials card, etc.
(3) EMV module: provide transaction related interfaces, such as save/delete AIDs and Capks, save terminal params, init EMV procedure, start EMV process, set/get TLV data, etc.
(4) PinPad module: provide PinPad related interfaces, such as init PinPad, cancel input PIN, set PinPad text, set/get PinPad mode, etc.
(5) Security module: provide key related interfaces, such as save MKSK/Dukpt/SM2/RSA keys, use saved keys to encrypt/decrypt data, calculate Mac, etc.
(6) ETC module:provide ETC( Electronic Toll Collection ) related interfaces, such as search OBU, ETC trade, etc. This module only used in china.
(7) Tax module: provide fiscal data exchange interfaces.
1.2 SDK file illustration
Name | Function | Backup |
PayLib-release-x.x.x.aar | aar packet which compiled from SDK AIDL files | Client APP should integrate this file |
PayLib-release-x.x.x-sources.jar | Provide source code of classes in PayLib-release-x.x.x.aar | Option file, not necessary for client APP |
SUNMI PAY SDK V2 开发文档_x.x.x.docx | Chinese version SDK interfaces document | |
SUNMI PAY SDK V2 Development Document_x.x.x.docx | English version SDK interfaces document | |
SunmiPaySdkTestDemo.rar | Source code of SDKTestDemo. Provide demo of access all kinds of SDK interfaces | |
SunmiSDKTestDemo_x.x.x_debug.apk | APK file, generated by SDKTestDemo source code |
2.Environment info
System environment | platform | Compile IDE |
Android 6.0+ | arm64, arm32 | Android studio |
3. SDK full package
Note: SDK full package contains PayLib-release-x.x.x.aar file, SDK interfaces documents file, SDKTestDemo source code file and SDKTestDemo apk file.
3.1 import SDK package to project
In Android Studio project, put PayLib-release-x.x.x.aar into libs directory.
3.2 Config build.gradle file
Add following code to project’s build.gradle file:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
......
compile(name: 'PayLib-release-x.x.x', ext: 'aar')
}
3.3 initialize and connect to SDK Service
Refer to the following code to connect to Sunmi Financial service:
/** bind PaySDK service */
public void bindPaySDKService() {
final SunmiPayKernel payKernel = SunmiPayKernel.getInstance();
payKernel.initPaySDK(this, new SunmiPayKernel.ConnectCallback() {
@Override
public void onConnectPaySDK() {
LogUtil.e(Constant.TAG, "onConnectPaySDK...");
emvOptV2 = payKernel.mEMVOptV2;
basicOptV2 = payKernel.mBasicOptV2;
pinPadOptV2 = payKernel.mPinPadOptV2;
readCardOptV2 = payKernel.mReadCardOptV2;
securityOptV2 = payKernel.mSecurityOptV2;
taxOptV2 = payKernel.mTaxOptV2;
etcOptV2 = payKernel.mETCOptV2;
printerOptV2 = payKernel.mPrinterOptV2;
connectPaySDK = true;
}
@Override
public void onDisconnectPaySDK() {
LogUtil.e(Constant.TAG, "onDisconnectPaySDK...");
connectPaySDK = false;
emvOptV2 = null;
basicOptV2 = null;
pinPadOptV2 = null;
readCardOptV2 = null;
securityOptV2 = null;
taxOptV2 = null;
etcOptV2 = null;
printerOptV2 = null;
Utility.showToast(R.string.connect_fail);
}
});
}