Card Query

What is a Card Query?

A card query is a call that will be done to an acquirer to obtain specific information about the card. This is typically used for loyalty cards.

Card query supports magstripe only and will return Track1, Track2 and PAN data in the clear if available. A card query will only return card data if the card bin has been whitelisted on the Ecentric Payment Portal.

📘

Track 2 Data

Track 2 data is encoded in a numerical format and primarily contains essential information necessary for processing store credit card transaction. This data is also stored on the magnetic stripe of the card.

The Track2 data consists of the below information:

  • Cardholder's card number
  • Expiry date

How Does a Card Query Work?

Process Description

Step 1:

The MPOS will initiate a CARDQUERY request, the CARDQUERY request will be sent to the Ecentric Payment App.

Step 2:

The Ecentric Payment App will process the card details and forward the CARDQUERY request to the Ecentric Server.

Step 3:

The Ecentric Server will validate the card bin.

Note: If the card bin is not whitelisted, the Ecentric Server will return and error to the Ecentric Payment App.

Step 4:

Once the card bin has been validated the Ecentric Server will return the CARDQUERY response to the Ecentric Payment App.

Step 5:

The Ecentric Payment App will then forward the CARDQUERY response to the MPOS App.

Step 6:

The MPOS App will then have access to the card details.


Request

Sample Bundle

The following is an example of a CARDQUERY request bundle that the MPOS Application will request.

"authenticationKey": "e27b6ce6-78ba6-4y46-9953-5afr28f7cbeb",
 "merchantID": "971234500000003",
 "launchType": "CARDQUERY"

Parameters

The following table describes the parameters of the CARDQUERY request message.

PARAMETERTYPEDESCRIPTIONEXAMPLE
REQUIRED
launchTypeSTRINGMust be “CARDQUERY”
Used for launching the Ecentric Payment App to perform a card query.
CARDQUERY
merchantIDSTRINGThe merchant ID assigned to the merchant.971234500000003
authenticationKeySTRINGThe authentication token that was generated by the server on a successful auth call to the Ecentric Payment Appe27b6ce6-78ba6-4y46-9953-5afr28f7cbeb

Sample Code

The following code needs to be implemented by the MPOS Application in order to invoke the Ecentric Payment App to initiate a CARDQUERY request message.

*See Sample Code CARDQUERY Response for the intentLauncher function

private void doCardQuery() {
   Intent intent = new Intent();
   intent.setClassName("com.ecentric.ecentricpay", "com.ecentric.ecentricpay.MainActivity");
   Bundle dataBundle = new Bundle();
   dataBundle.putString("launchType", "CARDQUERY");
   dataBundle.putString("merchantID", "910100000000001");
   dataBundle.putString("authenticationKey", "received_authenticationKey");

   intent.putExtra("ecentricBundle", dataBundle);
   try {
       intentLauncher.launch(intent);
   } catch (Exception e) {
       Log.e(TAG, "Error launching intent: " + e);
   }
}

Response

Sample Bundle

The following is an example of a CARDQUERY response bundle that the MPOS Application will receive.

  "adjustAmount": 0,
  "appVersion": "2.2.0",
  "buildInfo": "com.ecentric.ecentricpay-DEBUG-Ecentric-[Ecentric_UAT]",
  "cashAmount": 0,
  "isReceiptDataAvailable": true,
  "launchType": "CARDQUERY",
  "merchantID": "910100000000001",
  "outstandingAmount": 0,
  "panData": "6009352937150509",
  "posId": "",
  "receiptBundle": {
    "ACC_TYPE_DESC": "Credit",
    "APPLICATION_LABEL": "",
    "BUDGET_PERIOD": "00",
    "CARD_BIN": "6009352",
    "CARD_NAME": "Cr-Samba",
    "TSI": "0000",
    "TVR": "0400008001"
  },
  "resultCode": "00",
  "resultDescription": "COMPLETED",
  "serialNumber": "F31P606437P1024",
  "track1Data": "B6009352937150509^MASS BUILD                ^260279910000        00012000000",
  "track2Data": "6009352937150509\u003d260279910000050012",
  "transactionAmount": 0,
  "transactionUuid": "b7af9bd0-0735-439a-9e0d-62a0e16e271e"


Parameters

The following table describes the parameters of the CARDQUERY response message.

