The secux-paymentkit-sample-for-springtrees-ios is a sample APP for showing how to scan the QRCode from P22 and confirm the promotion / payment / refill to the P22 device via secux-paymentkit-v2.
- Minimum SDK Version: 24
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.secuxtech:secux-paymentkit-v2-android:{version}'
}
Add permission to the AndroidManifest.xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Request permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}
import com.secuxtech.paymentkit.*;
Use SecuXAccountManager object to do the operations below
private SecuXAccountManager mAccountManager = new SecuXAccountManager();
- Merchant login
Must login the assigned merchant account before calling payment related APIs.
Note: Login session is valid for 30 minutes. To continue use after 30 minutes, relogin is required.
SecuX Server API: /api/Admin/Login
Pair<Integer, String> loginMerchantAccount(String accountName, String accountPwd)
accountName: Merchant account name.
accountPwd: Merchant account password.
The first return value shows the operation result. If the result is SecuXRequestOK,
registration is successful, otherwise the second return value contains an error message.
Pair<Integer, String> ret = mAccountManager.loginMerchantAccount(name, pwd);
if (ret.first == SecuXServerRequestHandler.SecuXRequestOK) {
return true;
}
Log.i("", "Login merchant account failed! error:" + ret.second);
Use SecuXPaymentManager object to do the operations below
SecuXPaymentManager mPaymentManager = new SecuXPaymentManager();
- Get store information
Get store information via the hashed device ID in P22 QRCode.
SecuX Server API: /api/Terminal/GetStore
Pair<Pair<Integer, String>, SecuXStoreInfo> getStoreInfo(String devIDHash)
devID: Hashed device ID from getDeviceInfo function
The first return value shows the operation result. If the result is SecuXRequestOK,
getting store information is successful, the second SecuXStoreInfo contrains store
information, otherwise the first return string value contains an error message.
Note: if the first return result is SecuXRequestUnauthorized,
the login session is timeout, please relogin the system.
Pair<Pair<Integer, String>, SecuXStoreInfo> storeInfoRet = mPaymentManager.getStoreInfo(mDevIDhash);
- Do promotation / payment / refill operation
Confirm the promotation/payment/refill operation to the P22 device.
SecuX Server API:
- Encrypt operation data /api/B2B/ProduceCipher
SecuX Device APIs:
Please refer to the secux_paymentdevicekit for the APIs below:
-
Get P22 ivKey API
-
Cancel operation
-
Send encrypted operation data to P22 API
Pair<Integer, String> doActivity(Context context, String userID, String devID,
String coin, String token,
String transID, String amount,
String nonce,
String type)
context: Current activity context.
userID: Merchant account name.
devID: Current device ID, which can be get via getStoreInfo API
coin: Coin info. from the QRCode.
token: Token info. from the QRCode.
transID: Transaction ID assigned by merchant.
amount: Amount info. from the QRCode.
nonce: Nonce info. from the QRCode.
type: Activity type: promotion / payment / refill.
Pair<Integer, String> verifyRet = mPaymentManager.doActivity(this, this.mAccountName,
storeInfo.mDevID,
coin,
token,
transID,
amount,
nonce,
type);
if (verifyRet.first == SecuXServerRequestHandler.SecuXRequestUnauthorized){
if (!login(this.mAccountName, this.mAccountPwd)){
return;
}
verifyRet = mPaymentManager.doActivity(this, this.mAccountName, storeInfo.mDevID,
coin, token,
transID, amount,
nonce, type);
}
SecuX, [email protected]
SecuXPaymentKit is available under the MIT license.