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 is specified on the Ecentric Payment Server.

πŸ“˜

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");
  
   addDefaultToIntentBundle(dataBundle);

   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.

"resultDescription": "COMPLETED",
"buildInfo": "Ecentric",
"panData": "5210955001511518",
"resultCode": "00",
"merchantID": "invalid",
"serialNumber": "PC05P2CG10036",
"launchType": "CARDQUERY",
"track1Data": "B5210644001512518^ /^28036270000015400000000000000000000000000000",
"track2Data": "5210644001512518=28036270000000154000",
"transactionUuid": "e17cfa45-8c4c-4a75-90c4-6b861bbd7976",
"appVersion": "2.0.0"

Parameters

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

PARAMETERTYPEDESCRIPTIONEXAMPLE
launchTypeSTRINGEcho of the launchType used to launch the Ecentric Payment App.CARDQUERY
resultCodeSTRINGRepresents the result of the card query intent call:
● 00: COMPLETED
● 04: ERROR
00
merchantIDSTRINGEcho of the merchantID used in the request.910100000000001
resultDescriptionSTRINGA user readable representation of the above resultCode i.e. Approved for resultCode 01.COMPLETED
track1DataSTRINGContents of track 1 if availableB5210955001511518^ /^29056270000015400000000000000000000000000000
track2DataSTRINGContents of track 2 if available5210955001511518=29056270000000154000
panDataSTRINGPAN of card if available5210955001511518
transactionUuidSTRINGUnique ID of transaction. bdf9d0af-17b3-48ca-8a0b-37dc52bf49bc
serialNumberSTRINGThe serial number for the device that was used for the CARDQUERY intent call.PC05P2CB14336
appVersionSTRINGThe software version currently running on the Ecentric Payment App.1.9.2

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"