Fidel's real-time transaction monitoring allows you to monitor your customers' purchasing patterns. The first step, is of course, for customers to opt-in their credit cards for tracking at your locations. Dealing with card numbers opens up a requirement of "PCI Compliance." This is the Payment Card Industry Security Standard and requires regular security checks to ensure your systems are adequately protected.
If your systems are not PCI compliant, or you'd rather not worry about handling card numbers for real-time transactions, you can use Fidel's PCI compliant SDKs to link the cards. Thus absolving you of any security requirements for the process. Our documentation walks through the steps to add our SDK to a Java-based Android app, so in this post, we'll use Kotlin to accomplish the same.
Kotlin Android App
To add the SDK to an application, we'll build a basic "Hello World" Android app.
In Android Studio, start a new project:
Create an empty Activity from the templates:
Finally, name your application, choose Kotlin as your language, and use API 19 or higher (or use legacy support libraries to support older versions of Android).
Android Studio will chug for a bit but will create the working "Hello World" application for you.
Running the 'Hello World' app on your phone.
If you are new to Android development, you'll need to setup ADB debugging on your phone, and connect your phone to your computer. You can then click the "run" button in Android Studio to start the Hello World app:
The app will soon start up on your phone:
Adding in the Fidel SDK
Adding the Fidel SDK is easy: while the instructions in the documentation are for Java - Android Studio converts the code into Kotlin for you.
Let's walk through all of the steps we need to walk through to add the Fidel Card linking SDK to our sample app. Following the documentation, we need to:
- Add
maven { url 'https://jitpack.io' }
to our repositories section of ourbuild.grade
file. - Add
implementation 'com.github.FidelLimited:android-sdk:1.3.1'
to the App build.gradle dependencies. - Since you've updated your dependencies - sync your project.
- Now we can begin adding in our code to the MainActivity (and update the apiKey with your public key and the appropriate
programId
). You can find all this information in your Fidel Dashboard.
Fidel.apiKey = "pk_test_6e94da6f-145a-47db-b56b-f1314e74aa2e"
Fidel.programId = "f8d6890e-145d-46ea-b66f-afacfd954580"
- Now we add the Company name, privacy policy and deletion instructions. I also added the country parameter in this step:
Fidel.companyName = "Star Wars Quotes" // default: "Company Name".
Fidel.privacyURL = "https://media.giphy.com/media/4560Nv2656Gv0Lvp9F/giphy.gif"
// Maximum 60 characters, default: "going to your account settings."
Fidel.deleteInstructions = "https://media.giphy.com/media/DrDePYcSohIFG/giphy.gif"
Fidel.country = Fidel.Country.UNITED_KINGDOM;
- Paste in the result card response:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == Fidel.FIDEL_LINK_CARD_REQUEST_CODE) {
if (data != null && data.hasExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD)) {
val card = data.getParcelableExtra<Parcelable>(Fidel.FIDEL_LINK_CARD_RESULT_CARD) as LinkResult?
Log.d("d", "CARD ID = " + card!!.id)
}
}
}
- Finally, make sure to present the Fidel activity:
Fidel.present(this@MainActivity)
That is all there is to it - your app is now ready to run!
Card Linking on Android
There are 2 techniques to link your card with the Android SDK:
- The traditional way of entering the long card number/expiration date/CCV. Note also that if you have cards stored in Google Pay - your phone will attempt to autofill this for you. This is convenient for your customers, but real cards will fail in the Fidel test environment:
Entering a test number will sync with the Fidel backend:
- The Android SDK also has an optical card reader. By giving the application permission to use the camera:
The library in use does not appear to work for test cards found in a Google image search, but it does work with real cards.
Conclusion
With just a few lines of code, you can add the Fidel Android SDK to your application to allow your customers fast and easy sign up into your card linking service. Because the card numbers never touch your system, and the Fidel SDK is entirely PCI compliant, there are no security risks to you or your customers.
Let us know how you are using the Android SDK in your app over in the community forum.
Top comments (0)