导航菜单

页面标题

页面副标题

Bhakti v5.4.0 - PaytmPGActivity.java 源代码

正在查看: Bhakti v5.4.0 应用的 PaytmPGActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.paytm.pgsdk;

import Ai.o;
import Yl.m;
import Zn.y0;
import android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.http.SslError;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.text.TextUtils;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import ap.q1;
import com.google.firebase.perf.network.FirebasePerfOkHttpClient;
import easypay.appinvoke.actions.EasypayBrowserFragment;
import easypay.appinvoke.manager.EasypayWebViewClient;
import easypay.appinvoke.manager.PaytmAssist;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONException;
import org.json.JSONObject;

public class PaytmPGActivity extends AppCompatActivity implements Ho.d, Ho.a {
    public static final int REQUEST_CODE_UPI_APP = 105;
    private static final int SMS_CONSENT_REQUEST = 2;
    private static final String UI_INITIALIZATION_ERROR_OCCURED = "Some error occured while initializing UI of Payment Gateway Activity";
    private static final int mAssistId = 101;
    private static final int mwebVId = 121;
    private boolean isAssistEnabled;
    private volatile LinearLayout loaderView;
    private Activity mActivity;
    public volatile FrameLayout mAssistLayout;
    private Context mContext;
    private Dialog mDlg;
    private String mId;
    private volatile Bundle mParams;
    private PaytmAssist mPaytmAssist;
    protected volatile ProgressBar mProgress;
    private volatile PaytmWebView mWV;
    private boolean mbHideHeader;
    private boolean mbSendAllChecksumResponseParametersToPGServer;
    private EasypayWebViewClient mwebViewClient;
    private BroadcastReceiver myReceiver;
    private String orderId;

    public synchronized void cancelTransaction() {
        g.p("Displaying Confirmation Dialog");
        AlertDialog.Builder builder = new AlertDialog.Builder(this, k.CancelDialogeTheme);
        builder.setTitle("Cancel Transaction");
        builder.setMessage("Are you sure you want to cancel transaction");
        builder.setPositiveButton("Yes", new b(this, 0));
        builder.setNegativeButton("No", new b(this, 1));
        AlertDialog create = builder.create();
        this.mDlg = create;
        create.show();
    }

