TCardService provides basic card reading and pinpad functionality via providing AIDL interface. It is a BoundedService, which is only active when another application is bounded.
Place the cardservicebinding-release.aar library file into your project's "libs" folder and add it as dependency inside your app level build.gradle file like below and build your project in order to create build classes of library.
publicabstractclassBaseActivityextendsAppCompatActivityimplementsCardServiceListener {protectedCardServiceBinding cardServiceBinding; @OverrideprotectedvoidonCreate(@NullableBundle savedInstanceState) { super.onCreate(savedInstanceState); cardServiceBinding =newCardServiceBinding(this,this); } @OverrideprotectedvoidonDestroy() {//Make sure to call unBind() method when activity is finishingcardServiceBinding.unBind(); super.onDestroy(); } /** * Callback for Card Service connected method. You will not need to check whether card service is connected or not in most cases. * When you make an asynchronous method call on CardServiceBinding,it will be executed automatically as soon as CardService is connected. */ @OverridepublicvoidonCardServiceConnected() { } /** * Callback for TCardService getCard method. * As getCard is an asynchronous service operation, you will get the response after operation is done in this callback. * @apiNote Override this method in your activity in order to get card data after calling #getData() method of Card Service. * @param cardData: Card data json string */publicvoidonCardDataReceived(String cardData) { } /** * Callback for TCardService getOnlinePin method. * As getOnlinePin is an asynchronous real time operation, you will get the response after operation is done in this callback. * @apiNote Override this method in your activity in order to get pin data after calling #getOnlinePin() method of Card Service. * @param pin: Pin string */publicvoidonPinReceived(String pin) {} /** * Callback for TCardService iccTakeOut method. * This callback will be triggered when user takes out card from pos device after you inform the user with takeOutICC() method. * @apiNote Override this method in your activity in order to get icc take out callback after calling #iccTakeOut() method of Card Service. */publicvoidonICCTakeOut() {}}
CardServiceBinding api methods
getCard(...) API Details
It is used to get card (ICC, MSR, CL) according to config of the API.
Inputs
int amount : amount of the sale.
int timeout: card read timeout as seconds.
String config:
forceOnline: Force EMV Txns Online.
fallback: Enable fallback.
zeroAmount: Show the amount data on screen however send to EMV kernel amount as "0".
keyIn: Enable keyIn on getCard screen.
askCVV: Enable CVV entry on keyIn screen.
showAmount: Show the amount data on screen.
extraAmount: This amount will be added to the main amount and displayed as the total amount on the screen. It will be excluded from the EMV processing. Please provide it as 100 x Float amount.
showCardScreen: Show the Card Screen. If pre-reading has been made by the platform please set is as "0"
partialEMV: Deprecated, please use emvProcessType.
emvProcessType: It is used if txn is ICC. The types of the EMV process are below.
NOTE: X30TR does not support PARTIAL_EMV.
reqEMVData: Tags that requested for ICC Read Type. ICCData fields will be filled also according to requestedEMVData.
If it is not set by user, for READ_CARD it is set to "575A5F245F204F84", for other Txn Types it is set to "575A5F245F204F9B849F125F2A5F3482959A9C9F029F039F099F109F1A9F1E9F269F279F339F349F359F369F379F418E9F069F539F0D9F0E9F0F" by default.
Note 1:Please consider, it will take more time if you request more tags. Please make optimiziation on this tag to speed up the EMV Txn.
cardReadTypes:
currencySymbol: The ISO 4217 currency numeric code to show currency symbol on cardService screens. Ex:949 for TRY, 840 for USD.
forceICCTermCurrencyCode: For ICC transactions, temporarily set currencySymbol to 5F2A.
getOnlinePIN: Enable Online PIN during the getCard operation only for ICC transactions..
kmsVersion :
1 : Deprecated: Compatible with 400TR and 1000TR Castles-based systems.
2 : new KMS library, compatible with all devices.
keySet : allocated keySet value of the bank. Only set for kmsVersion 1. Not needed for kmsVersion 2.
keyIndex : keyIndex value of the PIN key.
minLen: min length of the requested PIN.
maxLen: max length of the requested PIN.
isDukptKey: it is set to 1 if the PIN key is Dukpt.
extraAmount: This amount will be added only to the main Amount and will be showed as Total Amount on the screen. It will be excluded from EMV process.
carPay: Specifically for 1000TR, it will be sent if In Car Pay is supported.
Returns
resultCode Values
ICC Card Type Return
CL Card Type Return
TransResult:
NOTE: Use this value to decide if the transaction will continue offline, online, or be declined.
0x0002 //d_EMVCL_OUTCOME_APPROVAL
0x0003 //d_EMVCL_OUTCOME_DECLINED
0x0004 //d_EMVCL_OUTCOME_ONL
SID:
CVMAnalysis:
Indicate which CVM is required
MSR Card Type Return
KeyIn Card Type Return
mCardReadType field values
completeEMVTxn(...) API Details
Actions after Online Processing, such as External Auth., Second Gen. AC, Issuer Script Processing.
Note: All ICC transactions must be completed in 330TR with completeEMVTxn. The EMV process is not completed until completeEmvTxn is called.
Inputs
action:
authRespCode: Response Code from the host. 2 bytes.
issuerAuthData: Issuer Authentication Data from the issuer host
issuerAuthDataLen: Length of the Issuer Authentication Data
issuerScript: Issuer Script from the issuer host
issuerScriptLen: Length of the Issuer Script
Returns
will be added...
getOnlinePIN(...) API Details
getOnlinePIN API used to get Encrypted PIN data.
Inputs
int amount : amount of the sale.
String pan : PAN of the used card
int keySet : allocated keySet value of the bank
int keyIndex : keyIndex value of the PIN key
int minLen: min length of the requested PIN
int maxLen: max length of the requested PIN
int timeout: max PIN entry period as sec.
Returns
pinData
getOnlinePINEx(String config) API Details
getOnlinePINEx API used to get Encrypted PIN with kmsVersion 2.
Note: Although this API is compatible with kmsVersion 1, as kmsVersion 1 has been deprecated, please use getOnlinePINEx.
Inputs
String config :
amount : amount of the sale.
PAN : PAN of the used card
kmsVersion :
1: Deprecated. Compatible with 400TR and 1000TR (Castles based).
2 : new KMS library, compatible with all devices.
keySet : allocated keySet value of the bank. Only set for kmsVersion 1. Not needed for kmsVersion 2.
keyIndex : keyIndex value of the PIN key.
minLen: min length of the requested PIN.
maxLen: max length of the requested PIN.
timeout: max PIN entry period as sec.
extraAmount: This amount will be added only to the main Amount and will be showed as Total Amount on the screen. It will be excluded from EMV process.
isDukptKey: it is set to 1 if the PIN key is Dukpt.
currencySymbol: The ISO 4217 currency numeric code to show currency symbol on cardService screens. Ex:949 for TRY, 840 for USD.
Returns
pinData
void takeOutICC(int timeout) API Details
takeOutICC is used to warn user to take out card.
Inputs
int timeout: take out period as sec.
String getEMVCompletionData();
Used to get EMV Completion data as JSON after completeEMVTxn API called.
Returns
Settings
setEMVConfiguration(...) API Details
setEMVConfiguration API sets the configuration settings of Banking App to kernel.
Note:The setEMVConfiguration should be called first and followed by the setEMVCLConfiguration.
Inputs
String config
Developer can create an xml file that is formatted like
// amount:
// please provide it as 100 x Float amount.
// example -> For 1 = provide 100, for 0.05 = provide 5
//
// timeout:
// duration as seconds that will present card view and
// detects any card types
//
// config:
// reserved for future use
void getCard(int amount, int timeout, String config);
// action:
// Online approval 1
// Online decline 2
// Unable go online 3
// Issuer referral approval 4
// Issuer referral decline 5
// Unable go online with specific ARC 6
//
// authRespCode:
// Response Code from the host. 2 bytes.
//
// issuerAuthData:
// Issuer Authentication Data from the issuer host
//
// issuerAuthDataLen:
// Length of the Issuer Authentication Data
//
// issuerScript:
// Issuer Script from the issuer host
//
// issuerScriptLen:
// Length of the Issuer Script
int completeEmvTxn(byte action, in byte[] authRespCode, in byte[] issuerAuthData, int issuerAuthDataLen, in byte[] issuerScript, int issuerScriptLen);
// config:
// emv settings xml data
int setEMVConfiguration(String config);
// amount:
// please provide it as 100 x Float amount.
// example -> For 1 = provide 100, for 0.05 = provide 5
//
// pan:
// PAN of the Card
//
// keySet:
// The keySet that assigned for Bank
//
// keyIndex:
// The index of the key in keySet
//
// minLen:
// min PIN entry len
//
// maxLen:
// max PIN entry len
//
// timeout:
// PIN entry timeout as Sec
void getOnlinePIN(int amount, String pan, int keySet, int keyIndex, int minLen, int maxLen, int timeout);
//ret: device SN as String
String getDeviceSN();
// timeout:
// duration as seconds that will present take out Chip Card
void takeOutICC(int timeout);
//ret: EMV completion datas as JSON data
String getEMVCompletionData();
//info will be added
void showQR(String header, String total, String QRData);
void showSuccess(boolean isSuccess, String header);
void showBlackScreen();
// config:
// emv settings xml data
int setEMVCLConfiguration(String config);
// config:
// config pin entry
public void getOnlinePINEx(String config)
}
public enum emvProcessType {
PARTIAL_EMV(0), //After reading card data with requested Tags, requesting AAC at the 1st Generate AC to complete transaction and return requested Tag data
READ_CARD(1), //After app selection, read requested card data and return
CONTINUE_EMV(2), //Continue and complete full EMV Txn from Read Card Data process and returns requested Tag data.
FULL_EMV(3); //Actions based EMV Specification, such as Initiate App. Processing, Read App. Data, Off. Auth., Processing restrictions, Cardholder Verification, Term. Risk Man., First Gen AC and returns requested Tag data.
}
public enum CardReadCombination {
ICC,
CL,
MSR,
ICC_CL,
ICC_MSR,
CL_MSR,
ALL
}
public enum CardServiceResult {
SUCCESS(0),
USER_CANCELLED(1),
ERROR(2),
}
Indicate which CVM is required
0x00 – None.
0x01 – Signature.
0x02 – Online PIN.
0x03 – CVM Fail.
0x04 – NO CVM.
0x05 – Confirmation Code Verified.
{
"resultCode":0,
"mCardReadType":2,
"mCardNumber":"5168881167113299",
"mTrack2Data":"1201530011?", //other than pan and exp date
"mExpireDate":"2711",
"mTranAmount1":123,
"mTrack1CustomerName":"REMZI SEPIK",
"Track1Data":"%B5168881167113299^SEPIK\/REMZI ^27111201100000000153000000?",
"Track2Data":";5168881167113299=27111201530011?"
}