Swipe Reader SDK

Swipe Reader SDK

Prerequisites

For Sandbox (UAT)

Users should be onboarded on iPOSpays sandbox(UAT) environment as a merchant and have a valid TPN.

For Production (Live)

Users should be onboarded on iPOSpays production environment as a merchant and have a valid TPN.

If you do not have a TPN, contact your ISO or support@dejavoo.io.

The swipe_reader.aar file is provided with the kit. Download from here

Downloading the SwipeReaderSDK

  1. Locate the swipe_reader.aar file provided with your SwipeReader kit.
  2. Copy the swipe_reader.aar file to your project directory.

Configuring Gradle Dependencies

  1. Open your project's build.gradle file (located at the module level).
  2. Add the following dependencies within the dependencies block:
implementation files("../libs/swipe_reader.aar")
implementation "com.google.code.gson:gson:2.8.9"

The second line (optional) includes the Gson library (version 2.8.9) as an example dependency. You may need to adjust this based on your project's requirements.

Synchronizing Gradle

Click Sync Project with Gradle Files in Android Studio. This process updates your project with the SwipeReaderSDK and any additional dependencies you've included.

Get Card Details

To start reading swipe cards, call the read() method on the MsrReader instance.

MsrReader msrReader = new MsrReader(context, timeoutInSeconds);
msrReader.read(new SwipeResult() {
    
    @Override
    public void onSuccess(String result) {
        // Handle successful swipe
    }
 
    @Override
    public void onFailure(String error) {
        // Handle swipe failure
    }
 
    @Override
    public void onTimeOut(String message) {
        // Handle swipe timeout
    }
});

Sample code snippet for card reading by SDK

public class MainActivity extends AppCompatActivity {
 
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
 
      // Initialize card reader 
      MsrReader msrReader = new MsrReader(this, 60);
 
      // Read swipe card
      msrReader.read(new SwipeResult() {
 
          @Override 
          public void onSuccess(String s) {
              Log.d("onSuccess", s);
              runOnUiThread(()->Toast.makeText(context,s,Toast.LENGTH_SHORT).show());
          }
 
          @Override
          public void onFailure(String s) {
              Log.d("onFailure", s);
              runOnUiThread(()->Toast.makeText(context,s,Toast.LENGTH_SHORT).show());
          }
 
          @Override
          public void onTimeOut(String s) {
              Log.d("onTimeOut", s);
              runOnUiThread(()->Toast.makeText(context,s,Toast.LENGTH_SHORT).show());
          }
      });
    } 
  }

Response Fields

Output tagTypeFormat
responseCode * String

00

responseData * JSON

{”track1”:”527912186188049”,”track2”:”527912186188049”}

track1 – Provides data from track1 of card if available

track2 – Provides data from track2 of card if available

track3 – Provides data from track3 of card if available

responseMessage * String

SUCCESS – if data is available

FAILURE – If any error while reading the card

Here the responseData is a JSON String

The response will indicate success or failure. Here's what some of the outcome looks like:

Success Response

{ 
  "responseCode": "00",
  "responseData": "{\"track1\":\"527912186188049\",\"track2\":\"527912186188049\"}",
  "responseMessage": "SUCCESS"
}

Failure Response

{
  "responseCode": "06", 
  "responseData": "Failed to read card data",
  "responseMessage": "FAILURE"
}

Timeout Response

{
  "responseCode": "07",
  "responseData": "Card detection timeout",
  "responseMessage": "FAILURE"
}

Error Codes and Their Meaning

For a complete list of error codes and their explanations, please visit our Error Codes Reference Page.