Skip to content

secuxtech/secux-paymentkit-sample-common-android

Repository files navigation

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: 24

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}'
}

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 promotation / payment / refill operation

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

Procedure

SecuX Server API:

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

Declaration

    Pair<Integer, String> doActivity(Context context, String userID, String devID, 
                                        String coin, String token, 
                                        String transID, String amount, 
                                        String nonce,
                                        String type)

Parameter

    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.

Sample

    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);
    }

Author

SecuX, [email protected]

License

SecuXPaymentKit is available under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages