Paytm Payment Gateway Integration in Android

This Tutorial explains, the right way to combine Paytm payment Gateway in our Android Application. Paytm offers payment gateway solution that may be integrated into web and mobile apps with Debit/ Credit Card, NetBanking, UPI and Paytm Wallet payment options. Paytm is quick, reliable and extra accessible payment solution. We can integrate paytm Gateway with any kind of mobile application. We already defined, the right way to integrate PayUbiz Payment Gateway in Android Application.

Don't Miss

Also try following Android Payment Integration:

Overview of Payment processing by way of Paytm Android SDK

We are looking, how the Paytm Android SDK works. Also we are able to check this from Paytm API Document.

  1. PHP

    https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_PHP

  2. JAVA

    https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_JAVA

  3. Python

    https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_Python

  4. Ruby

    https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_Ruby

  5. NodeJs

    https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_NodeJs

  6. .Net

    https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_DotNet

  • Our server passes the payload and checksumhash again to the app which fingers over these particulars to Paytm SDK
  • SDK verifies payload and shows fee Paytm checkout web page
  • Customer fills the fee particulars and completes the fee authentication. Once the fee is full, response is posted again to our app by way of callback
    Verify checksumhash obtained in response on our server facet.
  • Lastly, confirm transaction standing with Transaction Status API by way of server to server name. This protects us from situations the place our account credentials are compromised or request/response has been tampered.
  • Paytm online Payment SDK work flow

     

     

    Steps to begin fee gateway integration by way of Paytm Android SDK

     

     

    Create an Account on Paytm

    We want credentials of Paytm to combine on-line fee gateway, so we are going to create an account on Paytm. Go to Paytm and create account. After efficiently, created an account, we are able to get the Merchant Key and MID on the Paytm Gateway Dashboard.
    Paytm Gateway API keys

    SDK Installation and Setup

    We want to put in Paytm Android SDK within the app. Add the next dependency in our construct.gradle file:

    dependencies {
    	implementation('com.paytm:pgplussdk:1.4.4') {
    		transitive = true;
    	}
    }

    SMS Permission

    We want static and runtime sms permission to permit sdk to autoread the otp despatched by financial institution through the account verification.

    Add the next code to our AndroidManifest.xml to get static permission

    <uses-permission android:title="android.permission.INTERNET"/>
    <uses-permission android:title="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:title="android.permission.READ_SMS"/>
    <uses-permission android:title="android.permission.RECEIVE_SMS"/>

    Using the code under, we are able to get runtime permissions wanted from consumer to auto-read the OTP

    if (ContextCompat.checkSelfPermission(EssentialActivity.this, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED) {
    	ActivityCompat.requestPermissions(EssentialActivity.this, new String[]{Manifest.permission.READ_SMS, Manifest.permission.RECEIVE_SMS}, 101);
    }

    Proguard Rules

    If we’re utilizing proguard for construct, we have to add the next strains to our proguard file (proguard-rules.professional):

    keepclassmembers class com.paytm.pgsdk.paytmWebView$PaytmJavaScriptInterface {
       public *;
    }

    Layout Design

    We are making a easy format design. In which, we’re asking Customer ID, Order ID and transaction quantity to proceed fee. for this, we are going to add three EditText and a button to submit and begin one other exercise.

    <?xml model="1.0" encoding="utf-8"/>;
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:instruments="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        instruments:context=".MainActivity">
     
       <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:weightSum="1"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <Textual contentView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textual content="Studytutorial.in"
                    android:textStyle="bold"
                    android:textSize="24dip"
                    android:layout_marginTop="20dp"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginBottom="10dip"/>
            </LinearLayout>
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:id="@+id/orderID"
                android:trace="Order ID"/>
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:id="@+id/custId"
                android:trace="Customer ID"/>
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:id="@+id/txnAmount"
                android:trace="Amount"/>
            <Button
                android:layout_width="217dp"
                android:layout_height="wrap_content"
                android:id="@+id/start_transaction"
                android:textual content="Start Payment"
                android:textColor="#052e70"
                android:layout_gravity="center"
                android:textStyle="bold"
                android:textSize="16dip"
                android:background="#00baed"
                android:layout_marginTop="30dip"
                android:layout_weight="2.05" />
        </LinearLayout&amp;amp;>
     
    </androidx.constraintlayout.widget.ConstraintLayout>
    Paytm_Integration_layout

    Create Class MyConnection

    We will generate checksumhash by our server facet utility and in addition confirm by server facet. therefore we are going to create a generic class to set off hits to server. Create a java class named as MyConnection. Add the next code in our MyConnection.java file:

    import android.content material.Context;
    import android.os.Handler;
    import android.os.Looper;
    import android.widget.Toast;
    import org.json.JSONObject;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.web.HttpURLConnection;
    import java.web.URL;
    public class MyConnection {
            static JSONObject jObj = null;
            HttpURLConnection urlConnection = null;
            personal Context context;
            // constructor
            public MyConnection(Context context){
                this.context=context;
            }
            public JSONObject makeHttpRequest(String url, String methodology, String params) {
                attempt {
    
                    URL url1 = new URL(url);
                    // test for request methodology
                    HttpURLConnection urlConnection = (HttpURLConnection) url1.openConnection();
                    if (methodology == "POST") {
                        // request methodology is POST
                        urlConnection.setDoOutput(true);
                        urlConnection.setRequestMethod("POST");
                        urlConnection.setFixedLengthStreamingMode(params.getBytes().size);
                        urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                        PrintWriter out = new PrintWriter(urlConnection.getOutputStream());
                        out.print(params);
                        out.shut();
                    }
                    InputStream in = urlConnection.getInputStream();
                    byte[] bytes = new byte[10000];
                    StringBuilder sb = new StringBuilder();
                    int numRead = 0;
                    whereas ((numRead = in.learn(bytes)) != 0) {
                        sb.append(new String(bytes, 0, numRead));
                    }
                    String response = sb.toString();
                    jObj = new JSONObject(response);
                } catch (Exception e) {
                    e.printStackTrace();
                    new Handler(Looper.getMainLooper()).submit(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(context, "Connectivity issue. Please try again later.", Toast.LENGTH_LONG).present();
                        }
                    });
                    return null;
                }lastly {
                    if (urlConnection != null) {
                        urlConnection.disconnect();
                    }
                }
    
                return jObj;
            }
    }

    Download checkSum utility

    We are producing checksum & confirm Calllback url by server facet utilizing php. we are able to use any language for checksum utilities. We added a hyperlink above. Download the PHP-CHECKSUM-KIT here and change my Merchant KEY & Merchant ID out of your within the libs/config.php.

    Create a brand new Activity

    We must create a brand new exercise named as NamePaytmGateway. We will get the Order ID, Customer ID and transaction quantity within the EssentialActivity. We will go to the NamePaytmGateway by way of Intent. Add the next code within the EssentialActivity:

    import androidx.appcompat.app.AppCompatActivity;
    import androidx.core.app.ActivityCompat;
    import androidx.core.content material.ContextCompat;
    
    import android.Manifest;
    import android.content material.Intent;
    import android.content material.pm.PackageManager;
    import android.os.Bundle;
    import android.view.View;
    import android.view.WindowManager;
    import android.widget.Button;
    import android.widget.EditText;
    
    public class EssentialActivity extends AppCompatActivity {
        EditText OrderID, CUSTID, TXN_AMOUNT;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            tremendous.onCreate(savedInstanceState);
            setContentView(R.format.activity_main);
            //initOrderId();
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
            Button btn = (Button) discoverViewById(R.id.start_transaction);
            OrderID = (EditText) discoverViewById(R.id.orderID);
            CUSTID = (EditText) discoverViewById(R.id.custId);
            TXN_AMOUNT = (EditText) discoverViewById(R.id.txnAmount);
            btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(EssentialActivity.this, NamePaytmGateway.class);
                    intent.putExtra("ORDER_ID", OrderID.getText().toString());
                    intent.putExtra("CUST_ID", CUSTID.getText().toString());
                    intent.putExtra("TXN_AMOUNT", TXN_AMOUNT.getText().toString());
                    beginActivity(intent);
                }
            });
            if (ContextCompat.checkSelfPermission(EssentialActivity.this, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(EssentialActivity.this, new String[]{Manifest.permission.READ_SMS, Manifest.permission.RECEIVE_SMS}, 101);
            }
        }
    }
    

    Get Order Details

    We already handed the order particulars by way of Intent from EssentialActivity to NamePaytmGateway Activity. To get the order particulars, use the next code and in addition we outlined MID, checksum url & confirm url. Replace these out of your:

    public class NamePaytmGateway extends AppCompatActivity {
        String CUST_ID = "", ORDER_ID = "", MID = "YOUR_MID", TXN_AMOUNT = "";
        String checksumUrl = "YOUR_DOMAIN/checksum/generateChecksum.php";
        String verifyUrl = "YOUR_DOMAIN/checksum/verifyChecksum.php";
        String CheckSum = "";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            tremendous.onCreate(savedInstanceState);
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
            Intent intent = getIntent();
            ORDER_ID = intent.getExtras().getString("ORDER_ID");
            CUST_ID = intent.getExtras().getString("CUST_ID");
            TXN_AMOUNT = intent.getExtras().getString("TXN_AMOUNT");
    
        }
    }

    Generate Checksum

    We triggered to our server with POST information. In the backend, we now have to outline Merchant KEY. We will create a brand new Asynchronous methodology named advert SendPostRequest. In this methodology, we’re name sever to generate checksum and return it. After getting checksum, we are going to begin Paytm transaction service. Use the next code:

    public String getPostDataString(JSONObject params) throws Exception {
    
            StringBuilder end result = new StringBuilder();
            boolean first = true;
    
            Iterator<String> itr = params.keys();
    
            whereas (itr.hasNext()) {
    
                String key = itr.subsequent();
                Object worth = params.get(key);
    
                if (first)
                    first = false;
                else
                    end result.append("&");
    
                end result.append(URLEncoder.encode(key, "UTF-8"));
                end result.append("=");
                end result.append(URLEncoder.encode(worth.toString(), "UTF-8"));
    
            }
            return end result.toString();
        }
    
    
        public class SendPostRequest extends public class SendPostRequest extends AsyncTask<String, Void, String> {
            personal ProgressDialog dialog = new ProgressDialog(NamePaytmGateway.this);
    
            @Override
            protected void onPreExecute() {
                this.dialog.setMessage("Please wait");
                this.dialog.present();
            }
    
            protected String doInBackground(ArrayList<String>... alldata) {
                MyConnection jsonParser = new MyConnection(NamePaytmGateway.this);
                attempt {
    
                    JSONObject postDataParams = new JSONObject();
                    postDataParams.put("MID", MID);
                    postDataParams.put("CUST_ID", CUST_ID);
                    postDataParams.put("ORDER_ID", ORDER_ID);
                    postDataParams.put("TXN_AMOUNT", TXN_AMOUNT);
                    postDataParams.put("CHANNEL_ID", "WAP");
                    postDataParams.put("WEBSITE", "WEBSTAGING");
                    postDataParams.put("CALLBACK_URL", verifyUrl);
                    postDataParams.put("INDUSTRY_TYPE_ID", "Retail");
                    Log.e("params",getPostDataString(postDataParams));
    
                    JSONObject jsonObject = jsonParser.makeHttpRequest(checksumUrl, "POST", getPostDataString(postDataParams));
    
                    Log.e("Checksum result", jsonObject.toString());
                    if (jsonObject != null) {
                        Log.e("Checksum result", jsonObject.toString());
                        attempt {
                            CheckSum = jsonObject.has("CHECKSUMHASH") ? jsonObject.getString("CHECKSUMHASH") : "";
                            Log.e("CheckSum result", CheckSum);
    
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                return CheckSum;
            }
    
            @Override
            protected void onPostExecute(String end result) {
                if (dialog.isShowing()) {
                    dialog.dismiss();
                }
            }
        }
    }
    

    PHP code

    <?php
    header("Pragma: no-cache");
    header("Cache-Control: no-cache");
    header("Expires: 0");
    // following recordsdata should be included
    require_once("./lib/config_paytm.php");
    require_once("./lib/encdec_paytm.php");
    $checkSum = "";
    
    // under code snippet is necessary, in order that nobody can use your checksumgeneration url for different goal .
    $findme   = 'REFUND';
    $findmepipe = '|';
    
    $paramList = array();
    
    $paramList["MID"] = PAYTM_MERCHANT_ID; 
    $paramList["ORDER_ID"] = $_POST["ORDER_ID"];
    $paramList["CUST_ID"] = $_POST["CUST_ID"];
    $paramList["INDUSTRY_TYPE_ID"] = 'Retail';
    $paramList["CHANNEL_ID"] = 'WAP';
    $paramList["TXN_AMOUNT"] = $_POST["TXN_AMOUNT"];
    $paramList["WEBSITE"] = 'WEBSTAGING';
    foreach($_POST as $key=>$worth)
    {  
      $pos = strpos($worth, $findme);
      $pospipe = strpos($worth, $findmepipe);
      if ($pos === false || $pospipe === false) 
        {
            $paramList[$key] = $worth;
        }
    }
    
    
      
    //Here checksum string will return by getChecksumFromArray() operate.
    $checkSum = getChecksumFromArray($paramList,PAYTM_MERCHANT_KEY);
    //print_r($_POST);
     echo json_encode(array("CHECKSUMHASH" => $checkSum,"ORDER_ID" => $_POST["ORDER_ID"], "payt_STATUS" => "1"),JSON_UNESCAPED_SLASHES);
      //Sample response return to SDK
     
    //  {"CHECKSUMHASH":"GhAJV057opOCD3KJuVWesQ9pUxMtyUGLPAiIRtkEQXBeSws2hYvxaj7jRn33rTYGRLx2TosFkgReyCslu4OUj/A85AvNC6E4wUP+CZnrBGM=","ORDER_ID":"asgasfgasfsdfhl7","payt_STATUS":"1"} 
     
    ?>

    Initialization Paytm SDK

    To initialize the Paytm SDK, use under courses:

    Object: Service
    Service object is used to entry PG companies like initiating transaction, getting transaction callbacks and so forth. This is totally different for staging and manufacturing and created with following snippet:

    For Staging atmosphere:

    PaytmPGService Service = PaytmPGService.getStagingService();

    For Production atmosphere:

    PaytmPGService Service = PaytmPGService.getProductionService();

    Object: Order
    Stores all order associated info that are required to be handed by you to Paytm. Order object is created by following code snippet –

    PaytmPGService Service = PaytmPGService.getStagingService("");
    // when app is able to publish use manufacturing service
    // PaytmPGService  Service = PaytmPGService.getProductionService();
    // now name paytm service right here
    //under parameter map is required to assemble PaytmOrder object, Merchant ought to change under map values along with his personal values
    HashMap<String, String> paramMap = new HashMap<String, String&amp>;
    //these are necessary parameters
    paramMap.put("MID", MID); //MID supplied by paytm
    paramMap.put("ORDER_ID", ORDER_ID);
    paramMap.put("CUST_ID", CUST_ID);
    paramMap.put("CHANNEL_ID", "WAP");
    paramMap.put("TXN_AMOUNT", TXN_AMOUNT);
    paramMap.put("WEBSITE", "WEBSTAGING");
    paramMap.put("CALLBACK_URL", verifyUrl);
    paramMap.put("CHECKSUMHASH", CheckSum);
    paramMap.put("INDUSTRY_TYPE_ID", "Retail");
    PaytmOrder Order = new PaytmOrder(paramMap);
    Log.e("checksum ", "param " + paramMap.toString());
    
    Paytm Description of parameters used in hashmap object

    Handling callback from Paytm

    We must implement callback strategies to deal with fee response. This will present the fee standing and motive for transaction failures. Based on the explanations for failures, dealing with may be constructed at your finish. Transaction callbacks may be listened by way of overriding strategies of PaytmPaymentTransactionCallback.

    public class NamePaytmGateway extends AppCompatActivity implements PaytmPaymentTransactionCallback {
    }

    After transaction is full:
    Once the transaction is full, you’re going to get a JSON response. Note that completion of transaction doesn’t indicate that fee is profitable. Payment may be in profitable or failed state which must be derived from JSON.

        @Override
        public void onTransactionResponse(Bundle bundle) {
            Log.e("checksum ", " response " + bundle.toString());
        }
    

    User interface error:
    This is triggered when SDK is unable to load the fee web page. This would possibly occur in case SDK just isn’t in a position to parse the transaction payload obtained from the app.

        @Override
        public void someUIErrorOccurred(String s) {
            Log.e("checksum ", " UI fail response  " + s);
        }
    

    Network Error:
    Due to weak or no web connectivity on buyer’s system.

        @Override
        public void networkNotAvailable() {
        }
    

    Client authentication failure:
    This can occur because of a number of motive –

    • Paytm companies are usually not out there because of a downtime
    • Server unable to generate checksum or checksum response just isn’t in correct format
    • Server didn’t authenticate the shopper. That is worth of payt_STATUS is 2. // payt_STATUS hasn’t been outlined wherever
        @Override
        public void clientAuthenticationFailed(String s) {
        }
    

    Error in loading net web page:
    This is triggered when SDK is unable to load the fee web page. This would possibly occur because of server unavailability at Paytm’s finish or because of handshaking error with Paytm gateway.

       @Override
        public void onErrorLoadingWebPage(int i, String s, String s1) {
            Log.e("checksum ", " error loading page response " + s + "  s1 " + s1);
        }
    

    On press of again button
    This is triggered when consumer presses a again button on the fee web page. Followed by urgent the again button, there’s a reconfirmation taken from the client to depart the fee web page

        @Override
        public void onBackPressedCancelTransaction() {
            Log.e("checksum ", " cancel call back response  ");
        }
    

    On transaction cancelled:
    This is triggered when a transaction will get cancelled. In case consumer presses a again or cancel button and confirms to depart the web page, this callback is triggered

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

    Full NamePaytmGateway

    Full code of NamePaytmGateway. Use the next code:

    import android.app.ProgressDialog;
    import android.content material.Intent;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.WindowManager;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    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.web.URLEncoder;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    
    public class NamePaytmGateway extends AppCompatActivity implements PaytmPaymentTransactionCallback {
        String CUST_ID = "", ORDER_ID = "", MID = "aSwJFM41063048709765", TXN_AMOUNT = "";
        String checksumUrl = "https://studytutorial.in/checksum/generateChecksum.php";
        String verifyUrl = "https://studytutorial.in/checksum/verifyChecksum.php";
        String CheckSum = "";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            tremendous.onCreate(savedInstanceState);
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
            Intent intent = getIntent();
            ORDER_ID = intent.getExtras().getString("ORDER_ID");
            CUST_ID = intent.getExtras().getString("CUST_ID");
            TXN_AMOUNT = intent.getExtras().getString("TXN_AMOUNT");
            SendPostRequest sendPostRequest = new SendPostRequest();
            sendPostRequest.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    
        }
    
        @Override
        public void onTransactionResponse(Bundle bundle) {
            Log.e("checksum ", " response " + bundle.toString());
        }
    
        @Override
        public void networkNotAvailable() {
        }
    
        @Override
        public void clientAuthenticationFailed(String s) {
        }
    
        @Override
        public void someUIErrorOccurred(String s) {
            Log.e("checksum ", " UI fail response  " + s);
        }
    
        @Override
        public void onErrorLoadingWebPage(int i, String s, String s1) {
            Log.e("checksum ", " error loading page response " + s + "  s1 " + s1);
        }
    
        @Override
        public void onBackPressedCancelTransaction() {
            Log.e("checksum ", " cancel call back response  ");
        }
    
        @Override
        public void onTransactionCancel(String s, Bundle bundle) {
            Log.e("checksum ", "  transaction cancel ");
        }
    
        public String getPostDataString(JSONObject params) throws Exception {
    
            StringBuilder end result = new StringBuilder();
            boolean first = true;
    
            Iterator itr = params.keys();
    
            whereas (itr.hasNext()) {
    
                String key = itr.subsequent();
                Object worth = params.get(key);
    
                if (first)
                    first = false;
                else
                    end result.append("&");
    
                end result.append(URLEncoder.encode(key, "UTF-8"));
                end result.append("=");
                end result.append(URLEncoder.encode(worth.toString(), "UTF-8"));
    
            }
            return end result.toString();
        }
    
        public class SendPostRequest extends public class SendPostRequest extends AsyncTask<string, void,="" string=""> {
            personal ProgressDialog dialog = new ProgressDialog(NamePaytmGateway.this);
    
            @Override
            protected void onPreExecute() {
                this.dialog.setMessage("Please wait");
                this.dialog.present();
            }
    
            protected String doInBackground(ArrayList... alldata) {
                MyConnection jsonParser = new MyConnection(NamePaytmGateway.this);
                attempt {
    
                    JSONObject postDataParams = new JSONObject();
                    postDataParams.put("MID", MID);
                    postDataParams.put("CUST_ID", CUST_ID);
                    postDataParams.put("ORDER_ID", ORDER_ID);
                    postDataParams.put("TXN_AMOUNT", TXN_AMOUNT);
                    postDataParams.put("CHANNEL_ID", "WAP");
                    postDataParams.put("WEBSITE", "WEBSTAGING");
                    postDataParams.put("CALLBACK_URL", verifyUrl);
                    postDataParams.put("INDUSTRY_TYPE_ID", "Retail");
                    Log.e("params",getPostDataString(postDataParams));
    
                    JSONObject jsonObject = jsonParser.makeHttpRequest(checksumUrl, "POST", getPostDataString(postDataParams));
    
                    Log.e("Checksum result", jsonObject.toString());
                    if (jsonObject != null) {
                        Log.e("Checksum result", jsonObject.toString());
                        attempt {
                            CheckSum = jsonObject.has("CHECKSUMHASH") ? jsonObject.getString("CHECKSUMHASH") : "";
                            Log.e("CheckSum result", CheckSum);
    
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                return CheckSum;
            }
    
            @Override
            protected void onPostExecute(String end result) {
                if (dialog.isShowing()) {
                    dialog.dismiss();
                }
                PaytmPGService Service = PaytmPGService.getStagingService("");
                // when app is able to publish use manufacturing service
                // PaytmPGService  Service = PaytmPGService.getProductionService();
                // now name paytm service right here
                //under parameter map is required to assemble PaytmOrder object, Merchant ought to change under map values along with his personal values
                HashMap<string, string=""> paramMap = new HashMap<string, string="">
                //these are necessary parameters
                paramMap.put("MID", MID); //MID supplied by paytm
                paramMap.put("ORDER_ID", ORDER_ID);
                paramMap.put("CUST_ID", CUST_ID);
                paramMap.put("CHANNEL_ID", "WAP");
                paramMap.put("TXN_AMOUNT", TXN_AMOUNT);
                paramMap.put("WEBSITE", "WEBSTAGING");
                paramMap.put("CALLBACK_URL", verifyUrl);
                paramMap.put("CHECKSUMHASH", CheckSum);
                paramMap.put("INDUSTRY_TYPE_ID", "Retail");
                PaytmOrder Order = new PaytmOrder(paramMap);
                Log.e("checksum ", "param " + paramMap.toString());
                Service.initialize(Order, null);
                // begin fee service name right here
                Service.beginPaymentTransaction(NamePaytmGateway.this, true, true,
                        NamePaytmGateway.this);
    
            }
        }
    }
    

    Finally, we built-in Paytm Gateway in Android software. We can get the reference from Paytm Official Document.

    If you want this tutorial, like Facebook web page to get newest submit notification.

    3 COMMENTS

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here

    564FansLike

    Recent Posts

    How to Install & Setup the Java Development Kit (JDK)

    If you do not have the newest JDK already put in in your pc, comply with the steps under. You have to have the JDK put in to run applications. To see which version of...

    How to Setup Kotlin Plugin in Android Studio Tutorial

    Kotlin is a programming language launched by JetBrains, the official designer of essentially the most intelligent Java IDE, named Intellij IDEA. One nice information of shifting to Kotlin is, you...

    How to Parse Json in Android Application

    JSON stands for JavaScript Object Notation.It is an independent data trade format and is the perfect various for XML. This chapter explains the way to parse the JSON file and...

    Related Articles

    How to Install & Setup the Java Development Kit (JDK)

    If you do not have the newest JDK already put in in your pc, comply with the steps under. You have to have the JDK put in to run applications. To see which version of...

    How to Setup Kotlin Plugin in Android Studio Tutorial

    Kotlin is a programming language launched by JetBrains, the official designer of essentially the most intelligent Java IDE, named Intellij IDEA. One nice information of shifting to Kotlin is, you...

    How to Parse Json in Android Application

    JSON stands for JavaScript Object Notation.It is an independent data trade format and is the perfect various for XML. This chapter explains the way to parse the JSON file and...