title: Un authorized transaction as the transaction already initiated
body: <p>i have completed payment gateway integration on web and want to do same integration on mobile app, but i am getting said error "Un authorized transaction as the transaction already initiated." while getting response, as am unable to handle session or there will be issue in the code. Please help me to get this close.</p>
  
  <p>**package com.payzak.epos;</p>
  
  <pre><code>import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.net.http.SslError;
  import android.os.Bundle;
  import android.util.Log;
  import android.webkit.CookieManager;
  import android.webkit.CookieSyncManager;
  import android.webkit.SslErrorHandler;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  /**
   * Created by nivedha on 4/1/2017.
   */
  
  public class Activity_PG extends Activity {
  
  public static String webURL,sessionId;
  
  @Override
  public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_pay_old);
  
  Intent in = getIntent();
  webURL = in.getExtras().getString("url");
  //sessionId = in.getExtras().getString("sessionId");
  
  WebView pgWebView = (WebView)findViewById(R.id.pgWebview);
  pgWebView.getSettings().setJavaScriptEnabled(true);
  pgWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  
  
  CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(pgWebView.getContext());
  CookieManager cookieManager = CookieManager.getInstance();
  cookieManager.setAcceptCookie(true);
  cookieManager.removeSessionCookie();
  //cookieManager.setCookie("https://securepgtest.fssnet.co.in:443/pgway/", sessionId);
  cookieSyncManager.sync();
  pgWebView.setWebViewClient(new AppWebViewClients());
  pgWebView.loadUrl(webURL);
      }
  
  public class myWebViewClient extends WebViewClient {
          @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
  view.loadUrl(url);
              return true;
          }
      }
  
      public class AppWebViewClients extends WebViewClient {
  
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
  
              Log.d("TAG", "shouldOverrideUrlLoading");
              Log.d("TAG", "actualURL: " + webURL);
              Log.d("TAG", "NewURL: " + url);
  
              view.loadUrl(url);
  
              return true;
  
          }
  
          @Override
          public void onPageStarted(WebView view, String url, Bitmap favicon) {
              super.onPageStarted(view, url, favicon);
              //SHOW LOADING IF IT ISNT ALREADY VISIBLE
              Log.d("TAG", "onPageStarted");
          }
  
          public void onPageFinished(WebView view, String url) {
  
          }
  
          public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
  
              Log.d("TAG", "Error Description: " + description);
              Log.d("TAG", "failingUrl: " + failingUrl);
          }
  
          @Override
          public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
              try{
                  final AlertDialog.Builder builder = new AlertDialog.Builder(Activity_PG.this);
                  builder.setMessage("notification_error_ssl_cert_invalid");
                  builder.setPositiveButton("continue", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          handler.proceed();
                      }
                  });
                  builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          handler.cancel();
                      }
                  });
                  final AlertDialog dialog = builder.create();
                  dialog.show();
              }catch (Exception e){
                  e.printStackTrace();
              }
          }
      }
  
  }
  </code></pre>