    public void closeOrderApi() {
        e eVar;
        String str;
        String str2;
        String str3;
        HashMap hashMap;
        synchronized (e.class) {
            try {
                if (e.a == null) {
                    e.a = new e();
                }
                eVar = e.a;
            } finally {
            }
        }
        m mVar = new m(this, 12);
        eVar.getClass();
        y0 y0Var = d.c().a;
        if (y0Var == null || (hashMap = (HashMap) y0Var.b) == null) {
            str = null;
            str2 = null;
            str3 = null;
        } else {
            str2 = (String) hashMap.get("MID");
            str3 = (String) ((HashMap) y0Var.b).get("ORDER_ID");
            str = (String) ((HashMap) y0Var.b).get("TXN_TOKEN");
        }
        if (str2 == null || str3 == null) {
            d.c().d().v(null);
            finish();
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append("https://" + d.b() + "/theia/api/v2/closeOrder");
        sb.append("?orderId=");
        sb.append(str3);
        String r2 = o.r(sb, "&mid=", str2);
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        JSONObject jSONObject3 = new JSONObject();
        try {
            jSONObject3.put("mid", str2);
            jSONObject3.put("orderId", str3);
            jSONObject2.put("tokenType", "TXN_TOKEN");
            if (str != null) {
                jSONObject2.put("token", str);
            }
            jSONObject2.put("version", "v2");
            jSONObject2.put("requestTimestamp", System.currentTimeMillis());
            jSONObject.put("head", jSONObject2);
            jSONObject.put("body", jSONObject3);
        } catch (JSONException e4) {
            e4.printStackTrace();
        }
        Request build = new Request.Builder().url(r2).header("content-type", "application/json").header("Accept", "application/json").post(RequestBody.create(MediaType.parse("application/json"), jSONObject.toString().getBytes())).build();
        OkHttpClient.Builder newBuilder = new OkHttpClient().newBuilder();
        TimeUnit timeUnit = TimeUnit.SECONDS;
        FirebasePerfOkHttpClient.enqueue(newBuilder.connectTimeout(30L, timeUnit).writeTimeout(30L, timeUnit).readTimeout(30L, timeUnit).build().newCall(build), new q1(mVar, 8));
    }

    public void fillOtpOnWebPage(String str) {
        this.mWV.loadUrl(o.i("javascript:if(document.getElementById('inp')){document.getElementById('inp').focus();setTimeout(function(){document.getElementById('inp').value='", str, "'},0);}"));
    }

    public void getDataFromSmsBundle(Intent intent) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            try {
                Object[] objArr = (Object[]) extras.get("pdus");
                SmsMessage[] smsMessageArr = objArr != null ? new SmsMessage[objArr.length] : null;
                if (smsMessageArr != null) {
                    for (int i10 = 0; i10 < smsMessageArr.length; i10++) {
                        SmsMessage createFromPdu = SmsMessage.createFromPdu((byte[]) objArr[i10]);
                        smsMessageArr[i10] = createFromPdu;
                        createFromPdu.getOriginatingAddress();
                        fillOtpOnWebPage(parseOneTimeCode(smsMessageArr[i10].getMessageBody()));
                    }
                }
            } catch (Exception e4) {
                a.b().c("Redirection", e4.getMessage());
                e4.printStackTrace();
                Xb.e.K(e4, "EXCEPTION");
            }
        }
    }

    private synchronized boolean initUI() {
        try {
            try {
                if (getIntent() != null) {
                    this.mbHideHeader = getIntent().getBooleanExtra("HIDE_HEADER", false);
                    this.mbSendAllChecksumResponseParametersToPGServer = getIntent().getBooleanExtra("SEND_ALL_CHECKSUM_RESPONSE_PARAMETERS_TO_PG_SERVER", false);
                    this.mId = getIntent().getStringExtra("mid");
                    this.orderId = getIntent().getStringExtra("orderId");
                    this.isAssistEnabled = getIntent().getBooleanExtra("IS_ENABLE_ASSIST", true);
                    g.p("Assist Enabled");
                }
                g.p("Hide Header " + this.mbHideHeader);
                g.p("Initializing the UI of Transaction Page...");
                RelativeLayout relativeLayout = new RelativeLayout(this);
                relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
                this.loaderView = new LinearLayout(this);
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
                layoutParams.addRule(13);
                this.loaderView.setLayoutParams(layoutParams);
                this.loaderView.setOrientation(1);
                TextView textView = new TextView(this);
                textView.setText("Please wait");
                textView.setTypeface(textView.getTypeface(), 1);
                textView.setTextSize(0, getResources().getDimension(j.dimen_24sp));
                textView.setTextColor(-16777216);
                LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-2, -2);
                layoutParams2.topMargin = getResources().getDimensionPixelSize(j.dimen_7dp);
                layoutParams2.bottomMargin = getResources().getDimensionPixelSize(j.dimen_10dp);
                layoutParams2.gravity = 17;
                textView.setLayoutParams(layoutParams2);
                TextView textView2 = new TextView(this);
                textView2.setText("Loading...");
                textView2.setTextColor(-7829368);
                textView2.setTextSize(0, getResources().getDimension(j.dimen_18sp));
                LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(-2, -2);
                layoutParams3.gravity = 17;
                textView2.setLayoutParams(layoutParams3);
                relativeLayout.setBackgroundColor(-1);
                this.loaderView.addView(textView);
                this.loaderView.addView(textView2);
                RelativeLayout relativeLayout2 = new RelativeLayout(this);
                relativeLayout2.setLayoutParams(new RelativeLayout.LayoutParams(-1, -2));
                relativeLayout2.setId(1);
                relativeLayout2.setBackgroundColor(Color.parseColor("#bdbdbd"));
                Button button = new Button(this, null, R.attr.buttonStyleSmall);
                RelativeLayout.LayoutParams layoutParams4 = new RelativeLayout.LayoutParams(-2, -2);
                layoutParams4.addRule(15);
                layoutParams4.leftMargin = (int) (getResources().getDisplayMetrics().density * 5.0f);
                button.setOnClickListener(new Ab.j(this, 8));
                button.setLayoutParams(layoutParams4);
                button.setText("Cancel");
                TextView textView3 = new TextView(this);
                RelativeLayout.LayoutParams layoutParams5 = new RelativeLayout.LayoutParams(-2, -2);
                layoutParams5.addRule(13);
                textView3.setLayoutParams(layoutParams5);
                textView3.setTextColor(-16777216);
                textView3.setText("Paytm Payments");
                relativeLayout2.addView(button);
                relativeLayout2.addView(textView3);
                RelativeLayout relativeLayout3 = new RelativeLayout(this);
                RelativeLayout.LayoutParams layoutParams6 = new RelativeLayout.LayoutParams(-1, -1);
                layoutParams6.addRule(3, relativeLayout2.getId());
                relativeLayout3.setLayoutParams(layoutParams6);
                relativeLayout3.setBackgroundColor(-1);
                this.mWV = new PaytmWebView(this);
                this.mPaytmAssist = PaytmAssist.getAssistInstance();
                this.mAssistLayout = new FrameLayout(this, null);
                this.mWV.setVisibility(8);
                this.mWV.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
                this.mProgress = new ProgressBar(this, null, R.attr.progressBarStyleSmall);
                RelativeLayout.LayoutParams layoutParams7 = new RelativeLayout.LayoutParams(-2, -2);
                layoutParams7.addRule(13);
                this.mProgress.setLayoutParams(layoutParams7);
                RelativeLayout.LayoutParams layoutParams8 = new RelativeLayout.LayoutParams(-1, -2);
                layoutParams8.addRule(12);
                this.mAssistLayout.setId(101);
                this.mAssistLayout.setLayoutParams(layoutParams8);
                relativeLayout3.addView(this.mWV);
                relativeLayout3.addView(this.loaderView);
                relativeLayout3.addView(this.mAssistLayout);
                relativeLayout.addView(relativeLayout2);
                relativeLayout.addView(relativeLayout3);
                if (this.mbHideHeader) {
                    relativeLayout2.setVisibility(8);
                }
                setContentView(relativeLayout);
                startAssist();
                g.p("Initialized UI of Transaction Page.");
            } catch (Exception e4) {
                a.b().c("Redirection", e4.getMessage());
                g.p("Some exception occurred while initializing UI.");
                g.B(e4);
                return false;
            }
        } catch (Throwable th2) {
            throw th2;
        }
        return true;
    }

    private boolean isEasyPayFragmentAdded() {
        if (getSupportFragmentManager().T(101) != null) {
            return getSupportFragmentManager().T(101).isAdded();
        }
        return false;
    }

    public String parseOneTimeCode(String str) {
        if (str == null || str.isEmpty()) {
            Xb.e.K(this, "Message received is either null or empty");
            return "";
        }
        Matcher matcher = Pattern.compile("\\d{6}").matcher(str);
        if (!matcher.find()) {
            return "";
        }
        Matcher matcher2 = Pattern.compile("\\d{6}").matcher(matcher.group(0));
        if (!matcher2.find()) {
            return "";
        }
        String group = matcher2.group(0);
        Xb.e.K(this, "OTP found: " + group);
        return group;
    }

    private void setOtpHelperCallBack(String str) {
        EasypayBrowserFragment T9 = getSupportFragmentManager().T(101);
        if (T9 == null || T9.getCurrentNewOtpHelper() == null) {
            return;
        }
        PaytmAssist.getAssistInstance().registerSMSCallBack(T9.getCurrentNewOtpHelper());
        PaytmAssist.getAssistInstance().setAppSMSCallback(str);
    }

    private void startAssist() {
        if (!TextUtils.isEmpty(this.mId) && !TextUtils.isEmpty(this.orderId)) {
            this.mPaytmAssist.startConfigAssist(this, Boolean.valueOf(this.isAssistEnabled), Boolean.valueOf(this.isAssistEnabled), Integer.valueOf(this.mAssistLayout.getId()), this.mWV, this, this.orderId, this.mId);
            this.mWV.setWebCLientCallBacks();
            this.mPaytmAssist.startAssist();
        }
        EasypayWebViewClient webClientInstance = this.mPaytmAssist.getWebClientInstance();
        this.mwebViewClient = webClientInstance;
        if (webClientInstance == null) {
            g.p("EasyPayWebView Client:mwebViewClient Null");
        } else {
            g.p("EasyPayWebView Client:mwebViewClient");
            this.mwebViewClient.addAssistWebClientListener(this);
        }
    }

    private void startReadingSMS() {
        this.myReceiver = new Pb.k(this, 5);
        registerReceiver(this.myReceiver, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));
    }

    private synchronized void startTransaction() {
        try {
            g.p("Starting the Process...");
            this.mActivity = (Activity) this.mContext;
            if (getIntent() != null && getIntent().getBundleExtra("Parameters") != null) {
                this.mParams = getIntent().getBundleExtra("Parameters");
                if (this.mParams != null && this.mParams.size() > 0) {
                    if (d.c() != null && this.mWV != null) {
                        this.mWV.setId(121);
                        this.mWV.postUrl(d.c().b, g.t(this.mParams).getBytes());
                        this.mWV.requestFocus(130);
                        if (d.c().a != null && ((HashMap) d.c().a.b) != null) {
                            if (((HashMap) d.c().a.b).get("prenotificationurl") != null) {
                                Intent intent = new Intent(getApplicationContext(), (Class<?>) IntentServicePreNotification.class);
                                intent.putExtra("url", (String) ((HashMap) d.c().a.b).get("prenotificationurl"));
                                getApplicationContext().startService(intent);
                            }
                        }
                        f d10 = d.c().d();
                        if (d10 != null) {
                            d10.C("Transaction failed due to invaild parameters");
                        }
                        finish();
                    } else if (this.mWV == null) {
                        f d11 = d.c().d();
                        if (d11 != null) {
                            d11.C("Transaction failed because of values becoming null");
                        }
                        finish();
                    }
                }
            }
        } catch (Throwable th2) {
            throw th2;
        }
    }

    public void OnWcPageFinish(WebView webView, String str) {
        if (this.loaderView != null && this.loaderView.getVisibility() == 0) {
            this.loaderView.post(new c(this, 0));
        } else if (this.mWV != null && this.mWV.getVisibility() == 8) {
            this.mWV.post(new c(this, 1));
        }
        g.p("Pg Activity:OnWcPageFinish");
    }

    public void OnWcPageStart(WebView webView, String str, Bitmap bitmap) {
        g.p("Pg Activity:OnWcPageStart");
    }

    public void OnWcSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
        g.p("Pg Activity:OnWcSslError");
    }

    public void WcshouldInterceptRequest(WebView webView, String str) {
    }

    public boolean WcshouldOverrideUrlLoading(WebView webView, Object obj) {
        return false;
    }

    public void onActivityResult(int i10, int i11, Intent intent) {
        super.onActivityResult(i10, i11, intent);
        if (i10 != 105) {
            return;
        }
        String b = o.b(i11, "javascript:window.upiIntent.intentAppClosed(", ");");
        this.mWV.loadUrl(b);
        g.p("Js for acknowldgement" + b);
    }

    public void onBackPressed() {
        cancelTransaction();
    }

    public synchronized void onCreate(Bundle bundle) {
        try {
            requestWindowFeature(1);
            super.onCreate(bundle);
            if (bundle != null) {
                if (d.c() != null && d.c().d() != null) {
                    d.c().d().w();
                }
                finish();
            }
            if (this.isAssistEnabled && U1.b.a(this, "android.permission.RECEIVE_SMS") == 0 && U1.b.a(this, "android.permission.READ_SMS") == 0) {
                startReadingSMS();
            }
            if (initUI()) {
                this.mContext = this;
                startTransaction();
            } else {
                finish();
                f d10 = d.c().d();
                if (d10 != null) {
                    d10.m();
                }
            }
        } catch (Throwable th2) {
            throw th2;
        }
    }

    @Override
    public synchronized void onDestroy() {
        BroadcastReceiver broadcastReceiver;
        try {
            try {
                if (this.isAssistEnabled && (broadcastReceiver = this.myReceiver) != null) {
                    unregisterReceiver(broadcastReceiver);
                }
                d.c().g();
                e.a = null;
                PaytmAssist paytmAssist = this.mPaytmAssist;
                if (paytmAssist != null) {
                    paytmAssist.removeAssist();
                }
            } catch (Exception e4) {
                a.b().c("Redirection", e4.getMessage());
                d.c().g();
                g.p("Some exception occurred while destroying the PaytmPGActivity.");
                g.B(e4);
            }
            super.onDestroy();
            if (a.f12657d != null) {
                a.f12657d = null;
            }
        } catch (Throwable th2) {
            throw th2;
        }
    }

    public void onResume() {
        super.onResume();
    }

    public void smsReceivedCallback(String str) {
        g.p("SMS received:" + str);
    }
}