导航菜单

页面标题

页面副标题

Crafto v9.3.3 - PhonePe.java 源代码

正在查看: Crafto v9.3.3 应用的 PhonePe.java JAVA 源代码文件

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


package com.phonepe.intent.sdk.api;

import Hk.e;
import Xn.g;
import Xn.p;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
import android.util.Log;
import androidx.annotation.NonNull;
import co.c;
import com.google.firebase.crashlytics.internal.metadata.UserMetadata;
import com.paytmpayments.customuisdk.common.Constants.SDKConstants;
import com.phonepe.intent.sdk.api.PhonePe;
import com.phonepe.intent.sdk.api.ShouldShowMandateCallback;
import com.phonepe.intent.sdk.api.ShowPhonePeCallback;
import com.phonepe.intent.sdk.api.UserValidityCallback;
import com.phonepe.intent.sdk.api.models.PhonePeEnvironment;
import com.phonepe.intent.sdk.api.models.SDKType;
import com.phonepe.intent.sdk.contracts.DeviceIdListener;
import com.phonepe.intent.sdk.ui.B2BPGActivity;
import com.phonepe.intent.sdk.ui.OpenIntentTransactionActivity;
import com.phonepe.intent.sdk.ui.PreCacheService;
import com.phonepe.intent.sdk.ui.TransactionActivity;
import com.phonepe.intent.sdk.ui.UpiAppsSelectionDialogActivity;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import jmjou.jmjou;
import kotlin.Pair;
import kotlin.collections.P;
import kotlin.collections.Q;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONException;
import org.json.JSONObject;
import rmqfk.qwsnv;
import rmqfk.rmqfk;
import rmqfk.uauho;
import wlgrx.cqqlq;
import wlgrx.zihjx;
import xl.a;
import xl.d;
import xl.h;
import xl.j;
import xl.l;
import xl.q;
import xl.t;
import zk.b;

public class PhonePe {
    public static final String TAG = "PhonePe";
    public static jmjou irjuc;

    public class irjuc implements CheckPhonePeAvailabilityInternalCallback {
        public final CheckPhonePeAvailabilityCallback cqqlq;
        public final AtomicBoolean irjuc;

        public irjuc(AtomicBoolean atomicBoolean, CheckPhonePeAvailabilityCallback checkPhonePeAvailabilityCallback) {
            this.irjuc = atomicBoolean;
            this.cqqlq = checkPhonePeAvailabilityCallback;
        }

        @Override
        public final void onFailure(boolean z, @NonNull String str) {
            Intrinsics.checkNotNullParameter("CHECK_AVAILABILITY_API_CALL_FAILURE", "eventName");
            try {
                d d = b.b().d(d.class);
                d.a(d.b("CHECK_AVAILABILITY_API_CALL_FAILURE"));
            } catch (Exception e) {
                a.d("EventDebug", "error in send event", e);
            }
            PhonePe.irjuc(true, "SUCCESS", this.irjuc, this.cqqlq);
        }

        @Override
        public final void onSuccess(boolean z, @NonNull String str) {
            Intrinsics.checkNotNullParameter("CHECK_AVAILABILITY_API_CALL_SUCCESS", "eventName");
            try {
                d d = b.b().d(d.class);
                d.a(d.b("CHECK_AVAILABILITY_API_CALL_SUCCESS"));
            } catch (Exception e) {
                a.d("EventDebug", "error in send event", e);
            }
            PhonePe.irjuc(z, str, this.irjuc, this.cqqlq);
        }
    }

    @e
    public PhonePe(Context context) {
        irjuc(context);
        try {
            cqqlq().getClass();
            if (!t.j((Boolean) jmjou.f("com.phonepe.android.sdk.PreCacheEnabled")) || Build.VERSION.SDK_INT > 25) {
                return;
            }
            Intent intent = new Intent(context, (Class<?>) PreCacheService.class);
            intent.putExtra("data_factory", (Parcelable) cqqlq());
            context.startService(intent);
        } catch (PhonePeInitException e) {
            a.d(TAG, e.getMessage(), e);
        }
    }

