paytm integration android example sdk 2.1

Paytm Integration Android Example SDK 2.1 Step by Step

Watch Latest Paytm Integration tutorial 2019 Click Here

If you want to receive payment in India then paytm integration is very popular and easy to use. Paytm accept all types of payment like wallet payment and Debit card/credit card payment. In this android tutorial, You will learn how to integrate Paytm SDK 2.1 on android app in four easy steps. Here is the office link for Paytm SDK integration. First create a developer account using this link – Paytm Developer Account

Watch New Paytm Tutorial 2019 Click Here

Easy 4 Step Process

1) Create Login & Get Credentials from paytm integration
2) Upload PHP file on your server for Checksum Generation
3) Add Paytm SDK 2.1 jar file & Gradle Dependency
4) Get Checksum value from your server PHP file
5) Call Paytm Service to Make Payment

Login & Download source code



Get Credentials from Paytm

You need to create developer account on Paytm. There you don’t need to upload doc to start your development. You can go to sandbox and can get credential. Please note down all the values for future use.

paytm integration android example

Upload PHP file on your server for Checksum Generation

Now Let’s start with server side code. You don’t need to write single line of code on server side to create checksum. Paytm provides all the file that you need for checksum generation. You can find paytm android SDK link here and Get Paytm PHP kit here. Please download PHP file folder and Upload it on your server.

Now Inside the folder we have a file named generateChecksum.php and we need to use it for generating checksum for paytm integration.
But first we need to put our Paytm Merchant Key in the configuration.
Go to inside lib folder ( paytm/lib/config_paytm.php) and there you will find config_paytm.php, and put your Paytm Merchant Key. This is for server side only.
Staging And Production Credentials: Following credentials will be provided by Paytm after registering:

A Unique Merchant ID – This ID is unique for each merchant.
Website: A website name.
Industry Type ID: An ID for the Industry Type.
Paytm Merchant Key: This is a unique key which will be needed for generating & verifying checksums. This is a secret key and should never be passed along with request parameters in API calls to Paytm Servers.
Paytm CALLBACK_URL: this url is provided by Paytm so app can read the data from paytm
Channel id: An Id for the channel being used.

//Change the value of PAYTM_MERCHANT_KEY constant with details received from Paytm.

Add Paytm SDK 2.1 jar file & Gradle Dependency

Please download Paytm PGSDK from this link. Now Create new Android project and inside lib folder put the PGSDKv2.1.jar file. Add dependency on android project module gradle file – implementation files(‘libs/PGSDK_V2.1.jar’)

apply plugin: ''

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "blueappsoftware.shopeasypaytm"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation ''
    implementation ''
    testImplementation 'junit:junit:4.12'
    androidTestImplementation ''
    androidTestImplementation ''
    compile ''
  // for android studio below 3.0.1 
   compile files('libs/PGSDK_V2.1.jar')
    // for android studio  3.0.1 and later 
    implementation files('libs/PGSDK_V2.1.jar')

Adding Permissions and Paytm Activity

You need to add INTERNET and ACCESS_NETWORK_STATE permission, and PaytmPGActivity ( Get it from Here) for paytm integration. So open AndroidManifest.xml and modify it as below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

        <activity android:name="com.paytm.pgsdk.PaytmPGActivity"
            android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation|keyboard"/>

        <activity android:name=".checksum" />



Get Checksum value from your server PHP file

Now, First understand the process of paytm integration and payment transaction. You need to generate Checksum on your server then send this checksum along with other parameter to paytm transaction service. Please Remember All the param the you will use during checksum generation must pass topaytm transaction service. Also Order Id must be unique for each transaction other wise you will get OOPS Fail Transaction .

You can use Retrofit or Volley or HttpConnection for get checksum from your server. Once you get the checksum then you need to call PaytmPGService for test transaction.

            PaytmPGService Service =PaytmPGService.getStagingService();
           // when app is ready to publish use production service
             PaytmPGService  Service = PaytmPGService.getProductionService();

