未经授权的交易,因为交易已经启动

时间:2017-04-06 06:50:29

标签: javascript java android

我已经完成了网络上的支付网关集成,并希望在移动应用程序上进行相同的集成,但我得到了错误"未授权的交易,因为交易已经启动。"在获得响应时,由于无法处理会话或代码中存在问题。请帮我把它关闭。

** package com.payzak.epos;

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();
            }
        }
    }

}

0 个答案:

没有答案