Paytm Integration in Android Example – Accepting Payments with Paytm

Paytm is the most popular mobile wallet and payment method used in India. So I thought to publish a Paytm Integration in Android Example.
In this post, we will learn how can we add a Pay with Paytm method in our android application.
There is the official documentation about integrating Paytm at PayWithPaytm/Developer but that is very confusing, and if you are a newbie then you can face troubles. Here I will show you every step in detailed explanation so you can easily integrate Paytm payments in your application.

Getting Credentials from Paytm

The first step is getting credential from Paytm. Paytm provides it to all the merchants. So you need to signup as a merchant in Paytm. But the problem is it takes time, and you need to submit some docs like GST, Bank Account details.
But you do not need to worry as the developer can get sandbox access for development purposes.

  • Go to this link and sign in with your Paytm account.
  • You do not need to submit any details after Signup just click on Sandbox Access link as shown in the below image.
paytm sandbox
Paytm Sandbox
  • Now you will see your Sandbox Credential.
sandbox credential
Sandbox Credential
  • You are going to use the above credentials. Now lets integrate the Paytm Payment.

How to Integrate Paytm Payment into Android Application?

Let’s first understand how we add Paytm Payment in our Application. We need to perform these two steps.

  1. Generate CHECKSUM on our server.
  2. Accept Payment with Paytm SDK.

We need to generate the Checksum on our server, so the process requires some server-side implementation as well. And here on the server side, I am going to use PHP with Xampp Server.

And for sending Request from android side I will be using Retrofit.

Paytm Integration in Android Example

Configuring the Paytm Checksum Kit

Now let’s start the real process. We will start with the server-side implementation.

  • Open XAMPP Server and Start the Server. (Skip this step if you are using a live server).
  • Then download the Paytm App Checksum Kit. And paste it to your server’s root directory. (For XAMPP it is c:/xampp/htdocs by default)
paytm php kit
Paytm PHP Checksum Kit
  • I have renamed the folder to only paytm to make it short and simple.
  • Inside the folder we have a file named generateChecksum.php and we need to use it for generating checksum.
  • But first we need to put our Paytm Merchant Key in the configuration.
  • Go to config_paytm.php (it is inside the lib folder paytm/lib/config_paytm.php), and put your Paytm Merchant Key.

  • That’s it for the server side implementation, we just need to route to generateChecksum.php file. So it is localhost/paytm/generateChecksum.php.

But remember using localhost will not work you need to find the IP. You can see it using the ipconfig command, and if you are using a live server, then you can use the URL with your domain. 

Now, let’s move ahead by creating an Android Studio Project.

Integrating Paytm Payment in Android Project

Creating a New Project

  • First, we will create a new Android Studio Project. I have create a project named PaytmPaymentSample with an Empty Activity.

Adding Paytm SDK

  • Now download the Paytm SDK. Inside the SDK you will find a file named PGSDK_V2.1.jar. We need to add this file in our project dependencies.
  • So first on the project explorer select Project.

project explorer

  • Then inside app/lib paste the PGSDK_V2.1.jar that we downloaded.

adding paytm sdk

  • Now click on File->Project Structure.

project structure

  • Now from the top tabs go to dependency, and from the right green plus icon select jar dependency.

jar dependency

  • Now select the jar from the lib folder that you added, and hit ok.

adding dependency android studio

  • That’s it the Paytm SDK is added.

Adding Permissions and Paytm Activity

  • We need to add INTERNET and ACCESS_NETWORK_STATE permission, and PaytmPGActivity (The activity comes with the Paytm SDK that we already added).
  • So open AndroidManifest.xml and modify it as below.

Adding Retrofit and Gson

  • As I told you above that, we are going to use the Retrofit Library for sending network request. So for this, we need to Add Retrofit and Gson.
  • Come inside your app level build.gradle file and add both libraries.

Defining Constants

  • Now, we will define all the required constants in a separate class. For this create a new class named and define the following inside.
  • Remember you need to change the first 3 values according to the Paytm Credentials you got.

Creating User Interface

  • Now we will create a very Simple User Interface. So come inside activity_main.xml and write the following code.

  • The above code will generate the following layout.