    @MerchantAPI
    public static void checkAvailability(AvailabilityCheckRequest availabilityCheckRequest, CheckPhonePeAvailabilityCallback checkPhonePeAvailabilityCallback) throws PhonePeInitException {
        String str;
        HashMap hashMap = new HashMap();
        hashMap.put("merchantRequest", availabilityCheckRequest.toString());
        Intrinsics.checkNotNullParameter(q.zihjx, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "CHECK_AVAILABILITY")});
        if (!hashMap.isEmpty()) {
            h.putAll(hashMap);
        }
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        AtomicBoolean atomicBoolean = new AtomicBoolean(false);
        jmjou jmjouVar = b.a;
        if (!b.a(cqqlq())) {
            if (!t.a(cqqlq())) {
                str = "PHONEPE_APP_NOT_INSTALLED";
            } else if (b.d(cqqlq(), t.c(irjuc))) {
                c d2 = irjuc.d(c.class);
                boolean z = d2.a.b().getBoolean("availability_check_enabled", true);
                long j = d2.a.b().getLong("availability_check_timeout_ms", 5000L);
                if (z) {
                    irjuc(atomicBoolean, j, availabilityCheckRequest, checkPhonePeAvailabilityCallback);
                    return;
                }
            } else {
                str = "UPI_NOT_REGISTERED";
            }
            irjuc(false, str, atomicBoolean, checkPhonePeAvailabilityCallback);
            return;
        }
        irjuc(true, "SUCCESS", atomicBoolean, checkPhonePeAvailabilityCallback);
    }

    public static ShouldShowMandateCallbackResult cqqlq(JSONObject jSONObject) {
        a.c(TAG, "json result from app for should show mandate : " + jSONObject.toString());
        return (jSONObject.optBoolean("loggedIn", false) && jSONObject.optBoolean("linkedUpiBankAccount", false)) ? new ShouldShowMandateCallbackResult(jSONObject.optBoolean("singleMandateSupportedAccountAvailable", false), jSONObject.optBoolean("recurringMandateSupportedAccountAvailable", false)) : new ShouldShowMandateCallbackResult(false, false);
    }

    @MerchantAPI
    public static void getDeviceId(Context context, DeviceIdListener deviceIdListener) throws PhonePeInitException {
        cqqlq().d(l.class).b(true, deviceIdListener);
    }

    @MerchantAPI
    public static Intent getImplicitIntent(Context context, @NonNull B2BPGRequest b2BPGRequest, String str) throws PhonePeInitException {
        HashMap hashMap = new HashMap();
        hashMap.put("merchantRequest", b2BPGRequest.toString());
        Intrinsics.checkNotNullParameter(q.rmqfk, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "PG_PAY")});
        if (!hashMap.isEmpty()) {
            h.putAll(hashMap);
        }
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        Parcelable cqqlq = cqqlq();
        int i = B2BPGActivity.m;
        Intrinsics.checkNotNullParameter(cqqlq, "objectFactory");
        uauho d2 = cqqlq.d(uauho.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("data_factory", cqqlq);
        bundle.putParcelable("request", b2BPGRequest);
        bundle.putParcelable("sdk_context", d2);
        bundle.putString("openIntentWithApp", str);
        Intent intent = new Intent(context, (Class<?>) B2BPGActivity.class);
        intent.putExtras(bundle);
        return intent;
    }

    @MerchantAPI
    public static String getPackageSignature() throws PhonePeInitException {
        cqqlq().getClass();
        return jmjou.g();
    }

    public static long getPhonePeAppVersionCode() throws PhonePeInitException {
        return t.b(cqqlq(), t.c(cqqlq()));
    }

    @MerchantAPI
    public static String getSDKVersion() {
        return "2.4.1";
    }

    @MerchantAPI
    public static Intent getTransactionIntent(@NonNull TransactionRequest transactionRequest) throws PhonePeInitException {
        HashMap hashMap = new HashMap();
        hashMap.put("merchantRequest", transactionRequest.toString());
        Intrinsics.checkNotNullParameter(q.cqqlq, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "DEBIT")});
        if (!hashMap.isEmpty()) {
            h.putAll(hashMap);
        }
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        cqqlq().getClass();
        Context context = jmjou.a;
        Parcelable cqqlq = cqqlq();
        int i = TransactionActivity.l;
        uauho d2 = cqqlq.d(uauho.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("data_factory", cqqlq);
        bundle.putParcelable("request", transactionRequest);
        bundle.putParcelable("sdk_context", d2);
        Intent intent = new Intent(context, (Class<?>) TransactionActivity.class);
        intent.putExtras(bundle);
        return intent;
    }

    public static List<UPIApplicationInfo> getUpiApps() throws PhonePeInitException {
        Intrinsics.checkNotNullParameter(q.dphej, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "GET_UPI_APPS")});
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        Intent intent = new Intent();
        intent.setData(j.a.a);
        List g = t.g(cqqlq(), intent);
        ArrayList arrayList = new ArrayList();
        if (cqqlq() != null) {
            cqqlq().getClass();
            if (jmjou.a != null && g != null) {
                cqqlq().getClass();
                PackageManager packageManager = jmjou.a.getPackageManager();
                Iterator it = g.iterator();
                while (it.hasNext()) {
                    ActivityInfo activityInfo = ((ResolveInfo) it.next()).activityInfo;
                    arrayList.add(new UPIApplicationInfo(activityInfo.packageName, packageManager.getApplicationLabel(activityInfo.applicationInfo).toString(), t.b(cqqlq(), r4)));
                }
            }
        }
        return arrayList;
    }

    @e
    @MerchantAPI
    public static void init(Context context) {
        try {
            cqqlq(context);
            HashMap irjuc2 = irjuc();
            Intrinsics.checkNotNullParameter(q.irjuc, "sdkApiName");
            LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "INIT")});
            if (!irjuc2.isEmpty()) {
                h.putAll(irjuc2);
            }
            Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
            try {
                d d = b.b().d(d.class);
                qwsnv b = d.b("SDK_API_CALLED");
                for (Map.Entry entry : h.entrySet()) {
                    b.b(entry.getValue(), (String) entry.getKey());
                }
                d.a(b);
            } catch (Exception e) {
                a.d("EventDebug", "error in send event", e);
            }
        } catch (Exception e2) {
            a.d(TAG, e2.getMessage(), e2);
        }
    }

    public static HashMap irjuc() throws PhonePeInitException {
        String str;
        String str2;
        String str3;
        String str4;
        HashMap hashMap = new HashMap();
        cqqlq().getClass();
        String str5 = "";
        if (jmjou.f("com.phonepe.android.sdk.MerchantId") != null) {
            cqqlq().getClass();
            str = (String) jmjou.f("com.phonepe.android.sdk.MerchantId");
        } else {
            str = "";
        }
        hashMap.put("manifestMerchantId", str);
        cqqlq().getClass();
        if (jmjou.f("com.phonepe.android.sdk.AppId") != null) {
            cqqlq().getClass();
            str5 = (String) jmjou.f("com.phonepe.android.sdk.AppId");
        }
        hashMap.put("manifestAppId", str5);
        cqqlq().getClass();
        String str6 = "false";
        if (jmjou.f("com.phonepe.android.sdk.isUAT") != null) {
            cqqlq().getClass();
            str2 = jmjou.f("com.phonepe.android.sdk.isUAT").toString();
        } else {
            str2 = "false";
        }
        hashMap.put("manifestIsUat", str2);
        cqqlq().getClass();
        if (jmjou.f("com.phonepe.android.sdk.PreCacheEnabled") != null) {
            cqqlq().getClass();
            str3 = jmjou.f("com.phonepe.android.sdk.PreCacheEnabled").toString();
        } else {
            str3 = "false";
        }
        hashMap.put("manifestIsPreCacheEnabled", str3);
        cqqlq().getClass();
        if (jmjou.f("com.phonepe.android.sdk.isSimulator") != null) {
            cqqlq().getClass();
            str4 = jmjou.f("com.phonepe.android.sdk.isSimulator").toString();
        } else {
            str4 = "false";
        }
        hashMap.put("manifestIsSimulator", str4);
        cqqlq().getClass();
        if (jmjou.f("com.phonepe.android.sdk.isSimulatorStage") != null) {
            cqqlq().getClass();
            str6 = jmjou.f("com.phonepe.android.sdk.isSimulatorStage").toString();
        }
        hashMap.put("manifestIsSimulatorStage", str6);
        return hashMap;
    }

    @e
    @MerchantAPI
    public static boolean isAppInstalled() throws PhonePeInitException {
        return t.a(cqqlq());
    }

    @MerchantAPI
    public static boolean isGooglePayAppInstalled(boolean z) throws PhonePeInitException {
        if (!z) {
            jmjou cqqlq = cqqlq();
            cqqlq.getClass();
            Context context = jmjou.a;
            cqqlq.d(j.class).getClass();
            return t.i(context, "com.google.android.apps.nbu.paisa.user");
        }
        jmjou cqqlq2 = cqqlq();
        cqqlq2.getClass();
        Context context2 = jmjou.a;
        cqqlq2.d(j.class).getClass();
        if (t.i(context2, "com.google.android.apps.nbu.paisa.user")) {
            jmjou jmjouVar = b.a;
            jmjou cqqlq3 = cqqlq();
            irjuc.d(j.class).getClass();
            if (b.d(cqqlq3, "com.google.android.apps.nbu.paisa.user")) {
                return true;
            }
        }
        return false;
    }

    @MerchantAPI
    public static void isMandateSupported(final ShouldShowMandateCallback shouldShowMandateCallback) throws PhonePeInitException {
        a.c(TAG, "isMandateSupported started");
        h.a.b(q.wlgrx, (HashMap) null);
        jmjou jmjouVar = b.a;
        if (b.a(cqqlq())) {
            irjuc(true, true, shouldShowMandateCallback);
            return;
        }
        if (!t.a(cqqlq())) {
            a.c(TAG, "app is not installed");
            h.a.a("APP_NOT_INSTALLED", (Map) null);
            irjuc(false, false, shouldShowMandateCallback);
            return;
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("loggedIn", true);
            jSONObject.put("linkedUpiBankAccount", true);
            jSONObject.put("singleMandateSupportedAccountAvailable", true);
            jSONObject.put("recurringMandateSupportedAccountAvailable", true);
            irjuc(jSONObject);
        } catch (Exception e) {
            a.d(TAG, e.getMessage(), e);
        }
        Intrinsics.checkNotNullParameter("APP_COMM_STARTED", "eventName");
        try {
            d d = b.b().d(d.class);
            d.a(d.b("APP_COMM_STARTED"));
        } catch (Exception e2) {
            a.d("EventDebug", "error in send event", e2);
        }
        a.c(TAG, "communicating with app now");
        String jSONObject2 = jSONObject.toString();
        RequestCallback requestCallback = new RequestCallback() {
            @Override
            public final void onResponse(String str) {
                PhonePe.irjuc(ShouldShowMandateCallback.this, str);
            }
        };
        jmjou.a d2 = irjuc.d(jmjou.a.class);
        d2.put("request", "checkUpiMandateSupported");
        d2.put("constraints", jSONObject2);
        d2.put("callback", requestCallback);
        irjuc.e(Ri.a.class, d2);
    }

    @MerchantAPI
    public static boolean isPayTMAppInstalled(boolean z) throws PhonePeInitException {
        if (!z) {
            jmjou cqqlq = cqqlq();
            cqqlq.getClass();
            Context context = jmjou.a;
            cqqlq.d(j.class).getClass();
            return t.i(context, SDKConstants.PAYTM_APP_PACKAGE);
        }
        jmjou cqqlq2 = cqqlq();
        cqqlq2.getClass();
        Context context2 = jmjou.a;
        cqqlq2.d(j.class).getClass();
        if (t.i(context2, SDKConstants.PAYTM_APP_PACKAGE)) {
            jmjou jmjouVar = b.a;
            jmjou cqqlq3 = cqqlq();
            irjuc.d(j.class).getClass();
            if (b.d(cqqlq3, SDKConstants.PAYTM_APP_PACKAGE)) {
                return true;
            }
        }
        return false;
    }

    @MerchantAPI
    public static boolean isPhonePeAppInstalled(boolean z) throws PhonePeInitException {
        if (!z) {
            return t.a(cqqlq());
        }
        if (t.a(cqqlq())) {
            jmjou jmjouVar = b.a;
            if (b.d(cqqlq(), t.c(irjuc))) {
                return true;
            }
        }
        return false;
    }

    @MerchantAPI
    public static void isUPIAccountRegistered(final ShowPhonePeCallback showPhonePeCallback) throws PhonePeInitException {
        h.a.b(q.qwsnv, new HashMap());
        jmjou jmjouVar = b.a;
        if (b.a(cqqlq())) {
            cqqlq(true, showPhonePeCallback, true);
            return;
        }
        if (!t.a(cqqlq())) {
            h.a.a("APP_NOT_INSTALLED", (Map) null);
            cqqlq(false, showPhonePeCallback, false);
            return;
        }
        final boolean d = b.d(cqqlq(), t.c(irjuc));
        if (irjuc.d(c.class).a.b().getBoolean("sdk_config_is_should_show_enabled", true)) {
            irjuc(new ShowPhonePeCallback() {
                @Override
                public final void onResponse(boolean z) {
                    PhonePe.irjuc(d, showPhonePeCallback, z);
                }
            });
        } else {
            cqqlq(true, showPhonePeCallback, d);
        }
    }

    @e
    @MerchantAPI
    public static void logout() throws PhonePeInitException {
        PhonePeEnvironment phonePeEnvironment;
        Intrinsics.checkNotNullParameter(q.krrvc, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "LOGOUT")});
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        HashMap irjuc2 = irjuc();
        cqqlq().d(zk.a.class).b().edit().clear().commit();
        cqqlq().getClass();
        jmjou.c.a.clear();
        cqqlq().getClass();
        Context context = jmjou.a;
        String str = (String) irjuc2.get("com.phonepe.android.sdk.MerchantId");
        b.b();
        if (t.j((Boolean) jmjou.f("com.phonepe.android.sdk.isSimulator"))) {
            phonePeEnvironment = PhonePeEnvironment.SANDBOX;
        } else {
            phonePeEnvironment = PhonePeEnvironment.RELEASE;
        }
        irjuc(context, phonePeEnvironment, str, (String) irjuc2.get("com.phonepe.android.sdk.AppId"));
    }

    @MerchantAPI
    public static void setAdditionalInfo(SDKType sDKType) {
        jmjou jmjouVar = b.a;
        Intrinsics.checkNotNullParameter(sDKType, "<set-?>");
        b.b = sDKType;
    }

    @MerchantAPI
    public static void setFlowId(String str) {
        if (str != null) {
            a.c(TAG, " setting new flow ID : ".concat(str));
            irjuc.getClass();
            jmjou.h(str, "flowId");
        }
    }

    @MerchantAPI
    public static void validateUser(String str, final UserValidityCallback userValidityCallback) throws PhonePeInitException {
        h.a.b(q.npzhg, androidx.appcompat.widget.c.b("mobileNumber", str));
        jmjou jmjouVar = b.a;
        if (b.a(cqqlq())) {
            String validityStatus = UserValidityStatus.Companion.getValidityStatus(true);
            Intrinsics.checkNotNullParameter(validityStatus, "userStatus");
            h.a.a("VALIDATE_USER_SDK_RESULT_SENT", P.b(new Pair("result", validityStatus)));
            userValidityCallback.onResponse(validityStatus);
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject();
            byte[] digest = MessageDigest.getInstance("SHA-256").digest(str.getBytes(StandardCharsets.UTF_8));
            StringBuilder sb = new StringBuilder();
            for (byte b : digest) {
                String hexString = Integer.toHexString(b & 255);
                if (hexString.length() == 1) {
                    sb.append('0');
                }
                sb.append(hexString);
            }
            jSONObject.put("hashedPhoneNumber", sb.toString());
            irjuc(jSONObject);
            h.a.a("APP_COMM_STARTED", (Map) null);
            String jSONObject2 = jSONObject.toString();
            RequestCallback requestCallback = new RequestCallback() {
                @Override
                public final void onResponse(String str2) {
                    PhonePe.irjuc(UserValidityCallback.this, str2);
                }
            };
            jmjou.a d = irjuc.d(jmjou.a.class);
            d.put("request", "checkPhoneNumberValidity");
            d.put("constraints", jSONObject2);
            d.put("callback", requestCallback);
            irjuc.e(Ri.a.class, d);
        } catch (Exception e) {
            String message = e.getMessage();
            if (message == null) {
                message = "";
            }
            Map b2 = P.b(new Pair("error", message));
            Intrinsics.checkNotNullParameter("SDK_ERROR", "eventName");
            try {
                d d2 = b.b().d(d.class);
                qwsnv b3 = d2.b("SDK_ERROR");
                if (b2 != null) {
                    for (Map.Entry entry : b2.entrySet()) {
                        b3.b(entry.getValue(), (String) entry.getKey());
                    }
                }
                d2.a(b3);
            } catch (Exception e2) {
                a.d("EventDebug", "error in send event", e2);
            }
            String validityStatus2 = UserValidityStatus.Companion.getValidityStatus(false);
            Intrinsics.checkNotNullParameter(validityStatus2, "userStatus");
            h.a.a("VALIDATE_USER_SDK_RESULT_SENT", P.b(new Pair("result", validityStatus2)));
            userValidityCallback.onResponse(validityStatus2);
        }
    }

    @MerchantAPI
    public boolean isInUATMode() {
        try {
            cqqlq().getClass();
            return t.j((Boolean) jmjou.f("com.phonepe.android.sdk.isUAT"));
        } catch (PhonePeInitException e) {
            a.d(TAG, e.getMessage(), e);
            return false;
        }
    }

    public static jmjou cqqlq() throws PhonePeInitException {
        jmjou jmjouVar = irjuc;
        if (jmjouVar != null) {
            return jmjouVar;
        }
        throw new PhonePeInitException();
    }

    @e
    public static void irjuc(ApplicationInfo applicationInfo) {
        try {
            jmjou cqqlq = cqqlq();
            String string = applicationInfo.metaData.getString("com.phonepe.android.sdk.MerchantId");
            cqqlq.getClass();
            jmjou.h(string, "com.phonepe.android.sdk.MerchantId");
            jmjou cqqlq2 = cqqlq();
            String string2 = applicationInfo.metaData.getString("com.phonepe.android.sdk.AppId");
            cqqlq2.getClass();
            jmjou.h(string2, "com.phonepe.android.sdk.AppId");
            jmjou cqqlq3 = cqqlq();
            Boolean valueOf = Boolean.valueOf(applicationInfo.metaData.getBoolean("com.phonepe.android.sdk.isUAT"));
            cqqlq3.getClass();
            jmjou.h(valueOf, "com.phonepe.android.sdk.isUAT");
            jmjou cqqlq4 = cqqlq();
            Boolean valueOf2 = Boolean.valueOf(applicationInfo.metaData.getBoolean("com.phonepe.android.sdk.PreCacheEnabled"));
            cqqlq4.getClass();
            jmjou.h(valueOf2, "com.phonepe.android.sdk.PreCacheEnabled");
            jmjou cqqlq5 = cqqlq();
            Boolean valueOf3 = Boolean.valueOf(applicationInfo.metaData.getBoolean("com.phonepe.android.sdk.isSimulator"));
            cqqlq5.getClass();
            jmjou.h(valueOf3, "com.phonepe.android.sdk.isSimulator");
            jmjou cqqlq6 = cqqlq();
            Boolean valueOf4 = Boolean.valueOf(applicationInfo.metaData.getBoolean("com.phonepe.android.sdk.isSimulatorStage"));
            cqqlq6.getClass();
            jmjou.h(valueOf4, "com.phonepe.android.sdk.isSimulatorStage");
        } catch (PhonePeInitException e) {
            a.d(TAG, e.getMessage(), e);
        }
    }

    public PhonePe(Context context, PhonePeEnvironment phonePeEnvironment, String str, String str2) {
        try {
            jmjou jmjouVar = b.a;
            b.c(cqqlq(), str, phonePeEnvironment, str2);
            cqqlq().getClass();
            if (!t.j((Boolean) jmjou.f("com.phonepe.android.sdk.PreCacheEnabled")) || Build.VERSION.SDK_INT > 25) {
                return;
            }
            Intent intent = new Intent(context, (Class<?>) PreCacheService.class);
            intent.putExtra("data_factory", (Parcelable) cqqlq());
            context.startService(intent);
        } catch (PhonePeInitException e) {
            a.d(TAG, e.getMessage(), e);
        }
    }

    @e
    public static void cqqlq(Context context) throws PhonePeInitException {
        a.a = new a.a();
        a.e(TAG, "PhonePe SDK initializing ...");
        irjuc = new jmjou(context);
        jmjou jmjouVar = b.a;
        jmjou jmjouVar2 = irjuc;
        Intrinsics.checkNotNullParameter(jmjouVar2, "objectFactory");
        b.a = jmjouVar2;
        setFlowId("FLOW" + UUID.randomUUID().toString().replace("-", ""));
        PhonePe phonePe = new PhonePe(context);
        jmjou cqqlq = cqqlq();
        String canonicalName = PhonePe.class.getCanonicalName();
        cqqlq.getClass();
        jmjou.h(phonePe, canonicalName);
        F2.l.c();
        h.a();
        b.b();
        jmjou.h(Boolean.TRUE, "SDK_INIT_SUCCESS");
        a.e(TAG, "PhonePe SDK initialized");
    }

    public static void irjuc(JSONObject jSONObject) throws PhonePeInitException, JSONException {
        String str;
        cqqlq().getClass();
        jSONObject.put("merchantAppId", jmjou.f("com.phonepe.android.sdk.AppId"));
        irjuc.getClass();
        jSONObject.put("sdkFlowId", jmjou.f("flowId"));
        jSONObject.put("sdkVersion", "2.4.1");
        xl.e d = irjuc.d(xl.e.class);
        d.getClass();
        try {
            str = d.a().getPackageManager().getPackageInfo(d.a().getPackageName(), 0).versionName;
        } catch (Exception unused) {
            str = "unknown";
        }
        jSONObject.put("merchantAppVersion", str);
    }

    @e
    public static void irjuc(Context context) {
        try {
            a.e(TAG, "trying to get app metadata ...");
            ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), UserMetadata.MAX_ROLLOUT_ASSIGNMENTS);
            if (applicationInfo != null && applicationInfo.metaData != null) {
                irjuc(applicationInfo);
                return;
            }
            a.a aVar = a.a;
            if (aVar != null && aVar.e(3)) {
                Log.wtf(TAG, "failed to get application applicationInfo or applicationMetaData");
            }
            h.a.a("SDK_ERROR", P.b(new Pair("error", "failed to get application applicationInfo or applicationMetaData")));
            throw new IllegalArgumentException("failed to get application applicationInfo or applicationMetaData");
        } catch (PackageManager.NameNotFoundException e) {
            a.b(TAG, "failed to cache merchant meta with exception message = {" + e.getMessage() + "}. failed to initialized SDK");
            String message = e.getMessage();
            if (message == null) {
                message = "";
            }
            h.a.a("SDK_ERROR", P.b(new Pair("error", message)));
            throw new IllegalArgumentException("Failed to retrieve merchant metaData from manifest");
        }
    }

    @MerchantAPI
    public static boolean init(@NonNull Context context, @NonNull PhonePeEnvironment phonePeEnvironment, @NonNull String str, String str2) {
        try {
            irjuc(context, phonePeEnvironment, str, str2);
            HashMap irjuc2 = irjuc();
            Intrinsics.checkNotNullParameter(q.irjuc, "sdkApiName");
            LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "INIT")});
            if (!irjuc2.isEmpty()) {
                h.putAll(irjuc2);
            }
            Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
            try {
                d d = b.b().d(d.class);
                qwsnv b = d.b("SDK_API_CALLED");
                for (Map.Entry entry : h.entrySet()) {
                    b.b(entry.getValue(), (String) entry.getKey());
                }
                d.a(b);
            } catch (Exception e) {
                a.d("EventDebug", "error in send event", e);
            }
            return true;
        } catch (Exception e2) {
            a.d(TAG, e2.getMessage(), e2);
            return false;
        }
    }

    public static void cqqlq(boolean z, ShowPhonePeCallback showPhonePeCallback, boolean z2) {
        h.a.a("IS_UPI_ACC_REG_SDK_RESULT_SENT", Q.g(new Pair[]{new Pair("show", String.valueOf(Boolean.valueOf(z))), new Pair("isRegistered", String.valueOf(Boolean.valueOf(z2)))}));
        showPhonePeCallback.onResponse(z2 && z);
    }

    @MerchantAPI
    public static Intent getImplicitIntent(Context context, @NonNull TransactionRequest transactionRequest) throws PhonePeInitException {
        HashMap hashMap = new HashMap();
        hashMap.put("merchantRequest", transactionRequest.toString());
        Intrinsics.checkNotNullParameter(q.chmha, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "DEBIT_OPEN_INTENT")});
        if (!hashMap.isEmpty()) {
            h.putAll(hashMap);
        }
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        Parcelable cqqlq = cqqlq();
        int i = TransactionActivity.l;
        uauho d2 = cqqlq.d(uauho.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("data_factory", cqqlq);
        bundle.putParcelable("request", transactionRequest);
        bundle.putParcelable("sdk_context", d2);
        Intent intent = new Intent(context, (Class<?>) UpiAppsSelectionDialogActivity.class);
        intent.putExtras(bundle);
        return intent;
    }

    public static void irjuc(Context context, @NonNull PhonePeEnvironment phonePeEnvironment, @NonNull String str, String str2) throws PhonePeInitException {
        a.a = new a.a();
        a.e(TAG, "PhonePe SDK initializing ...");
        irjuc = new jmjou(context);
        cqqlq().getClass();
        jmjou.c.a.clear();
        jmjou jmjouVar = b.a;
        jmjou jmjouVar2 = irjuc;
        Intrinsics.checkNotNullParameter(jmjouVar2, "objectFactory");
        b.a = jmjouVar2;
        setFlowId("FLOW" + UUID.randomUUID().toString().replace("-", ""));
        PhonePe phonePe = new PhonePe(context, phonePeEnvironment, str, str2);
        jmjou cqqlq = cqqlq();
        String canonicalName = PhonePe.class.getCanonicalName();
        cqqlq.getClass();
        jmjou.h(phonePe, canonicalName);
        F2.l.c();
        h.a();
        b.b();
        jmjou.h(Boolean.TRUE, "SDK_INIT_SUCCESS");
        a.e(TAG, "PhonePe SDK initialized");
    }

    @MerchantAPI
    public static Intent getImplicitIntent(Context context, @NonNull TransactionRequest transactionRequest, String str) throws PhonePeInitException {
        HashMap hashMap = new HashMap();
        hashMap.put("merchantRequest", transactionRequest.toString());
        hashMap.put("openIntentWithApp", str);
        h.a.b(q.jmjou, hashMap);
        if (t.i(context, str)) {
            Parcelable cqqlq = cqqlq();
            String str2 = OpenIntentTransactionActivity.i;
            uauho d = cqqlq.d(uauho.class);
            Bundle bundle = new Bundle();
            bundle.putParcelable("data_factory", cqqlq);
            bundle.putParcelable("request", transactionRequest);
            bundle.putParcelable("sdk_context", d);
            bundle.putString("openIntentWithApp", str);
            Intent intent = new Intent(context, (Class<?>) OpenIntentTransactionActivity.class);
            intent.putExtras(bundle);
            return intent;
        }
        h.a.a("APP_NOT_INSTALLED", (Map) null);
        throw new PhonePeInitException("App is not installed on user's device");
    }

    @MerchantAPI
    public static Intent getImplicitIntent(Context context, @NonNull String str, String str2) throws PhonePeInitException {
        HashMap hashMap = new HashMap();
        hashMap.put("merchantRequest", str);
        hashMap.put("packageName", str2);
        Intrinsics.checkNotNullParameter(q.jmbjl, "sdkApiName");
        LinkedHashMap h = Q.h(new Pair[]{new Pair("sdkApiName", "PG_PAY_DIRECT")});
        if (!hashMap.isEmpty()) {
            h.putAll(hashMap);
        }
        Intrinsics.checkNotNullParameter("SDK_API_CALLED", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("SDK_API_CALLED");
            for (Map.Entry entry : h.entrySet()) {
                b.b(entry.getValue(), (String) entry.getKey());
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        Parcelable cqqlq = cqqlq();
        int i = B2BPGActivity.m;
        Intrinsics.checkNotNullParameter(str, "b2bPGResponse");
        Intrinsics.checkNotNullParameter(cqqlq, "objectFactory");
        a.a("B2BPGActivity", "getting direct implicit intent");
        Intrinsics.checkNotNullParameter(cqqlq, "objectFactory");
        uauho d2 = cqqlq.d(uauho.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("data_factory", cqqlq);
        bundle.putParcelable("request", null);
        bundle.putParcelable("sdk_context", d2);
        bundle.putString("openIntentWithApp", str2);
        Intent intent = new Intent(context, (Class<?>) B2BPGActivity.class);
        intent.putExtras(bundle);
        intent.putExtra("B2B_PG_Response", str);
        return intent;
    }

    public static void irjuc(ShouldShowMandateCallback shouldShowMandateCallback, String str) {
        boolean z;
        if (shouldShowMandateCallback != null) {
            h.a.a("APP_RESULT", P.b(new Pair("result", str == null ? "" : str)));
            if (str == null || str.isEmpty()) {
                a.c(TAG, "result is null or empty");
                z = true;
            } else {
                a.c(TAG, "got result ".concat(str));
                try {
                    ShouldShowMandateCallbackResult cqqlq = cqqlq(new JSONObject(str));
                    a.c(TAG, "sending result " + cqqlq);
                    irjuc(cqqlq.isSingleMandateSupported(), cqqlq.isRecurringMandateSupported(), shouldShowMandateCallback);
                    return;
                } catch (Exception e) {
                    a.b(TAG, "error " + e.getMessage());
                    String message = e.getMessage();
                    h.a.a("SDK_ERROR", P.b(new Pair("error", message != null ? message : "")));
                    z = false;
                }
            }
            irjuc(z, z, shouldShowMandateCallback);
        }
    }

    public static void irjuc(boolean z, ShowPhonePeCallback showPhonePeCallback, boolean z2) {
        try {
            cqqlq(z2, showPhonePeCallback, z);
        } catch (Exception e) {
            String message = e.getMessage();
            if (message == null) {
                message = "";
            }
            h.a.a("SDK_ERROR", P.b(new Pair("error", message)));
            cqqlq(false, showPhonePeCallback, false);
        }
    }

    public static void irjuc(ShowPhonePeCallback showPhonePeCallback, String str) {
        if (showPhonePeCallback != null) {
            h.a.a("APP_RESULT", P.b(new Pair("result", str == null ? "" : str)));
            if (str != null && !str.isEmpty()) {
                try {
                    showPhonePeCallback.onResponse(new JSONObject(str).optBoolean("result", true));
                    return;
                } catch (Exception e) {
                    String message = e.getMessage();
                    h.a.a("SDK_ERROR", P.b(new Pair("error", message != null ? message : "")));
                }
            }
            showPhonePeCallback.onResponse(true);
        }
    }

    public static void irjuc(boolean z, AtomicBoolean atomicBoolean, long j, Long l, CheckPhonePeAvailabilityCallback checkPhonePeAvailabilityCallback) {
        long currentTimeMillis = System.currentTimeMillis();
        if (z && Looper.myLooper() != null && Looper.myLooper() != Looper.getMainLooper()) {
            Looper.myLooper().quit();
        }
        if (atomicBoolean.get()) {
            return;
        }
        Map g = Q.g(new Pair[]{new Pair("checkAvailabilityTimeoutMs", Long.valueOf(j)), new Pair("timeTakenMs", Long.valueOf(currentTimeMillis - l.longValue()))});
        Intrinsics.checkNotNullParameter("CHECK_AVAILABILITY_API_CALL_TIMED_OUT", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("CHECK_AVAILABILITY_API_CALL_TIMED_OUT");
            if (g != null) {
                for (Map.Entry entry : g.entrySet()) {
                    b.b(entry.getValue(), (String) entry.getKey());
                }
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        irjuc(true, "SUCCESS", atomicBoolean, checkPhonePeAvailabilityCallback);
    }

    public static void irjuc(UserValidityCallback userValidityCallback, String str) {
        String validityStatus;
        h.a.a("APP_RESULT", P.b(new Pair("result", str == null ? "" : str)));
        if (str != null && !str.isEmpty()) {
            try {
                String validityStatus2 = UserValidityStatus.Companion.getValidityStatus(new JSONObject(str).optBoolean("isPhoneNumberValid"));
                Intrinsics.checkNotNullParameter(validityStatus2, "userStatus");
                h.a.a("VALIDATE_USER_SDK_RESULT_SENT", P.b(new Pair("result", validityStatus2)));
                userValidityCallback.onResponse(validityStatus2);
                return;
            } catch (JSONException unused) {
                validityStatus = UserValidityStatus.Companion.getValidityStatus(false);
            }
        } else {
            validityStatus = UserValidityStatus.Companion.getValidityStatus(true);
        }
        Intrinsics.checkNotNullParameter(validityStatus, "userStatus");
        h.a.a("VALIDATE_USER_SDK_RESULT_SENT", P.b(new Pair("result", validityStatus)));
        userValidityCallback.onResponse(validityStatus);
    }

    public static void irjuc(boolean z, String str, AtomicBoolean atomicBoolean, CheckPhonePeAvailabilityCallback checkPhonePeAvailabilityCallback) {
        if (atomicBoolean.get()) {
            return;
        }
        atomicBoolean.set(true);
        Intrinsics.checkNotNullParameter(str, "responseCode");
        Map g = Q.g(new Pair[]{new Pair("checkAvailabilityFinalResponse", Boolean.valueOf(z)), new Pair("checkAvailabilityFinalResponseCode", str)});
        Intrinsics.checkNotNullParameter("CHECK_AVAILABILITY_SDK_FINAL_RESPONSE_SENT", "eventName");
        try {
            d d = b.b().d(d.class);
            qwsnv b = d.b("CHECK_AVAILABILITY_SDK_FINAL_RESPONSE_SENT");
            if (g != null) {
                for (Map.Entry entry : g.entrySet()) {
                    b.b(entry.getValue(), (String) entry.getKey());
                }
            }
            d.a(b);
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        checkPhonePeAvailabilityCallback.onResponse(z, str);
    }

    public static void irjuc(boolean z, boolean z2, ShouldShowMandateCallback shouldShowMandateCallback) {
        h.a.a("IS_MANDATE_SUPPORTED_SDK_RESULT_SENT", Q.g(new Pair[]{new Pair("isSingleMandateSupported", String.valueOf(z)), new Pair("isRecurringMandateSupported", String.valueOf(z2))}));
        shouldShowMandateCallback.onResponse(new ShouldShowMandateCallbackResult(z, z2));
    }

    public static void irjuc(final ShowPhonePeCallback showPhonePeCallback) throws PhonePeInitException {
        if (t.a(cqqlq())) {
            if (cqqlq().d(co.a.class).b.b().getBoolean("showPhonePeEnabled", true)) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("loggedIn", true);
                    jSONObject.put("singlePaymentInstrumentAvailable", true);
                    irjuc(jSONObject);
                } catch (Exception e) {
                    a.d(TAG, e.getMessage(), e);
                }
                Intrinsics.checkNotNullParameter("APP_COMM_STARTED", "eventName");
                try {
                    d d = b.b().d(d.class);
                    d.a(d.b("APP_COMM_STARTED"));
                } catch (Exception e2) {
                    a.d("EventDebug", "error in send event", e2);
                }
                String jSONObject2 = jSONObject.toString();
                RequestCallback requestCallback = new RequestCallback() {
                    @Override
                    public final void onResponse(String str) {
                        PhonePe.irjuc(ShowPhonePeCallback.this, str);
                    }
                };
                jmjou.a d2 = irjuc.d(jmjou.a.class);
                d2.put("request", "shouldShowPhonePe");
                d2.put("constraints", jSONObject2);
                d2.put("callback", requestCallback);
                irjuc.e(Ri.a.class, d2);
                return;
            }
            showPhonePeCallback.onResponse(true);
            return;
        }
        Intrinsics.checkNotNullParameter("APP_NOT_INSTALLED", "eventName");
        try {
            d d3 = b.b().d(d.class);
            d3.a(d3.b("APP_NOT_INSTALLED"));
        } catch (Exception e3) {
            a.d("EventDebug", "error in send event", e3);
        }
        showPhonePeCallback.onResponse(false);
    }

    public static void irjuc(final AtomicBoolean atomicBoolean, final long j, AvailabilityCheckRequest availabilityCheckRequest, final CheckPhonePeAvailabilityCallback checkPhonePeAvailabilityCallback) {
        boolean z;
        uauho uauhoVar;
        final Long valueOf = Long.valueOf(System.currentTimeMillis());
        if (Looper.myLooper() == null) {
            Looper.prepare();
            z = true;
        } else {
            z = false;
        }
        final boolean z2 = z;
        new Handler(Looper.myLooper()).postDelayed(new Runnable() {
            @Override
            public final void run() {
                PhonePe.irjuc(z2, atomicBoolean, j, valueOf, checkPhonePeAvailabilityCallback);
            }
        }, j);
        Intrinsics.checkNotNullParameter("CHECK_AVAILABILITY_API_CALL_STARTED", "eventName");
        try {
            d d = b.b().d(d.class);
            d.a(d.b("CHECK_AVAILABILITY_API_CALL_STARTED"));
        } catch (Exception e) {
            a.d("EventDebug", "error in send event", e);
        }
        irjuc irjucVar = new irjuc(atomicBoolean, checkPhonePeAvailabilityCallback);
        Intrinsics.checkNotNullParameter(availabilityCheckRequest, "availabilityCheckRequest");
        Intrinsics.checkNotNullParameter(irjucVar, "callback");
        Xn.j d2 = b.b().d(Xn.j.class);
        rmqfk rmqfkVar = null;
        try {
            uauhoVar = b.b().d(uauho.class);
        } catch (PhonePeInitException unused) {
            uauhoVar = null;
        }
        try {
            rmqfkVar = (zihjx) b.b().d(zihjx.class);
        } catch (PhonePeInitException unused2) {
        }
        Xn.q qVar = new Xn.q(irjucVar);
        d2.a.getClass();
        boolean j2 = t.j((Boolean) jmjou.f("com.phonepe.android.sdk.isUAT"));
        StringBuilder sb = new StringBuilder();
        HashSet hashSet = p.a;
        String a = B.d.a(sb, (j2 ? p.a.cqqlq : p.a.chmha).irjuc, "/v3/availabilitycheck");
        cqqlq d3 = d2.a.d(cqqlq.class);
        String data = availabilityCheckRequest.getData();
        if (data == null) {
            d3.getClass();
        } else {
            d3.put("request", data);
        }
        if (uauhoVar != null) {
            d3.put("sdkContext", uauhoVar.toJsonObject());
        }
        if (rmqfkVar != null) {
            d3.put("phonePeContext", rmqfkVar.toJsonObject());
        }
        d2.b(availabilityCheckRequest.getHeaderMap(), new g(d2, a, d3.toJsonString(), qVar));
        if (z) {
            Looper.loop();
        }
    }
}