Integrations

This part contains the changes required to adapt the application written for 400TR and 1000TR to x30 in the most accurate and minimum effort way.

Libs

For 330TR add the libs below.

Manifest

330TR:

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>

Build Gradle

Ui Components

implementation 'com.google.android.material:material:1.6.0'

Note: Add to app/build.gradle for x30 ui components

KMS

400TR: new CtKMS2System().checkKey(VersionParams.keyset, 0);

330TR: kms.checkKeyExist(VersionParams.tpk);

Service Binding:

kms = new TokenKMS();
kms.init(getApplicationContext(), new KMSWrapperInterface.InitCallbacks() {
    @Override
    public void onInitSuccess() {
        Log.v("Token KMS onInitSuccess", "KMS Init OK");
    }
    @Override
    public void onInitFailed() {
        Log.v("Token KMS onInitFailed", "KMS Init Failed");
    }
});

Enc/Dec

400TR:

CtKMS2FixedKey enckey = new CtKMS2FixedKey();
enckey.setCipherMethod(CTOS.CtKMS2FixedKey.DATA_ENCRYPT_METHOD_ECB);


CtKMS2FixedKey deckey = new CtKMS2FixedKey();
deckey.setCipherMethod(CTOS.CtKMS2FixedKey.DATA_ENCRYPT_METHOD_ECB);

330TR:

kms.encryptData(VersionParams.kek, tdata2encrypt, TokenKMSConstants.TOKENKMS_PROTECTION_MODE_ECB, ICV);

kms.decryptData(VersionParams.pek, data, TokenKMSConstants.TOKENKMS_PROTECTION_MODE_CBC, ICV);

Write Key

400TR:

CtKMS2KPK kpk = new CtKMS2KPK();

kpk.setCipherKeyLocation(KEK_keyset, KEK_keyindex);
kpk.setKeyLocation(keyset, keyindex);

kpk.writekey();

330TR

kms.injectKeybyKEK(VersionParams.kek, 1, TokenKMSConstants.TOKENKMS_KEYTYPE_TDK, TokenKMSConstants.TOKENKMS_KEY_ALG_TYPE_3DES,

Printer

400TR:

printService = new PrintServiceBinding(); // Bind Service
printService.print(printText); // Print

330TR:

StyledString styledText = new StyledString();
/* Add text…*/
styledText.print(PrinterService.getService(getApplicationContext())); // Print, without service binding

Card Service

getCard

String config:

{
 "forceOnline":1,
 "fallback":1,
 "zeroAmount":1,
 "keyIn":1,
 "askCVV":1,       
 "showAmount":1,   
 "showCardScreen":1,
 "partialEMV":1, 
 "qrPay":1,  
 "emvTxnType":0,
 "emvProcessType":1,
 "reqEMVData":"575A5F245F204F84959F12",
 "cardReadTypes":6,
 "getOnlinePIN":1,
 "kmsVersion": 2,
 "keySet": 0,
 "keyIndex": 4,
 "minLen": 4,
 "maxLen": 12,
}

Note: The following fields are mandatory to be added for x30 integration.

  • getOnlinePIN: Must sent during the getCard Operation for ICC transactions.

  • kmsVersion :

1 : Deprecated: Compatible with 400TR and 1000TR Castles-based systems.

2 : new KMS library, compatible with all devices.

  • keyIndex : keyIndex value of the PIN key

  • keySet : allocated keySet value of the bank. Only set for kmsVersion 1. Not needed for kmsVersion 2.

  • keyIndex : keyIndex value of the PIN key.

getOnlinePINEx

Note: getOnlinePINEx API use to get Encrypted PIN with kmsVersion 2, and As kmsVersion 1 has been deprecated, please use getOnlinePINEx.

getOnlinePINEx(String config) API Details

{
  "amount": 80000,
  "PAN": "4797957003463700",
  "kmsVersion": 2,
  "keySet": 0,
  "keyIndex": 4,
  "minLen": 4,
  "maxLen": 12,
  "timeout": 30
}
  • kmsVersion : Send 2 for new KMS

  • keyIndex : keyIndex value of the PIN key.

completeEMVTxn

All ICC transactions must be completed in 330TR. The card read process is not completed until completeEmvTxn is called. Other than requested actions by API, ICC transactions can be completed as follows:

if (card.getmCardReadType() == CardReadType.ICC.value) {
    byte action = (byte) 0x01;
    int emvResult = cardServiceBinding.completeEmvTxn(action, new byte[]{0, 0}, new byte[]{0, 0}, 0, new byte[]{0, 0}, 0);
}

setEMVConfiguration

<TerminalConfig>   
.
.
.
.
.
<Item name="Trans Currency Code" tag="5F2A" attribute="hex">0949</Item>
</TerminalConfig>

Note: 5F2A field mandatory to be added for x30 integration.

Note: The setEMVConfiguration should be called first and followed by the setEMVCLConfiguration.

Android Studio Configuration:

You need to edit your configurations in 330TR unlike 400/1000TR because its version is more than Android 11. Therefore you need to open Edit Configurations and then select "Always install with package manager". If you don't select that configuration, your latest changes won't work on your 330TR device.

Last updated