PARAMETERTYPEDESCRIPTIONEXAMPLE
BODY
adjustAmountLONGN/A for Cardquery0
appVersionSTRINGThe software version currently running on the Ecentric Payment App.2.0.0
buildInfoSTRINGMetadata that identifies the specific software build running on the payment device.com.ecentric.ecentricpay-DEBUG-Ecentric-[Ecentric_UAT]
cashAmountLONGN/A for Cardquery0
isReceiptDataAvailableSTRINGBoolean indicating whether a receiptBundle object is available. Will always be included for approved or declined transactions.true
launchTypeSTRINGEcho of the launchType used to launch the Ecentric Payment App.CARDQUERY
merchantIDSTRINGEcho of the merchantID used in the request.910100000000001
outstandingAmountLONGN/A for Cardquery0
panDataSTRINGPAN of card if available6009352937150509
posIdSTRINGN/A for Companion API Integrations
receiptBundleSTRINGConsists of a sub-bundle of server parameters that can be used by the partner application to create a receipt.See RECEIPT BUNDLE
resultCodeSTRING

Represents the final outcome of the query.

● 00: COMPLETED
● 03: ABORTED
● 04: ERROR

00
resultDescriptionSTRINGA user readable representation of the above resultCode i.e. Approved for resultCode 01.COMPLETED
track1DataSTRINGContents of track 1 if available"B6009352937150509^MASS BUILD ^260279910000 00012000000"
track2DataSTRINGContents of track 2 if available5210955001511518=29056270000000154000
transactionAmountLONGN/A for Cardquery0
transactionUuidSTRINGEcho of the Unique ID of a transaction.bdf9d0af-17b3-48ca-8a0b-37dc52bf49bc
RECEIPT BUNDLE
ACC_TYPE_DESCSTRINGDescription of selected accountCredit
APPLICATION_LABELSTRINGLabel of application usedMSI12 v1 0
BUDGET_PERIODSTRINGSelected budget period for this transaction00
CARD_BINSTRINGBin of the card used6009352
CARD_NAMESTRINGScheme name of the card used for the transactionCr-Samba
TSISTRINGEMV Transaction Status Information0000
TVRSTRINGEMV Terminal Verification Results0400008001

Sample Code

📘

Note

There are 2 different responses that may be received when performing this function and are solely dependent on the Merchants configuration settings.

  • Response if the Card is not whitelisted
  • Response if the Card is whitelisted

The following code needs to be implemented by the MPOS Application to recover the CARDQUERY transaction outcome and resume the MPOS App flow accordingly.

When the response is returned the calling app needs to override the onActivityResult() method and can be done as follows:

private final ActivityResultLauncher<Intent> intentLauncher = registerForActivityResult(
       new ActivityResultContracts.StartActivityForResult(),
       result -> {
           if (result.getResultCode() == Activity.RESULT_OK) {
               Intent data = result.getData();
               if (data != null) {
                   Bundle responseBundle = new Bundle(data.getBundleExtra("ecentricApplicationResponse"));
                   String launchType = responseBundle.getString("launchType");
                   String resultCode = responseBundle.getString("resultCode");
                   String track1Data = responseBundle.getString("track1Data"); 
		   String track2Data = responseBundle.getString("track2Data"); 
		   String panData = responseBundle.getString("panData");
		   Boolean success = false;
                   if (resultCode != null && (resultCode.matches("00") || resultCode.matches("01"))) {
                       success = true;
                   }

                   if (responseBundle.get("errorBundle") != null) {
                       Bundle errorBundle = new Bundle(responseBundle.getBundle("errorBundle"));
                   }
               }
           } else {
               Log.e(TAG, "Received error resultCode: " + result.getResultCode());
           }
       }
);

Error Handling

The following table contains typical errors that might occur and how to handle these errors:

ERROR MESSAGESOLUTION
Incorrect merchantIDEnsure that you have entered the correct merchantID.
authenticationKey is invalidWhen your authenticationKey is invalid, you will receive an error message indicating that the authenticationKey is invalid, a RETAIL_AUTH request needs to be done to obtain a valid authenticationKey.

Sample Bundle

The following is an example of a CARDQUERY ERROR response bundle that the MPOS Application will receive.

"resultDescription": "ABORTED",
"errorBundle": {
    "description": "ERROR",
    "reference": "",
    "errorType": "OTHER",
    "message": "Transaction cancelled by user"
  },
"buildInfo": "Ecentric_DEBUG_Ecentric_INT",
"resultCode": "03",
"merchantID": "910100000000001",
"serialNumber": "PC05P2CG10036",
"launchType": "CARDQUERY",
"appVersion": "1.9.8"

Did this page help you?