paytm integration in android example

  • Make sure you add an image named macbook_air in the drawable folder. Or if the name of your image is different, then change it in the ImageView of your layout.

Creating Retrofit Models and Interface

Creating Models

We need two classes one is for CHECKSUM and other is for storing Paytm payment details.

  • First create a class named and write the following code.

  • Now create and write the following code.

Creating Retrofit API Interface
  • Create a new interface named

  • If you don’t know anything about using Retrofit you better go through the Retrofit Tutorial first.
  • Now come to and write the following code to complete our project.

  • Now you can try running your application.
paytm integration in android example
Paytm Integration in Android Example
  • Bingo! it is working fine.

Paytm Integration in Android Example – Source Code

  • If you are having some problem following this example, then you get my source code from my GitHub Repository. The link is given below.

So that’s all for this Paytm Integration in Android Example friends. I hope you found it useful if you did, please SHARE it with your friends.
And if you are having any query regarding this Paytm Integration in Android Example then don’t hesitate in commenting. Thank You 🙂

66 thoughts on “Paytm Integration in Android Example – Accepting Payments with Paytm”

  1. followed each of the above mentioned steps but in the payment gateway its says transaction to be made x amount
    but as u displayed the part where login/signup for paytm wallet come for payment transaction is not appearing to complete the transaction

    • Bruh, Its not possible to generate the Checksum from Firebase Hosting as it is used for static purposes only.. Try using it in local server, then use that php file to upload it on the live server as hosting..

    • You cannot use Firebase hosting for checksum generation as it is only used for static purposes. Try generating the checksum on a local server and do check that on a HTTP request client for verifying your checksum. Then copy the file to a live server.

  2. Hey Belal,

    What value should be for WEBSITE variable. As I am implementing this in app, what could be the website?
    I used your value for website but it is giving TimeoutError & unable to enqueue request.
    please help


  3. Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $

  4. getting following error when i launch app – android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class ImageView

  5. what is your CHANNEL_ID wap or web i had also same problem .mine was WAP but i was sending WEB in Constant class .make this change . it will work as expected

  6. Hello Bilal,

    I have done everything as same as you did. It is not working, When I am debugging the code it is onFailure of “call.enqueue” in the generateChecksum method.

    Not able to find why it is not going to success callback.

  7. Am getting this error
    “ java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ ‘
    I am using PHP kit for checksum with tomcat sever.
    my retrofit service call to getnerateChecksum.php function goes in onFailure() and gives above error

  8. Hello Bilal,

    I am also getting same error above
    “ java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ ‘
    I am using PHP kit for checksum with tomcat sever.
    my retrofit service call to getnerateChecksum.php function goes in onFailure() and gives above error

    I was unable to move forward because of this issue.

    Please reply…

  9. Good Afternoon , I have seen your video tutorial and took help from this post as well but there is an error when I compiled , after debugging I observe that after passing all the details onResponse() method is being skipped thus the app crashes .

    Help me to recover the error. Reply me with the improvisations.
    Thank You.

  10. is that the money is sent to any bank account?
    bcoz i want to create a wallet like application for my academic project in that i have to add money through paytm gateway so kindly help me with this issue

  11. Hello Belal,
    I checked this post, it is very useful… This is the best i found so far for paytm intergration.
    I have a query , i dont want to create sandbox credentials, i want to create live app.
    For this also, backend is required?
    Where should i set merchant key?

  12. I get this error after running above code. Please give me solution. failed to connect to / (port 80) after 10000ms

  13. Hi, thank you
    I followed every step and implemented successfully.
    I’m facing an issue after a successful transaction, I’m calling Transaction status API provided by paytm. But getting Internal processing error. please help

    class ConfirmTransactionStatus extends AsyncTask {
    protected String doInBackground(String… params) {
    String url =””;
    JSONParser jsonParser = new JSONParser(MainActivity.this);
    /*String param;

    param=”MID=” + MID+
    Map paramMap = new HashMap();
    paramMap.put(“MID”, MID);
    paramMap.put(“ORDERID”, ORDERID);

    JSONObject jsonObject = jsonParser.makeHttpRequest(url,”POST”,paramMap.toString());
    Log.e(“CheckSum result >>”,jsonObject.toString());
    if(jsonObject != null){
    Log.d(“CheckSum result >>”,jsonObject.toString());
    try {

    Log.e(“CheckSum result >>”,CHECKSUMHASH);

    } catch (JSONException e) {
    return null;

  14. This example is for accepting the payment from paytm . But what if i want to pay the user who are using my app. how can i implement this thing reply and give solution as soon as possible.Thanks in advance 🙂

  15. I am downloaded your enter source code and added my MID & credential buy is also working but after payment callback is not getting & get “opps” page when i contacted with paytm tech team say “You are missing checksumhash and callback url parameters in checksum generation file. It is mandatory all the parameters in checksum generation file and main file are same”.
    So can you please fix this and send me updated checksum generation file & main file.?

  16. Thanks bro !!! It worked great!!!
    PS: Use PHP version 5.x version. Don’t use PHP 7.x since the server-side utilities given by paytm uses php_mcrypt.dll which is deprecated in 7.x.

  17. Hi there,

    I really enjoy your videos which has helped me a lot too.

    About the integration, after clicking on buy (proceeding to payment), the page redirects to Paytm but the page – You are lost in space.

    What could be the reason for it. The order is registered. Is it the callback URL?

  18. this code doesn’t work for me .
    It doesn’t give any response on button click .Checksum is generated from server but it doesn’t receive it and not console the checksum value on file. So can u help me out.

  19. hey bro, i have a problem during sdk integration in android , so basically i have a problem while using localhost in generateChecksum.php file it said that getblock size () error what should i do??

  20. I have downloaded your source code but its not working . On click of buy button it is showing “” this exception .Retrofit call is going on onFailure .
    Could you please help .

    P.s: I have also added my merchant id and channel id .

  21. Hi, i followed your tutorialsteps….i am able to login …but showing insufficienr balance …even i have balance

  22. you have done with PHP with Xampp Server. i want to implement same thing with firebase. so How can i implement this? also how to add Paytm Checksum Kit file in my Firebase server?

  23. everything is working fine but i’m not getting the payment page means no error nothing …………. generatechecksum working fine then why i’m not getting the payment page plzzz help me out

  24. sir my project is done in xampp server and if i click my registered mobile no for payment so there is error is occured as says you are not registered and if i click on terms and condition so it says you are lost in space.

  25. I want to pay my user, so if user request to pay, amount will get debited form my paytm wallet and get added to users paytm wallet, can you please suggest or guide me any link or sample code for this.

    Thanks in advacne

  26. This way of paytm integration is no longer in use now. Paytm has removed addition of pgsdk.jar file in the whole procedure. Can you please update this blog with the new method and let me know what exactly I have to do. Please help me out.

  27. 1) PaymentOrder order = new PaymentOrder(paramMap); (paramMap) error shows in Android studio .

    2) After i added PaymentOrder order = new PaymentOrder((HashMap) paramMap);

    I’m getting a force close when clicked on buy button, logcat message :
    Nullpointerexception : Attempt to invoke virtual method ‘java.lang.String’ my packagename.Checksum.getChecksumHash() on a null object reference

  28. 1) PaymentOrder order = new PaymentOrder(paramMap); (paramMap) error shows in Android studio .

    2) After i added PaymentOrder order = new PaymentOrder((HashMap paramMap);

    I’m getting a force close when clicked on buy button, logcat message :
    Nullpointerexception : Attempt to invoke virtual method ‘java.lang.String’ my packagename.Checksum.getChecksumHash() on a null object reference

  29. I followed your tutorial, when i entered paytm gateway integration, it couldn’t work. the error message display 404 not found on my app. Help me

  30. hello,
    I have tried the same example demo in my android application, but on button click im getting 404 not found error page. Please give me the solution.

  31. Hello,

    I have done as per the steps mentioned in above tutorial but on button “Buy” click, I am getting 404 Not Found (nginx/1.6.2) error. Can you please help me with what is wrong here?


Leave a Comment