secuxtech / secux-paymentkit-sample-for-springtrees-android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SecuXPaymentKitSample

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.

APK download

secux-paymentkit-v2

Requirements

  • Minimum SDK Version: 21

Add JitPack repository

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add dependency secux-paymentkit-android

dependencies {
    implementation 'com.github.secuxtech:secux-paymentkit-v2-android:{version}'
    implementation 'com.github.secuxtech:secux-paymentdevicekit-v2-android:2.1.10'
}

Add bluetooth privacy permissions

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 the the module

import com.secuxtech.paymentkit.*;

Usage

SecuXAccount related operations

Use SecuXAccountManager object to do the operations below

private SecuXAccountManager mAccountManager = new SecuXAccountManager();
  1. 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

Declaration

    Pair<Integer, String> loginMerchantAccount(String accountName, String accountPwd)

Parameter

    accountName:    Merchant account name.
    accountPwd:     Merchant account password.

Return value

    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.

Sample

    Pair<Integer, String> ret = mAccountManager.loginMerchantAccount(name, pwd);
    if (ret.first == SecuXServerRequestHandler.SecuXRequestOK) {
        return true;
    }

    Log.i("", "Login merchant account failed! error:" + ret.second);

SecuXPayment related operations

Use SecuXPaymentManager object to do the operations below

    SecuXPaymentManager mPaymentManager = new SecuXPaymentManager();
  1. Get store information

Get store information via the hashed device ID in P22 QRCode.

SecuX Server API: /api/Terminal/GetStore

Declaration

    Pair<Pair<Integer, String>, SecuXStoreInfo> getStoreInfo(String devIDHash)

Parameter

    devID: Hashed device ID from getDeviceInfo function

Return value

    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.

Sample

    Pair<Pair<Integer, String>, SecuXStoreInfo> storeInfoRet = mPaymentManager.getStoreInfo(mDevIDhash);
  1. Do check-in / promotation / payment / refill operation

Confirm the promotation/payment/refill operation to the P22 device.

Procedure

2.1 SecuX Server API:

2.2 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

Author

SecuX, maochunsun@secuxtech.com

License

SecuXPaymentKit is available under the MIT license.

About


Languages

Language:Java 100.0%