Provide mobile in-app payments functionality within your Android application
Clone or download
Latest commit ea370c5 Oct 24, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src forcing TLS 1.2 for connections Oct 17, 2017
.gitignore Initial commit Jun 17, 2016
LICENSE Initial commit Jun 17, 2016 Update Oct 24, 2017
build.gradle New version to support TLS1.2 Oct 19, 2017 Title: Accept Android SDK first commit. Jul 11, 2016

Authorize.Net Accept Mobile SDK for Android

This SDK allows mobile developers to accept payments on a customer's mobile device from within their Android applications without having to pass sensitive card data back to their application backend servers. For more information on including payments in your mobile application see our In-App Payments Guide


  1. Installation
  2. Getting Started
  3. Sample Application

Installation (One Step)

Add the dependency from jCenter to your app's (not project's) build.gradle file.

repositories {

dependencies {
    compile 'net.authorize:accept-sdk-android:1.0.2'

Getting Started (Four Steps)


Android API 14+ is required as the minSdkVersion in your build.gradle

1. Initialize AcceptSDKApiClient

All SDK API's will be accessed through AcceptSDKApiClient Object, which can be created as follows:

// Parameters:
// 1) Context - Activity context
// 2) AcceptSDKApiClient.Environment - AUTHORIZE.NET ENVIRONMENT
apiClient = new AcceptSDKApiClient.Builder (getActivity(),
                                          .connectionTimeout(5000) // optional connection time out in milliseconds

2. Prepare Objects required to call Token API

Fetch token API requires EncryptTransactionObject, which can be created as follows:

 EncryptTransactionObject transactionObject = TransactionObject.
         createTransactionObject(TransactionType.SDK_TRANSACTION_ENCRYPTION)// type of transaction object
        .cardData(prepareCardDataFromFields()) // card data to be encrypted
        .merchantAuthentication(prepareMerchantAuthentication()) //Merchant authentication

EncryptTransactionObject requires cardData object, which can be created as follows:

CardData cardData = new CardData.Builder(CARD_NUMBER,
                                               EXPIRATION_MONTH, // MM
                                               EXPIRATION_YEAR) // YYYY
                                               .cvvCode(CARD_CVV) // Optional
                                               .zipCode(ZIP_CODE)// Optional
                                               .cardHolderName(CARD_HOLDER_NAME)// Optional

EncryptTransactionObject requires merchantAuthentication object, which can be created as follows:

ClientKeyBasedMerchantAuthentication merchantAuthentication = ClientKeyBasedMerchantAuthentication.
                createMerchantAuthentication(API_LOGIN_ID, CLIENT_KEY);

Check out the "Obtaining a Public Client Key" section in Accept Mobile for more information on getting CLIENT_KEY.

3. Calling Token API

When transaction information is ready, you can make the following call to fetch token:

// Parameters: 
// 1. EncryptTransactionObject - The transaction object for current transaction
// 2. transaction response callback.
apiClient.getTokenWithRequest(transactionObject, callback);

4. Implement EncryptTransactionCallback Interface.

To get a response back, the activity/fragment should implement the EncryptTransactionCallback interface. It has thefollowing methods:




This method will be called when token is successfully generated.EncryptTransactionResponse object has Data Descriptor and Data Value details which will be used to perform the payment transaction.

public void onEncryptionFinished(EncryptTransactionResponse response) 
                 response.getDataDescriptor() + " : " + response.getDataValue(),


This method will be called in three scenarios,

 > Validation of information is failed.
 > Network related errors.
 > API error response.

ErrorTransactionResponse may contain one or more error messages.

public void onErrorReceived(ErrorTransactionResponse errorResponse) 
 Message error = errorResponse.getFirstErrorMessage();
                 error.getMessageCode() + " : " + error.getMessageText() ,

Sample Application

We have a sample application which demonstrates the SDK usage:

Google Play In-App Billing API

Google’s developer terms require that purchases related to the app, such as premium features or credits, are made via their native Google Play In-app Billing API. See for more details.