Then you need to initialize paytm order and start trasaction.

   PaytmOrder Order = new PaytmOrder(paramMap);

            // start payment service call here
            Service.startPaymentTransaction(checksum.this, true, true, checksum.this  );

Get Checksum & Call Payment Transaction

package blueappsoftware.shopeasypaytm;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

import com.paytm.pgsdk.PaytmMerchant;
import com.paytm.pgsdk.PaytmOrder;
import com.paytm.pgsdk.PaytmPGService;
import com.paytm.pgsdk.PaytmPaymentTransactionCallback;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

 * Created by kamal_bunkar on 02-02-2018.

public class checksum extends AppCompatActivity  implements PaytmPaymentTransactionCallback{

    protected void onCreate(Bundle savedInstanceState) {
//        setContentView(R.layout.activity_main);

        sendUserDetailTOServerdd dl = new sendUserDetailTOServerdd();


    public class sendUserDetailTOServerdd extends AsyncTask<ArrayList<String>, Void, String> {

        private ProgressDialog dialog = new ProgressDialog(checksum.this);

        private String orderId , mid, custid, amt;
        String url ="";
        String varifyurl = // "<ORDER_ID>"; //
        String CHECKSUMHASH ="";

        protected void onPreExecute() {
            this.dialog.setMessage("Please wait");

           // initOrderId();
            orderId ="KK100343";  // NOTE :  order id must be unique
            mid = "blueap01867059473586";  // CREATI42545355156573
            custid = "KKCUST0342";


        protected String doInBackground(ArrayList<String>... alldata) {

            // String  url ="";

            JSONParser jsonParser = new JSONParser(checksum.this);
            String  param=
                    "&ORDER_ID=" + orderId+
                    "&CHANNEL_ID=WEB&TXN_AMOUNT=100&"+"&CALLBACK_URL="+ varifyurl+"&INDUSTRY_TYPE_ID=Retail";

            Log.e("checksum"," param string "+param );

            JSONObject jsonObject = jsonParser.makeHttpRequest(url,"POST",param);
            // yaha per checksum ke saht order id or status receive hoga..
            Log.e("CheckSum result >>",jsonObject.toString());
            if(jsonObject != null){
                Log.e("CheckSum result >>",jsonObject.toString());
                try {

                    Log.e("CheckSum result >>",CHECKSUMHASH);

                } catch (JSONException e) {
            return CHECKSUMHASH;

        protected void onPostExecute(String result) {
            // jab run kroge to yaha checksum dekhega
            ///ab service ko call krna hai
            Log.e(" setup acc ","  signup result  " + result);
            if (dialog.isShowing()) {

            PaytmPGService Service =PaytmPGService.getStagingService();
           // when app is ready to publish use production service
            // PaytmPGService  Service = PaytmPGService.getProductionService();

            // now call paytm service here
            //below parameter map is required to construct PaytmOrder object, Merchant should replace below map values with his own values
            Map<String, String> paramMap = new HashMap<String, String>();
            //these are mandatory parameters
            // ye sari valeu same hon achaiye

            //MID provided by paytm
            paramMap.put("MID", mid);
            paramMap.put("ORDER_ID", orderId);
            paramMap.put("CUST_ID", custid);
            paramMap.put("CHANNEL_ID", "WEB");
            paramMap.put("TXN_AMOUNT", "100");
            paramMap.put("WEBSITE", "");
            paramMap.put("CALLBACK_URL" ,varifyurl);
            //paramMap.put( "EMAIL" , "");   // no need
           // paramMap.put( "MOBILE_NO" , "9144040888");  // no need
            paramMap.put("CHECKSUMHASH" ,CHECKSUMHASH);
            //paramMap.put("PAYMENT_TYPE_ID" ,"CC");    // no need
            paramMap.put("INDUSTRY_TYPE_ID", "Retail");

            PaytmOrder Order = new PaytmOrder(paramMap);

            Log.e("checksum ", paramMap.toString());

            // start payment service call here
            Service.startPaymentTransaction(checksum.this, true, true, checksum.this  );



    public void onTransactionResponse(Bundle bundle) {
        Log.e("checksum ", " respon true " + bundle.toString());

    public void networkNotAvailable() {


    public void clientAuthenticationFailed(String s) {


    public void someUIErrorOccurred(String s) {
        Log.e("checksum ", " ui fail respon  "+ s );

    public void onErrorLoadingWebPage(int i, String s, String s1) {
        Log.e("checksum ", " error loading pagerespon true "+ s + "  s1 " + s1);

    public void onBackPressedCancelTransaction() {
        Log.e("checksum ", " cancel call back respon  " );

    public void onTransactionCancel(String s, Bundle bundle) {
        Log.e("checksum ", "  transaction cancel " );


Run Code

Run the code and you will see paytm login screen. If you are seeing only transaction amount and not Login & signup text( as show on video) that means you are passing wrong paramHash for checksum and to Paytm service. Please cross check all the paramHash value and rerun the code with new Order-ID.

paytm android integration

If you have any question please comment below.


Posted in andorid and tagged , , , , , .

I Am Post Graduation (M.Tech. C.S.E) from VNIT, Nagpur. I Have Published Two Research Paper On International Journal. My Apps on Google Play Store- Sanyukt Parivar(Mp Police ), NOTOtag- Digital Chhindwara, The Tubby-VoiceRecognizer & More.
Contact me at


  1. I love your blog.. very nice colors & theme. Did you create this
    website yourself or did you hire someone to do it for you?
    Plz respond as I’m looking to create my own blog and would like to find
    out where u got this from. appreciate it

  2. Pretty great post. I just stumbled upon your weblog and wanted to say
    that I’ve truly loved browsing your blog posts.
    In any case I’ll be subscribing for your feed and I hope you write once more very soon!

  3. Hi there! This post could not be written any better!
    Reading through this post reminds me of my good old room mate!
    He always kept talking about this. I will forward this article to him.
    Fairly certain he will have a good read. Thank you for sharing!

  4. Hi there! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly?
    My weblog looks weird when browsing from my iphone4.
    I’m trying to find a template or plugin that might
    be able to fix this issue. If you have any recommendations, please share.
    Thank you!

  5. This is really attention-grabbing, You are an overly skilled blogger.
    I have joined your feed and look forward to in the hunt
    for extra of your great post. Also, I have shared your site in my social networks

  6. I’m really enjoying the theme/design of your blog.

    Do you ever run into any browser compatibility issues?

    A few of my blog audience have complained about my site not
    working correctly in Explorer but looks great in Chrome.
    Do you have any solutions to help fix this issue?

  7. I was recommended this web site by my cousin. I’m
    not sure whether this post is written by him as no one else
    know such detailed about my problem. You are wonderful!


  8. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your
    blog and I look forward to your new updates.

  9. Having read this I thought it was very informative. I appreciate you finding the time and
    energy to put this short article together. I once again find myself personally spending a lot of time both reading and posting comments.
    But so what, it was still worthwhile!

  10. hi! may i know is your code complete? because i run the program and does nothing, i have download the given source code.

    • Yes this code is working…You have to create file on php server to store FCM key into your database for future use. First check on your android studio log whether FCM token is printing OR not. If it is printing in log than send token to your web server.

  11. Good day! I could have sworn I’ve been to
    this website before but after going through
    a few of the articles I realized it’s new to me.

    Nonetheless, I’m certainly delighted I found it and I’ll be book-marking it and checking back regularly!

  12. Spot on with this write-up, I absolutely feel this website needs much more attention. I’ll probably be returning to read
    through more, thanks for the info!

  13. Hey very cool website!! Man .. Excellent ..
    Amazing .. I will bookmark your site and take the feeds additionally?
    I am glad to search out numerous useful info here
    in the submit, we need work out more strategies
    on this regard, thanks for sharing. . . . . .

  14. Pingback: ExoPlayer Android Example- Best Alternative of VideoView By Kamal

  15. Pingback: Simplest way to get WordPress Post in Android App- REST API

  16. I just like the helpful information you supply to your articles.

    I’ll bookmark your blog and test once more here frequently.
    I’m fairly sure I will learn many new stuff proper here!
    Good luck for the following!

Comments are closed.