
libs folder of your app.Ensure libs folder is included in flatDir repositories in your app's build.gradle file.
repositories {
flatDir {
dirs 'libs'
}
}
Add MonetaryMobileToken.aar to the dependencies in your app's build.gradle file.
dependencies {
compile (name: 'MonetaryMobileToken', ext: 'aar')
}
import co.monetary.mobiletoken.*;onActivityResult for MonetaryTokenizerActivity.MONETARY_TOKENIZER_REQUEST requestCode@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == MonetaryTokenizerActivity.MONETARY_TOKENIZER_REQUEST)
{
if (resultCode == MonetaryTokenizerActivity.RESULT_SUCCESS)
{
// A token has been received!
MonetaryToken token = (MonetaryToken)data.getSerializableExtra("token");
}
else if (resultCode == MonetaryTokenizerActivity.RESULT_ERROR)
{
// A tokenization error has occurred!
MonetaryTokenizationError error = (MonetaryTokenizationError)data.getSerializableExtra("error");
}
else if (resultCode == MonetaryTokenizerActivity.RESULT_CANCELED)
{
// The user has cancelled tokenization!
}
}
}For the MonetaryTokenizerActivity.RESULT_SUCCESS resultCode, the received Intent contains a MonetaryToken object named "token" that contains 5 String members:
token: The one-time-use token for the user-entered account data.brand: The card brand of account represented by the token.expirationMonth: The 2-digit expiration month of the account.expirationYear: The 4-digit expiration year of the account.last4: The last 4 digits of the account number.For the MonetaryTokenizerActivity.RESULT_ERROR resultCode, the received Intent contains a MonetaryTokenizationError object named "error" that contains 2 members:
errorCode: The MonetaryMobileToken error code.errorMessage: The error description.The MonetaryTokenizationError object's member errorCode is an enum of 4 possible values:
ErrorCodes.CONNECTION_ERROR:ErrorCodes.AUTHENTICATION_ERROR:ErrorCodes.VALIDATION_ERROR:ErrorCodes.UNKNOWN_ERROR:MonetaryTokenizerActivity and provide a Monetary public key as an extra named "publicKey" then start activity for result with the IntentIntent tokenIntent = new Intent(this, MonetaryTokenizerActivity.class);
tokenIntent.putExtra("publicKey", "[Public Key Goes Here]");
startActivityForResult(tokenIntent, MonetaryTokenizerActivity.MONETARY_TOKENIZER_REQUEST);If you encounter any bugs or issues with the latest version of MobileToken for Android, please report them to us by opening a GitHub Issue!