How to integrate Authorize.Net with Magento Android App?

How can you build a mobile app that accepts payments? Whether it’s a travel app or a fashion mobile commerce application, you need to somehow accept electronic payments for physical goods your customers want to purchase. Sales from mobile shopping are projected to continue rising, according to Forrester research. It’s critical to have a payment processing gateway that runs smoothly within your mobile app. Here we will learn to integrate Authorize.Net payment gateway in android mobile app.

The Accept Mobile SDKs, for Android and iOS, provide secure credit card processing, using the same API fields as the Apple Pay and Android Pay secure payment data. This provides maximum flexibility for in-app payments, without the payment data touching your servers.

Integrate Authorize.Net payment gateway in android

First of all create Sandbox account. To create Sandbox account Click Here


When you send the payment data to Authorize.Net, you use a public client key to secure it.

To obtain a public client key:

1. Log in to the Authorize.Net Merchant Interface using an administrator account.

2. Navigate to Account > Settings > Security Settings > General Settings > Manage Public Client Key.

3. Enter the secret answer to your secret question in the section Create New Public Client Key and click Submit. The client key is shown as a string.

Step 2: Installation

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

repositories {

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

Step 3:Initialize AcceptSDKApiClient

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

apiClient = new AcceptSDKApiClient.Builder 
            .connectionTimeout(5000) // optional connection time out in milliseconds

Step 4: Prepare Objects required to call Token API

Fetch token API require EncryptTransactionObject and it 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 require CardData object and it can be created as follows:

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

EncryptTransactionObject require Merchant Authentication object and it can be created as follows:

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

Step 5: Implement EncryptTransactionCallback Interface

To get a response back, the activity/fragment should implement the EncryptTransactionCallback interface. It has following 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 payment transaction.

public void onEncryptionFinished(EncryptTransactionResponse response) 
  Toast.makeText(getActivity(),response.getDataDescriptor() + " : " + response.getDataValue(),Toast.LENGTH_LONG).show();


This method will be called in three senarios,

 > 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();
  Toast.makeText(getActivity(),error.getMessageCode() + " : " + error.getMessageText() ,Toast.LENGTH_LONG).show();


If you want to integrate Authorize.Net payment gateway in android mobile app then you will find these steps more easy. Integration of Authorize.Net payment gateway in android mobile app has very easy steps as described above. You can edit the xml and activity files in your own way to make it more attractive as per your requirements.

There are various native e-commerce and Social Network mobile apps available in the market for example MagentoShop – Shopping App etc that use these steps to to use Authorize.Net payment gateway .

Looking for a native Magento mobile app builder (iOS/Android) for your Magento based online marketplace? Try the 30-day free trial of our Magento mobile app, go mobile commerce in a few hours and increase your sales exponentially. No Setup Fee, Pay as you go pack at just $69/month.


User Guide : Authorize.Net Mobile Application

Mobile SDK : Authorize.Net Accept Mobile SDK for Android

Leave a Comment

Scroll to Top