Overview

The Android SDK by CommBank Simplify allows you to create a card token (one time use token representing card details) in your Android app to send to a server to enable it to make a payment. By creating a card token, Simplify allows you to avoid sending card details to your server. The SDK can help with formatting and validating card information before the information is tokenised.

These steps will allow you to collect card information, retrieve a card token from Simplify, and
send the card token to your server in order to charge a card.

Import the dependency

To import the Android SDK, include it as a dependency in your build.gradle file.

compile 'com.simplify:simplify-android:3.0.0'

Note: Please make sure the 'minSdkVersion' value in your build.gradle file is 16 or later.

Initialise the SDK

Before you can communicate with CommBank Simplify to tokenise a card, you must first initialise the SDK with your public API key. To retrieve a usable public API key, first log in to simplify.com and click on “API Keys” in the dropdown menu next to your name. From there, you can create a new public key specific to your app, or use an existing one. Be sure to use a “live” key for your production app. Card tokens created with a sandbox API key cannot be used to process real payments!

To initialise the SDK, set the API key in an instance of the Simplify object.

Manual Card / Custom UI

If you are using your own UI to collect card data from the user, you should build a Simplify Card object with this data.
Refer to the
CardToken API docs for the minimum required fields to tokenise a card.

Within your context, you can register a state change listener to receive notifications when the valid state of the view has changed after the user has entered details.
You may use this to enable/disable a checkout button as demonstrated below.

Android Pay

To enable Android Pay support within your app, refer to the Android Pay API tutorial. These instructions should guide you in how to:

Obtain a Google API key

Create an instance of the GoogleAPIClient

Incorporate the WalletFragment into your layout

Construct the masked and full wallet requests

Since Android Pay integration is optional with the CommBank Simplify SDK, you must provide the appropriate play services dependency.

compile 'com.google.android.gms:play-services-wallet:9.4.0'

In order to request encrypted card information from the Android Pay wallet, you must include the Android Pay public key in the PaymentMethodTokenizationParameters.
You can retrieve your public key by visiting Account Settings.

The CommBank Simplify SDK offers an Android Pay lifecycle handler for added convenience. You may implement the provided Android Pay callback and use the result handler within your Activity.
This alleviates the need to manually handle the Android Pay activity results, and will delegate the important transaction steps to callback methods.

Process a Payment

Regardless of which method you are using to collect card information, you should ultimately end up with a Simplify CardToken object. This one-time token should be sent back to your servers for processing. This is a highly recommended step to ensure your payment processing and your private API keys are kept secure.

Your private keys are considered sacred and can be used to process payments, issue refunds, and more.
A common development mistake is to simply include the Java SDK in an app and use a private key to complete the transaction lifecycle without involving a server.
While it may seem like an easy way to integrate payments, distributing your private key in an app leaves it vulnerable through simple reverse engineering.
Once compromised, an attacker can use your key to perform almost every operation offered through our APIs.
This is bad security practice. In addition, since keys can be revoked from the API Keys page, they are also considered volatile.
If a private key is revoked, any app using it will be broken until an update is released with a new key.
The bottom line is this: Don't do it. We will find you. :)

Rx-Enabled

If being reactive is your thing, then we've got you covered. Include the
RxJava library in your project,
then use the appropriate methods provided in the Simplify object.