导航菜单

页面标题

页面副标题

Chaupal v3.2 - CheckoutPresenterImpl.java 源代码

正在查看: Chaupal v3.2 应用的 CheckoutPresenterImpl.java JAVA 源代码文件

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


package com.razorpay;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Base64;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.google.android.gms.tasks.Task;
import com.razorpay.AnalyticsProperty;
import com.razorpay.BaseCheckoutActivity;
import com.razorpay.C0213b;
import com.razorpay.CheckoutBridge;
import com.razorpay.CheckoutUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;

class CheckoutPresenterImpl implements CheckoutInteractor, CheckoutPresenter {
    protected Activity activity;
    private E$_j$ autoReadOtpHelper;
    private Task<Void> automaticRetrievalTask;
    private long checkoutLoadStartAt;
    Queue<String> checkoutMessageQueue;
    L_$k$ checkoutOptions;
    private String checkoutUrl;
    private boolean clearHistory;
    private String dashOptions;
    private JSONObject dashOptionsJSON;
    private Boolean hideCircularLoader;
    JSONObject integratedPluginsData;
    private Boolean internalUpiApp;
    private boolean isCheckoutLoaded;
    private Task<Void> loginOtpSmsTask;
    String merchantKey;
    BroadcastReceiver otpAutoReadBroadcast;
    protected HashMap<String, String> pluginsMap;
    private long preloadAbortDuration;
    private long preloadCompleteDuration;
    private boolean truecallerLoginAttempt;
    UpiTurboCheckout upiTurbo;
    private Task<Void> userConsentTask;
    protected CheckoutView view;
    private boolean isOnLoadTriggered = false;
    private String checkoutContent = "{}";
    private int paymentAttempts = 0;
    private boolean isPaymentSuccessful = false;
    private boolean isSmsReceiverRegistered = false;
    private boolean isTwoWebViewFlow = false;
    private boolean isMagic = false;
    private int merchantLogoResourceId = 0;
    private boolean isActivityCreated = false;
    private boolean sendSmsHash = false;
    private boolean allowRotation = false;
    private String sanitizedChallanEncodedString = "";
    private boolean isDynamicUrlLoaded = false;
    private String payment_id = null;
    private X$_8_ magicBase = null;
    private boolean nameNotFound_retryStatus = false;

    interface CheckoutView {
        void addJavascriptInterfaceToPrimaryWebview(Object obj, String str);

        void checkSmsPermission();

        void clearWebViewHistory(int i);

        void destroy(int i, String str);

        WebView getWebView(int i);

        void hideProgressBar();

        boolean isWebViewVisible(int i);

        void loadData(int i, String str, String str2, String str3);

        void loadDataWithBaseURL(int i, String str, String str2, String str3, String str4, String str5);

        void loadUrl(int i, String str);

        void makeWebViewVisible(int i);

        void showProgressBar(int i);

        void showToast(String str, int i);
    }

    public CheckoutPresenterImpl(Activity activity, CheckoutView checkoutView) {
        Boolean bool = Boolean.FALSE;
        this.internalUpiApp = bool;
        this.hideCircularLoader = bool;
        this.otpAutoReadBroadcast = new BroadcastReceiver() {
            @Override
            public final void onReceive(Context context, Intent intent) {
                if ("com.google.android.gms.auth.api.phone.SMS_RETRIEVED".equals(intent.getAction())) {
                    Bundle extras = intent.getExtras();
                    Status status = (Status) extras.get("com.google.android.gms.auth.api.phone.EXTRA_STATUS");
                    AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_RECEIVED_SMS);
                    int statusCode = status.getStatusCode();
                    if (statusCode != 0) {
                        if (statusCode != 15) {
                            return;
                        }
                        AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_TIMEOUT);
                        return;
                    }
                    Intent intent2 = (Intent) extras.get("com.google.android.gms.auth.api.phone.EXTRA_CONSENT_INTENT");
                    if (intent2 == null) {
                        String str = (String) extras.get("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE");
                        Intent intent3 = new Intent();
                        intent3.putExtra("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE", str);
                        CheckoutPresenterImpl.this.onActivityResultReceived(1001, -1, intent3);
                        return;
                    }
                    ComponentName callingActivity = CheckoutPresenterImpl.this.activity.getCallingActivity();
                    if (callingActivity != null && callingActivity.getPackageName().equals(CheckoutPresenterImpl.this.activity.getPackageName()) && CheckoutPresenterImpl.this.activity.getLocalClassName().contains("CheckoutActivity")) {
                        try {
                            CheckoutPresenterImpl.this.activity.startActivityForResult(intent2, 1001);
                            AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_SHOWED_ONE_TIME_CONSENT);
                        } catch (ActivityNotFoundException e) {
                            AnalyticsUtil.reportError("AutoReadOtpHelper", "S0", e.getLocalizedMessage());
                        }
                    }
                }
            }
        };
        this.checkoutMessageQueue = new LinkedList();
        this.isCheckoutLoaded = false;
        this.integratedPluginsData = new JSONObject();
        this.truecallerLoginAttempt = false;
        this.activity = activity;
        this.view = checkoutView;
    }

    public void clearAllPlugins() {
        HashMap<String, String> hashMap = this.pluginsMap;
        if (hashMap == null || this.upiTurbo == null || !hashMap.containsKey("com.razorpay.plugin.upi_turbo")) {
            return;
        }
        this.upiTurbo.destroy();
    }

    public void executeWebViewCallback(int i, CheckoutBridge.WebViewSafeCheckCallback webViewSafeCheckCallback) {
        CheckoutView checkoutView;
        int i2 = 1;
        if (i == 1) {
            checkoutView = this.view;
        } else {
            checkoutView = this.view;
            i2 = 2;
        }
        try {
            String host = new URL(checkoutView.getWebView(i2).getTag().toString()).getHost();
            if (host == null || !(host.endsWith("razorpay.com") || host.endsWith("razorpay.in") || this.isDynamicUrlLoaded)) {
                webViewSafeCheckCallback.unSecure();
            } else {
                webViewSafeCheckCallback.secure();
            }
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
            webViewSafeCheckCallback.unSecure();
        }
    }

    public String getHandleMessageFormattedString() {
        return String.format("javascript: handleMessage(%s)", getOptionsForHandleMessage().toString());
    }

    @NotNull
    private JSONObject getSdkObject() {
        String str;
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("framework", AnalyticsUtil.getFramework());
        jSONObject.put("type", p$_5$.a);
        jSONObject.put(AppMeasurementSdk.ConditionalUserProperty.NAME, p$_5$.a + "_android_" + AnalyticsUtil.getFramework());
        jSONObject.put("version", BuildConfig.VERSION_NAME);
        jSONObject.put("platform", "android");
        String callingPackage = this.activity.getCallingPackage();
        if (callingPackage == null) {
            callingPackage = this.activity.getPackageName();
            str = "getPackageName";
        } else {
            str = "getCallingPackage";
        }
        if (callingPackage == null) {
            callingPackage = this.activity.getApplicationContext().getPackageName();
            str = "getApplicationContext.getPackageName";
        }
        if (callingPackage == null) {
            callingPackage = this.activity.getApplication().getPackageName();
            str = "getApplication.getPackageName";
        }
        if (callingPackage == null) {
            str = "null";
        }
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("function_name", str);
        AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_PACKAGE_NAME_FUNC_USED, jSONObject2);
        jSONObject.put("package_name", callingPackage);
        return jSONObject;
    }

    public void handleRetry(String str) {
        if (!CheckoutUtils.a(this.paymentAttempts)) {
            destroyActivity(0, str);
            return;
        }
        try {
            if (str == null) {
                destroyActivity(0, "");
                return;
            }
            JSONObject jSONObject = new JSONObject(str);
            if (jSONObject.has("error")) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append(str);
                sb2.append(this.checkoutUrl.contains("?") ? "&" : "?");
                str = sb2.toString();
                if (jSONObject.get("error") instanceof JSONObject) {
                    str = str + "error=" + ((JSONObject) jSONObject.get("error")).toString();
                }
            }
            helpersReset();
            loadForm(str);
        } catch (Exception e) {
            destroyActivity(0, "");
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
        }
    }

    private void loadResultToWebView(JSONObject jSONObject, String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("result", jSONObject);
        AnalyticsUtil.trackEvent(AnalyticsEvent.NATIVE_INTENT_ONACTIVITY_RESULT, AnalyticsUtil.getJSONResponse(hashMap));
        if (this.isCheckoutLoaded) {
            this.view.loadUrl(1, str);
            return;
        }
        if (this.checkoutMessageQueue == null) {
            this.checkoutMessageQueue = new LinkedList();
        }
        this.checkoutMessageQueue.add(str);
    }

    public void markPaymentCancelled() {
        if (this.payment_id == null || this.isPaymentSuccessful) {
            return;
        }
        try {
            String constructBasicAuth = BaseUtils.constructBasicAuth(this.merchantKey);
            HashMap hashMap = new HashMap();
            hashMap.put("Authorization", "Basic " + constructBasicAuth);
            e.a("https://api.razorpay.com/v1/payments/" + this.payment_id + "/cancel?platform=android_sdk", hashMap, new J__n_(this));
            this.payment_id = null;
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
        }
    }

    private void saveImageToGallery(String str, String str2, String str3) {
        try {
            byte[] decode = Base64.decode(str2, 0);
            ContentValues contentValues = new ContentValues();
            contentValues.put("_display_name", str + "." + str3);
            contentValues.put("mime_type", BaseUtils.getType(str3));
            int i = Build.VERSION.SDK_INT;
            if (i >= 29) {
                contentValues.put("is_pending", (Integer) 1);
                contentValues.put("relative_path", "DCIM");
            }
            Uri insert = this.activity.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
            if (insert != null) {
                OutputStream openOutputStream = this.activity.getContentResolver().openOutputStream(insert);
                if (openOutputStream != null) {
                    try {
                        openOutputStream.write(decode);
                        openOutputStream.flush();
                    } finally {
                    }
                }
                if (openOutputStream != null) {
                    openOutputStream.close();
                }
                if (i >= 29) {
                    contentValues.clear();
                    contentValues.put("is_pending", (Integer) 0);
                    this.activity.getContentResolver().update(insert, contentValues, null, null);
                }
                this.activity.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        Toast.makeText(CheckoutPresenterImpl.this.activity, "Image saved to gallery", 0).show();
                    }
                });
            }
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S2", "Failed to save image: " + e.getMessage());
            e.getMessage();
        }
    }

    private void savePrefillData(JSONObject jSONObject) {
        try {
            if (jSONObject.has("contact")) {
                CheckoutUtils.d(this.activity, jSONObject.getString("contact"));
                this.checkoutOptions.a("contact", jSONObject.getString("contact"));
            }
            if (jSONObject.has("email")) {
                CheckoutUtils.b(this.activity, jSONObject.getString("email"));
                this.checkoutOptions.a("email", jSONObject.getString("email"));
            }
        } catch (JSONException unused) {
        }
    }

    private void sendQueuedMessagesToCheckout() {
        Queue<String> queue = this.checkoutMessageQueue;
        if (queue == null || queue.isEmpty()) {
            return;
        }
        Iterator<String> it = this.checkoutMessageQueue.iterator();
        while (it.hasNext()) {
            this.view.loadUrl(1, it.next());
        }
        this.checkoutMessageQueue.clear();
    }

    private void setupExternalPlugins(HashMap<String, String> hashMap) {
        this.integratedPluginsData = new JSONObject();
        if (hashMap == null || !hashMap.containsKey("com.razorpay.plugin.upi_turbo")) {
            return;
        }
        try {
            JSONObject d = this.checkoutOptions.d();
            if (d.has("prefill") && d.getJSONObject("prefill").has("contact")) {
                this.integratedPluginsData.put("upi_turbo", true);
                CheckoutUtils.e(this.activity);
                if (d.has("order_id")) {
                    this.upiTurbo = new UpiTurboCheckout(this.activity, d.getJSONObject("prefill").getString("contact"), this.checkoutOptions.l(), d.getString("order_id"));
                } else {
                    this.upiTurbo = new UpiTurboCheckout(this.activity, d.getJSONObject("prefill").getString("contact"), this.checkoutOptions.l(), null);
                }
                this.upiTurbo.getLinkedUpiAccounts(new GenericPluginCallback() {
                    @Override
                    public final void onError(@NonNull JSONObject jSONObject) {
                        try {
                            CheckoutPresenterImpl.this.integratedPluginsData.remove("upi_turbo");
                            CheckoutPresenterImpl.this.integratedPluginsData.put("upiTurboData", jSONObject);
                            CheckoutPresenterImpl.this.onLoad();
                        } catch (JSONException unused) {
                        }
                    }

                    @Override
                    public final void onSuccess(@NonNull Object obj) {
                        try {
                            CheckoutPresenterImpl.this.integratedPluginsData.remove("upi_turbo");
                            CheckoutPresenterImpl.this.integratedPluginsData.put("upiTurboData", obj);
                            CheckoutPresenterImpl.this.onLoad();
                        } catch (JSONException unused) {
                        }
                    }
                });
            }
        } catch (JSONException unused) {
            this.integratedPluginsData.remove("upi_turbo");
            onLoad();
        }
    }

    private void startSmsRetrievers() {
        this.automaticRetrievalTask = SmsRetriever.getClient(this.activity).startSmsRetriever();
        this.userConsentTask = SmsRetriever.getClient(this.activity).startSmsUserConsent((String) null);
    }

    protected void addAnalyticsData(JSONObject jSONObject) {
        AnalyticsUtil.addFilteredPropertiesFromPayload(jSONObject);
    }

    protected void addOnFlowEnd() {
        if (this.magicBase != null) {
            throw null;
        }
    }

    @Override
    public void backPressed(final Map<String, Object> map) {
        AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_HARD_BACK_PRESSED, AnalyticsUtil.getJSONResponse(map));
        if (CheckoutUtils.a(this.view.getWebView(1)) && !this.view.isWebViewVisible(2)) {
            this.view.loadUrl(1, "javascript: window.backPressed ? window.backPressed('onCheckoutBackPress') : CheckoutBridge.onCheckoutBackPress();");
            map.put("in_checkout", "true");
        } else if (p$_5$.a().m()) {
            CheckoutUtils.a(this.activity, p$_5$.a().n(), p$_5$.a().l(), p$_5$.a().k(), new CheckoutUtils.BackButtonDialogCallback() {
                @Override
                public final void onNegativeButtonClick() {
                    boolean z;
                    AnalyticsUtil.trackEvent(AnalyticsEvent.ALERT_PAYMENT_CANCELLED, AnalyticsUtil.getJSONResponse((Map<String, Object>) map));
                    z = CheckoutPresenterImpl.this.isTwoWebViewFlow;
                    if (z) {
                        CheckoutPresenterImpl.this.view.makeWebViewVisible(1);
                        CheckoutPresenterImpl.this.view.loadUrl(2, "about:blank");
                        CheckoutPresenterImpl.this.view.loadUrl(1, "javascript: window.onpaymentcancel()");
                    } else {
                        CheckoutPresenterImpl.this.handleRetry(null);
                        CheckoutPresenterImpl.this.markPaymentCancelled();
                    }
                    CheckoutPresenterImpl.this.clearAllPlugins();
                    CheckoutPresenterImpl.this.isTwoWebViewFlow = false;
                }

                @Override
                public final void onPositiveButtonClick() {
                    AnalyticsUtil.trackEvent(AnalyticsEvent.ALERT_PAYMENT_CONTINUE, AnalyticsUtil.getJSONResponse((Map<String, Object>) map));
                }
            });
        } else {
            destroyActivity(0, "BackPressed");
        }
    }

    @Override
    public void callNativeIntent(String str, String str2) {
        if (str.contains("truecallersdk://truesdk")) {
            this.truecallerLoginAttempt = true;
        }
        BaseUtils.startActivityForResult(str, str2, this.activity);
        HashMap hashMap = new HashMap();
        hashMap.put("url", str);
        if (str2 == null) {
            str2 = "null";
        }
        hashMap.put("package_name", str2);
        AnalyticsUtil.trackEvent(AnalyticsEvent.NATIVE_INTENT_CALLED, AnalyticsUtil.getJSONResponse(hashMap));
    }

    @Override
    public void checkSmsPermission() {
        this.view.checkSmsPermission();
    }

    @Override
    public void cleanUpOnDestroy() {
        try {
            markPaymentCancelled();
            clearAllPlugins();
            unregisterReceivers();
            o.a();
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
        }
    }

    @Override
    public void destroyActivity(int i, String str) {
        String valueOf = String.valueOf(i);
        AnalyticsProperty.Scope scope = AnalyticsProperty.Scope.ORDER;
        AnalyticsUtil.addProperty("destroy_resultCode", new AnalyticsProperty(valueOf, scope));
        AnalyticsUtil.addProperty("destroy_result", new AnalyticsProperty(str, scope));
        AnalyticsUtil.trackEvent(AnalyticsEvent.INTERNAL_DESTROY_METHOD_CALLED);
        cleanUpOnDestroy();
        this.view.destroy(i, str);
    }

    protected void enableAddon(JSONObject jSONObject) {
        try {
            if (jSONObject.has("magic")) {
                boolean z = jSONObject.getBoolean("magic");
                this.isMagic = z;
                X$_8_ x$_8_ = this.magicBase;
                if (x$_8_ != null) {
                    x$_8_.a = z;
                }
                AnalyticsUtil.addProperty("is_magic", new AnalyticsProperty(z, AnalyticsProperty.Scope.PAYMENT));
            }
        } catch (JSONException e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
        }
    }

    void enableCheckoutLoaded() {
        this.isCheckoutLoaded = true;
    }

    void enableTwoViewFlow() {
        this.isTwoWebViewFlow = true;
    }

    @Override
    public void fetchCondfig() {
        p$_5$.d = isMagicPresent();
        p$_5$.a(this.activity, this.merchantKey);
    }

    @Override
    public L_$k$ getCheckoutOptions() {
        return this.checkoutOptions;
    }

    @Override
    public void getDownloadFileString(String str, String str2, String str3) {
        if (TextUtils.isEmpty(str2)) {
            return;
        }
        if (str2.contains("base64,")) {
            try {
                this.sanitizedChallanEncodedString = str2.split("base64,")[1];
            } catch (ArrayIndexOutOfBoundsException e) {
                AnalyticsUtil.reportError(CheckoutPresenterImpl.class.getSimpleName(), "S0", "getDownloadFileString: " + e.getMessage());
                return;
            }
        } else {
            this.sanitizedChallanEncodedString = str2;
        }
        String type = BaseUtils.getType(str3);
        if (type.startsWith("image/")) {
            saveImageToGallery(str, this.sanitizedChallanEncodedString, str3);
            return;
        }
        try {
            Intent intent = new Intent("android.intent.action.CREATE_DOCUMENT");
            intent.addCategory("android.intent.category.OPENABLE");
            intent.setType(type);
            intent.putExtra("android.intent.extra.TITLE", str);
            this.activity.startActivityForResult(intent, 78);
        } catch (ActivityNotFoundException unused) {
        }
    }

    protected JSONObject getOptionsForHandleMessage() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("options", this.checkoutOptions.d());
            jSONObject.put("data", this.checkoutContent);
            jSONObject.put("id", AnalyticsUtil.getLocalOrderId());
            jSONObject.put("pdf_download_supported", true);
            jSONObject.put("file_download_supported", true);
            jSONObject.put("key_id", this.merchantKey);
            jSONObject.put("externalSDKs", new JSONObject());
            if (this.checkoutOptions.b()) {
                jSONObject.put("sms_hash", new AppSignatureHelper(this.activity).getAppSignatures().get(0));
            }
            jSONObject.put("upi_intents_data", CheckoutUtils.c(this.activity));
            jSONObject.put("uri_data", CheckoutUtils.d(this.activity));
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("openedAt", System.currentTimeMillis());
            jSONObject.put("metadata", jSONObject2);
            jSONObject.put("sdk", getSdkObject());
            String b = f$_G$.b(this.activity.getApplicationContext());
            if (!TextUtils.isEmpty(b)) {
                jSONObject.put("device_token", b);
            }
            jSONObject.put("sdk_popup", true);
            jSONObject.put("magic", true);
            jSONObject.put("network_type", BaseUtils.getNetworkType(this.activity));
            jSONObject.put("activity_recreated", this.isActivityCreated);
        } catch (JSONException e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
        }
        return jSONObject;
    }

    @Override
    public void getPdfString(String str, String str2) {
        if (TextUtils.isEmpty(str2) || !str2.contains("base64,")) {
            return;
        }
        this.sanitizedChallanEncodedString = str2.split("base64,")[1];
        try {
            Intent intent = new Intent("android.intent.action.CREATE_DOCUMENT");
            intent.addCategory("android.intent.category.OPENABLE");
            intent.setType("application/pdf");
            intent.putExtra("android.intent.extra.TITLE", str);
            this.activity.startActivityForResult(intent, 77);
        } catch (ActivityNotFoundException unused) {
        }
    }

    @Override
    public String getProgressBarColor() {
        JSONObject jSONObject;
        String str = null;
        try {
            if (this.checkoutOptions.d() == null) {
                throw new Exception("No options defined");
            }
            String string = this.checkoutOptions.d().getJSONObject("theme").getString("color");
            Color.parseColor(string);
            return string;
        } catch (Exception e) {
            try {
                jSONObject = this.dashOptionsJSON;
            } catch (Exception e2) {
                AnalyticsUtil.reportError("CxPsntrImpl", "S2", e2.getMessage());
            }
            if (jSONObject == null) {
                throw new Exception("No dash options defined");
            }
            str = jSONObject.getJSONObject("theme").getString("color");
            Color.parseColor(str);
            AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getMessage());
            return str;
        }
    }

    @Override
    public String getSdkPlugins() {
        HashMap<String, String> allPluginsFromManifest = BaseUtils.getAllPluginsFromManifest(this.activity);
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("isAmazonPluginIntegrated", false);
            jSONObject.put("isGooglePayPluginIntegrated", false);
        } catch (JSONException e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
        }
        if (allPluginsFromManifest != null && allPluginsFromManifest.size() != 0) {
            for (String str : allPluginsFromManifest.values()) {
                if (allPluginsFromManifest.size() > 0 && str.equalsIgnoreCase("com.razorpay.RazorpayAmazon")) {
                    jSONObject.put("isAmazonPluginIntegrated", true);
                }
                if (allPluginsFromManifest.size() > 0 && str.equalsIgnoreCase("com.razorpay.RzpGpayMerged")) {
                    jSONObject.put("isGooglePayPluginIntegrated", true);
                }
                if (allPluginsFromManifest.size() > 0 && str.equalsIgnoreCase("com.razorpay.RazorpayTurbo")) {
                    jSONObject.put("isTurboPluginIntegrated", true);
                }
            }
            return jSONObject.toString();
        }
        return jSONObject.toString();
    }

    @Override
    public void handleCardSaving() {
        AnalyticsUtil.trackEvent(AnalyticsEvent.CARD_SAVING_START);
        f$_G$.a(this.activity.getApplicationContext());
    }

    protected void helpersReset() {
    }

    void injectJs(String str) {
        this.view.loadUrl(1, String.format("javascript: %s", str));
    }

    @Override
    public void invokePopup(String str) {
        this.isTwoWebViewFlow = true;
        try {
            this.activity.runOnUiThread(new Q__8_(this, str));
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
        }
    }

    @Override
    public boolean isAllowRotation() {
        return this.allowRotation;
    }

    @Override
    public boolean isMagicPresent() {
        return false;
    }

    @Override
    public boolean isUserRegistered(String str) {
        return BaseUtils.checkGpayCardsUpiRegistered(this.activity, str);
    }

    @Override
    public boolean isUserRegisteredOnUPI(String str) {
        return BaseUtils.checkUpiRegisteredApp(this.activity, str);
    }

    @Override
    public void isWebViewSafe(int i, CheckoutBridge.WebViewSafeCheckCallback webViewSafeCheckCallback) {
        executeWebViewCallback(i, webViewSafeCheckCallback);
    }

    @Override
    public void isWebViewSafeOnUI(int i, CheckoutBridge.WebViewSafeCheckCallback webViewSafeCheckCallback) {
        this.activity.runOnUiThread(new l__9_(this, i, webViewSafeCheckCallback));
    }

    @Override
    public void loadFetchedForm(String str, String str2) {
        if (this.paymentAttempts != 0) {
            AnalyticsUtil.postData();
        }
        int i = this.paymentAttempts + 1;
        this.paymentAttempts = i;
        AnalyticsUtil.addProperty("payment_attempt", new AnalyticsProperty(i, AnalyticsProperty.Scope.ORDER));
        this.clearHistory = true;
        this.view.loadDataWithBaseURL(1, str, str2, "text/html", "UTF-8", null);
    }

    @Override
    public void loadForm(String str) {
        if (this.paymentAttempts != 0) {
            AnalyticsUtil.postData();
        }
        int i = this.paymentAttempts + 1;
        this.paymentAttempts = i;
        AnalyticsUtil.addProperty("payment_attempt", new AnalyticsProperty(i, AnalyticsProperty.Scope.ORDER));
        this.clearHistory = true;
        this.view.loadUrl(1, (this.checkoutUrl + str).replace(" ", "%20"));
    }

    @Override
    public void onActivityResultReceived(int i, int i2, Intent intent) {
        OutputStream openOutputStream;
        if (i == 77 && i2 == -1) {
            if (intent == null || intent.getData() == null) {
                return;
            }
            Uri data = intent.getData();
            String str = this.sanitizedChallanEncodedString;
            try {
                openOutputStream = this.activity.getContentResolver().openOutputStream(data);
                if (openOutputStream != null) {
                    try {
                        openOutputStream.write(Base64.decode(str, 0));
                        openOutputStream.flush();
                        BaseUtils.openPdfFile(this.activity, data);
                    } finally {
                    }
                }
                if (openOutputStream != null) {
                    openOutputStream.close();
                    return;
                }
                return;
            } catch (IOException e) {
                e.printStackTrace();
                return;
            }
        }
        if (i == 78 && i2 == -1) {
            if (intent == null || intent.getData() == null) {
                return;
            }
            Uri data2 = intent.getData();
            String str2 = this.sanitizedChallanEncodedString;
            try {
                openOutputStream = this.activity.getContentResolver().openOutputStream(data2);
                if (openOutputStream != null) {
                    try {
                        openOutputStream.write(Base64.decode(str2, 0));
                        openOutputStream.flush();
                        BaseUtils.openFile(this.activity, data2);
                    } finally {
                        try {
                            openOutputStream.close();
                        } catch (Throwable th) {
                            th.addSuppressed(th);
                        }
                    }
                }
                if (openOutputStream != null) {
                    openOutputStream.close();
                    return;
                }
                return;
            } catch (IOException e2) {
                e2.printStackTrace();
                return;
            }
        }
        if (i == 1001) {
            if (i2 == -1) {
                AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_RECEIVED_SMS);
                String stringExtra = intent.getStringExtra("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE");
                if (this.isCheckoutLoaded) {
                    try {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("sender", "razorpay");
                        jSONObject.put("message", stringExtra);
                        injectJs(String.format("OTPElf.showOTP('%s','%s')", stringExtra, "razorpay"));
                        AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_OTP_POPULATION_JS);
                    } catch (JSONException e3) {
                        AnalyticsUtil.reportError("CxPsntrImpl", "S0", e3.getLocalizedMessage());
                        e3.printStackTrace();
                    }
                }
            } else {
                AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_CONSENT_DECLINED);
            }
            Task<Void> task = this.userConsentTask;
            if (task == null || task.isSuccessful()) {
                return;
            }
            startSmsRetrievers();
            return;
        }
        if (i == 99) {
            JSONObject jSONFromIntentData = BaseUtils.getJSONFromIntentData(intent);
            if (jSONFromIntentData.toString().contains("\"from\":\"razorpay\"") && AnalyticsUtil.getKeyType().equalsIgnoreCase("test") && this.internalUpiApp.booleanValue()) {
                destroyActivity(0, "");
                return;
            } else {
                loadResultToWebView(jSONFromIntentData, String.format("javascript: upiIntentResponse(%s)", jSONFromIntentData.toString()));
                return;
            }
        }
        if (i == 20) {
            try {
                JSONObject jSONObject2 = new JSONObject("{'data':" + i2 + "}");
                jSONObject2.put("provider", "CRED");
                loadResultToWebView(jSONObject2, String.format("javascript:externalAppResponse(%s)", jSONObject2.toString()));
            } catch (JSONException e4) {
                AnalyticsUtil.reportError("CxPsntrImpl", "S0", e4.getMessage());
            }
        }
    }

    @Override
    public void onCheckoutBackPress() {
        AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_SOFT_BACK_PRESSED);
        destroyActivity(0, BaseUtils.getPaymentCancelledResponse(BaseUtils.getInstance().getMetadata()));
    }

    @Override
    public void onCheckoutRendered() {
        System.currentTimeMillis();
        AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_RENDERED_COMPLETE);
    }

    protected void onComplete(JSONObject jSONObject) {
        try {
            if (jSONObject.has("error")) {
                AnalyticsProperty.Scope scope = AnalyticsProperty.Scope.PAYMENT;
                AnalyticsUtil.addProperty("payment_status", new AnalyticsProperty("fail", scope));
                AnalyticsUtil.addProperty("payload", new AnalyticsProperty(jSONObject.toString(), scope));
                AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_PAYMENT_COMPLETE);
                if (this.isTwoWebViewFlow) {
                    this.view.makeWebViewVisible(1);
                }
                onError(jSONObject);
            } else if (jSONObject.has("razorpay_fund_account_id")) {
                destroyActivity(1, jSONObject.toString());
            } else if (jSONObject.has("razorpay_payment_id")) {
                String string = jSONObject.getString("razorpay_payment_id");
                this.payment_id = string;
                AnalyticsProperty.Scope scope2 = AnalyticsProperty.Scope.PAYMENT;
                AnalyticsUtil.addProperty("payment_id", new AnalyticsProperty(string, scope2));
                AnalyticsUtil.addProperty("payment_status", new AnalyticsProperty("success", scope2));
                AnalyticsUtil.addProperty("payload", new AnalyticsProperty(jSONObject.toString(), scope2));
                AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_PAYMENT_COMPLETE);
                this.isPaymentSuccessful = true;
                destroyActivity(1, jSONObject.toString());
            } else if (jSONObject.has("external_wallet")) {
                destroyActivity(4, jSONObject.toString());
            } else {
                destroyActivity(0, "Post payment parsing error");
            }
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
            destroyActivity(0, e.getMessage());
        }
        this.isTwoWebViewFlow = false;
    }

    @Override
    public void onDismiss() {
        destroyActivity(0, BaseUtils.getPaymentCancelledResponse(BaseUtils.getInstance().getMetadata()));
    }

    protected void onError(final JSONObject jSONObject) {
        if (this.isTwoWebViewFlow) {
            this.view.loadUrl(1, String.format("javascript: window.onComplete(%s)", jSONObject.toString()));
        } else {
            this.activity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    CheckoutPresenterImpl.this.handleRetry(jSONObject.toString());
                }
            });
        }
    }

    @Override
    public void onFault(String str) {
        try {
            new JSONObject(str);
        } catch (JSONException unused) {
        }
    }

    @Override
    public void onLoad() {
        if (this.integratedPluginsData.has("upi_turbo")) {
            return;
        }
        CheckoutUtils.a();
        this.activity.runOnUiThread(new C0213b._f_(this));
        startSmsRetrievers();
    }

    @Override
    public void onPageFinished(int i, WebView webView, String str) {
        X$_8_ x$_8_;
        if (i == 1) {
            primaryWebviewPageFinished(str, webView);
            if (str.contains(this.checkoutUrl)) {
                return;
            }
            CheckoutUtils.a();
            return;
        }
        if (i == 2 && (x$_8_ = this.magicBase) != null && this.isMagic) {
            x$_8_.a();
        }
    }

    @Override
    public void onPageStarted(int i, WebView webView, String str) {
        X$_8_ x$_8_;
        if (i == 2 && (x$_8_ = this.magicBase) != null && this.isMagic) {
            x$_8_.b = false;
        }
    }

    @Override
    public void onProgressChanges(int i, int i2) {
        if (i != 1) {
            return;
        }
        this.view.showProgressBar(i2);
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
    }

    @Override
    public void onResumeTriggered() {
        if (this.truecallerLoginAttempt && this.view.isWebViewVisible(1)) {
            try {
                this.view.loadUrl(1, String.format("javascript: window.externalSDKResponse(%s)", new JSONObject().put("provider", "truecaller")));
                this.truecallerLoginAttempt = false;
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
    }

    @Override
    public void onSubmit(java.lang.String r6) {
        throw new UnsupportedOperationException("Method not decompiled: com.razorpay.CheckoutPresenterImpl.onSubmit(java.lang.String):void");
    }

    @Override
    public void passPrefillToSegment() {
        String k = this.checkoutOptions.k();
        if (!TextUtils.isEmpty(k)) {
            AnalyticsUtil.addProperty("email", new AnalyticsProperty(k, AnalyticsProperty.Scope.ORDER));
        }
        String j = this.checkoutOptions.j();
        if (TextUtils.isEmpty(j)) {
            return;
        }
        AnalyticsUtil.addProperty("contact", new AnalyticsProperty(j, AnalyticsProperty.Scope.ORDER));
    }

    protected void primaryWebviewPageFinished(String str, WebView webView) {
        long nanoTime = System.nanoTime();
        this.view.hideProgressBar();
        if (str.contains("https://api.razorpay.com") && str.contains("android") && str.contains(BuildConfig.VERSION_NAME)) {
            if (this.paymentAttempts == 1) {
                this.isCheckoutLoaded = true;
                sendQueuedMessagesToCheckout();
                HashMap hashMap = new HashMap();
                long j = nanoTime - this.checkoutLoadStartAt;
                hashMap.put("checkout_load_duration", Long.valueOf(j));
                BaseUtils.nanoTimeToSecondsString(j, 2);
                BaseUtils.nanoTimeToSecondsString(j, 2);
                BaseUtils.nanoTimeToSecondsString(j, 2);
                long j2 = this.preloadCompleteDuration;
                if (j2 > 0) {
                    hashMap.put("preload_finish_duration", Long.valueOf(j2));
                    BaseUtils.nanoTimeToSecondsString(this.preloadCompleteDuration, 2);
                } else {
                    long j3 = this.preloadAbortDuration;
                    if (j3 > 0) {
                        hashMap.put("preload_abort_duration", Long.valueOf(j3));
                        BaseUtils.nanoTimeToSecondsString(this.preloadAbortDuration, 2);
                    }
                }
                long j4 = this.preloadCompleteDuration - j;
                if (j4 > 0) {
                    hashMap.put("time_shaved_off", Long.valueOf(j4));
                    BaseUtils.nanoTimeToSecondsString(j4, 2);
                }
                AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_LOADED, AnalyticsUtil.getJSONResponse(hashMap));
            }
            if (this.clearHistory) {
                this.view.clearWebViewHistory(1);
                this.clearHistory = false;
            }
        }
    }

    @Override
    public void registerSmsListener() {
        try {
            IntentFilter intentFilter = new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED");
            if (Build.VERSION.SDK_INT >= 33) {
                this.activity.registerReceiver(this.otpAutoReadBroadcast, intentFilter, "com.google.android.gms.auth.api.phone.permission.SEND", null, 2);
            } else {
                this.activity.registerReceiver(this.otpAutoReadBroadcast, intentFilter, "com.google.android.gms.auth.api.phone.permission.SEND", null);
            }
            this.isSmsReceiverRegistered = true;
        } catch (Exception unused) {
            this.isSmsReceiverRegistered = false;
        }
    }

    @Override
    public void relay(String str) {
    }

    @Override
    public void requestExtraAnalyticsData() {
        final JSONObject extraAnalyticsPayload = AnalyticsUtil.getExtraAnalyticsPayload();
        this.activity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                try {
                    CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: CheckoutBridge.sendExtraAnalyticsData(%s)", extraAnalyticsPayload.toString()));
                } catch (Exception e) {
                    AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
                }
            }
        });
    }

    @Override
    public void requestOtpPermission() {
    }

    @Override
    public void saveInstanceState(Bundle bundle) {
        if (this.merchantLogoResourceId != 0) {
            bundle.putString("OPTIONS", this.checkoutOptions.i());
            bundle.putInt("IMAGE", this.merchantLogoResourceId);
        } else {
            bundle.putString("OPTIONS", this.checkoutOptions.e());
        }
        bundle.putString("DASH_OPTIONS", this.dashOptions);
        if (this.activity.getIntent() != null) {
            bundle.putBoolean("DISABLE_FULL_SCREEN", this.activity.getIntent().getBooleanExtra("DISABLE_FULL_SCREEN", false));
        }
    }

    @Override
    public void sendDataToWebView(final int i, final String str) {
        this.activity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                int i2 = i;
                if (i2 == 1) {
                    CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: handleRelay(%s)", str));
                } else {
                    if (i2 != 2) {
                        return;
                    }
                    CheckoutPresenterImpl.this.view.loadUrl(2, String.format("javascript: Magic.handleRelay(%s)", str));
                }
            }
        });
    }

    @Override
    public void sendExternalSdkResponse(String str) {
        String format = String.format("javascript: window.externalSDKResponse(%s)", str);
        if (this.isCheckoutLoaded) {
            this.view.loadUrl(1, format);
            return;
        }
        if (this.checkoutMessageQueue == null) {
            this.checkoutMessageQueue = new LinkedList();
        }
        this.checkoutMessageQueue.add(format);
    }

    @Override
    public void sendOtpPermissionCallback(final boolean z) {
        this.activity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                try {
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("granted", z);
                    CheckoutPresenterImpl.this.view.loadUrl(1, String.format("javascript: otpPermissionCallback(%s)", jSONObject.toString()));
                } catch (Exception e) {
                    AnalyticsUtil.reportError("CxPsntrImpl", "S2", e.getLocalizedMessage());
                }
            }
        });
    }

    @Override
    public void setAppToken(String str) {
        A.b(this.activity).putString("rzp_app_token", str).apply();
    }

    @Override
    public void setCheckoutLoadStartAt() {
        this.checkoutLoadStartAt = System.nanoTime();
    }

    @Override
    public void setDeviceToken(String str) {
        f$_G$.a(this.activity, str);
    }

    @Override
    public void setDimensions(final int i, final int i2) {
        if (q.a(this.activity)) {
            this.activity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    WindowManager.LayoutParams attributes = CheckoutPresenterImpl.this.activity.getWindow().getAttributes();
                    attributes.height = q.a(CheckoutPresenterImpl.this.activity, i2);
                    attributes.width = q.a(CheckoutPresenterImpl.this.activity, i);
                    CheckoutPresenterImpl.this.activity.getWindow().setAttributes(attributes);
                }
            });
        }
    }

    @Override
    public void setMerchantOptions(java.lang.String r5) {
        throw new UnsupportedOperationException("Method not decompiled: com.razorpay.CheckoutPresenterImpl.setMerchantOptions(java.lang.String):void");
    }

    @Override
    public boolean setOptions(Bundle bundle, boolean z) {
        this.isActivityCreated = z;
        if (bundle == null) {
            destroyActivity(0, this.activity.getResources().getString(R.string.activity_result_invalid_parameters));
            return false;
        }
        this.checkoutOptions = new L_$k$(bundle.getString("OPTIONS"));
        setupExternalPlugins(this.pluginsMap);
        JSONObject d = this.checkoutOptions.d();
        if (d.has("retry")) {
            p$_5$.a().a(d);
        }
        if (d.has("hideNativeLoader")) {
            this.hideCircularLoader = Boolean.TRUE;
        }
        this.merchantKey = this.checkoutOptions.a();
        this.sendSmsHash = this.checkoutOptions.b();
        this.allowRotation = this.checkoutOptions.c();
        int i = bundle.getInt("IMAGE", 0);
        this.merchantLogoResourceId = i;
        this.checkoutOptions.a(this.activity, i);
        CheckoutUtils.a(this.activity, this.merchantKey);
        d.has("ep");
        String a = CheckoutUtils.a(this.checkoutOptions);
        this.checkoutUrl = a;
        if (a == null) {
            destroyActivity(3, this.activity.getResources().getString(R.string.activity_result_invalid_url));
        }
        if (z) {
            this.dashOptions = bundle.getString("DASH_OPTIONS");
            if (!bundle.getBoolean("DISABLE_FULL_SCREEN", false)) {
                return true;
            }
            CheckoutUtils.a(this.activity);
            return true;
        }
        this.checkoutOptions.h();
        String c = CheckoutUtils.c(this.activity, this.merchantKey);
        this.dashOptions = c;
        if (c != null) {
            try {
                this.dashOptionsJSON = new JSONObject(this.dashOptions);
            } catch (Exception e) {
                AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getLocalizedMessage());
            }
        }
        String string = bundle.getString("FRAMEWORK");
        if (string != null) {
            AnalyticsUtil.addProperty("framework", new AnalyticsProperty(string, AnalyticsProperty.Scope.ORDER));
        }
        AnalyticsUtil.setFramework(string);
        String string2 = bundle.getString("FRAMEWORK_VERSION");
        if (string2 != null) {
            AnalyticsUtil.addProperty("frameworkVersion", new AnalyticsProperty(string2, AnalyticsProperty.Scope.ORDER));
        }
        if (bundle.getBoolean("DISABLE_FULL_SCREEN", false)) {
            CheckoutUtils.a(this.activity);
        }
        if (bundle.containsKey("PRELOAD_COMPLETE_DURATION")) {
            this.preloadCompleteDuration = bundle.getLong("PRELOAD_COMPLETE_DURATION");
        }
        if (!bundle.containsKey("PRELOAD_ABORT_DURATION")) {
            return true;
        }
        this.preloadAbortDuration = bundle.getLong("PRELOAD_ABORT_DURATION");
        return true;
    }

    @Override
    public void setOptionsWithDynamicUrl(Context context, Bundle bundle, boolean z, final BaseCheckoutActivity.SetOptionsCallback setOptionsCallback) {
        if (A.a(context, "optimizer_hosted") == null) {
            CheckoutUtils.a(this.checkoutOptions.a(), "optimizer_hosted", new Callback() {
                @Override
                public final void run(ResponseObject responseObject) {
                    if (!responseObject.getResponseResult().equalsIgnoreCase("true")) {
                        setOptionsCallback.onFeatureDisabled();
                        return;
                    }
                    CheckoutPresenterImpl checkoutPresenterImpl = CheckoutPresenterImpl.this;
                    checkoutPresenterImpl.checkoutUrl = CheckoutUtils.a(checkoutPresenterImpl.checkoutOptions, (String) null);
                    CheckoutPresenterImpl.this.isDynamicUrlLoaded = true;
                    setOptionsCallback.onOptionsSet();
                }
            });
            return;
        }
        this.checkoutUrl = CheckoutUtils.a(this.checkoutOptions, (String) null);
        this.isDynamicUrlLoaded = true;
        setOptionsCallback.onOptionsSet();
    }

    @Override
    public void setPaymentID(String str) {
        this.payment_id = str;
        BaseUtils.getInstance().setPaymentId(str);
        if (this.checkoutOptions.f() != null) {
            BaseUtils.getInstance().setOrderId(this.checkoutOptions.f());
        }
        AnalyticsUtil.addProperty("payment_id", new AnalyticsProperty(str, AnalyticsProperty.Scope.PAYMENT));
        AnalyticsUtil.trackEvent(AnalyticsEvent.PAYMENT_ID_ATTACHED);
    }

    @Override
    public void setUpAddOn() {
    }

    @Override
    public void showAlertDialog(String str, String str2, String str3) {
        this.activity.runOnUiThread(new K_$q$(this, str, str3, str2));
    }

    @Override
    public void showLoaderDialog(final int i, final String str) {
        this.view.loadUrl(1, "about:blank");
        if (this.activity.isFinishing()) {
            return;
        }
        final AlertDialog create = new AlertDialog.Builder(this.activity).create();
        create.setCancelable(false);
        create.setTitle("Trouble Connecting");
        create.setMessage("Unable to connect to Razorpay.\n\nPlease check your internet connection and/or disconnect from VPN if connected and hit Try Again");
        create.setButton(-1, "Try again", new r__Q_(this));
        create.setButton(-2, "Cancel Payment", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                create.dismiss();
                CheckoutPresenterImpl.this.destroyActivity(i, str);
            }
        });
        create.show();
    }

    @Override
    public void showRetryDialog(final int i, final String str) {
        this.view.loadUrl(1, "about:blank");
        final AlertDialog create = new AlertDialog.Builder(this.activity).create();
        create.setTitle("Trouble Connecting");
        create.setMessage("Please check your internet connection & restart the payment process.\n\nRetrying in 5 seconds");
        create.setButton(-2, "Cancel Payment", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                create.dismiss();
                CheckoutPresenterImpl.this.destroyActivity(i, str);
            }
        });
        create.show();
        new v__i_(this, 5000L, 1000L, create).start();
    }

    @Override
    public void toast(final String str, final int i) {
        this.activity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                CheckoutPresenterImpl.this.view.showToast(str, i);
            }
        });
    }

    @Override
    public void unregisterReceivers() {
        try {
            BroadcastReceiver broadcastReceiver = this.otpAutoReadBroadcast;
            if (broadcastReceiver != null) {
                this.activity.unregisterReceiver(broadcastReceiver);
                this.isSmsReceiverRegistered = false;
            }
        } catch (Exception e) {
            this.isSmsReceiverRegistered = false;
            AnalyticsUtil.reportError("CxPrntrImpl", "S2", e.getMessage());
        }
    }

    @Override
    public void unregisterSmsListener() {
        unregisterReceivers();
    }

    @Override
    public void onDismiss(String str) {
        try {
            destroyActivity(0, new JSONObject(str).toString());
        } catch (JSONException unused) {
            destroyActivity(0, BaseUtils.getGenericPaymentErrorResponse(str, BaseUtils.getInstance().getMetadata()));
        }
    }

    @Override
    public void onError(String str) {
        try {
            onError(new JSONObject(str));
        } catch (Exception e) {
            AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
            this.activity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    CheckoutPresenterImpl.this.helpersReset();
                    CheckoutPresenterImpl.this.loadForm("");
                }
            });
        }
    }

    @Override
    public void onComplete(final String str) {
        this.activity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                try {
                    CheckoutPresenterImpl.this.onComplete(new JSONObject(str));
                } catch (Exception e) {
                    AnalyticsUtil.reportError("CxPsntrImpl", "S0", e.getMessage());
                    CheckoutPresenterImpl.this.destroyActivity(0, BaseUtils.getPaymentCancelledResponse(BaseUtils.getInstance().getMetadata()));
                }
            }
        });
    }

    public CheckoutPresenterImpl(Activity activity, CheckoutView checkoutView, HashMap<String, String> hashMap) {
        Boolean bool = Boolean.FALSE;
        this.internalUpiApp = bool;
        this.hideCircularLoader = bool;
        this.otpAutoReadBroadcast = new BroadcastReceiver() {
            @Override
            public final void onReceive(Context context, Intent intent) {
                if ("com.google.android.gms.auth.api.phone.SMS_RETRIEVED".equals(intent.getAction())) {
                    Bundle extras = intent.getExtras();
                    Status status = (Status) extras.get("com.google.android.gms.auth.api.phone.EXTRA_STATUS");
                    AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_RECEIVED_SMS);
                    int statusCode = status.getStatusCode();
                    if (statusCode != 0) {
                        if (statusCode != 15) {
                            return;
                        }
                        AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_TIMEOUT);
                        return;
                    }
                    Intent intent2 = (Intent) extras.get("com.google.android.gms.auth.api.phone.EXTRA_CONSENT_INTENT");
                    if (intent2 == null) {
                        String str = (String) extras.get("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE");
                        Intent intent3 = new Intent();
                        intent3.putExtra("com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE", str);
                        CheckoutPresenterImpl.this.onActivityResultReceived(1001, -1, intent3);
                        return;
                    }
                    ComponentName callingActivity = CheckoutPresenterImpl.this.activity.getCallingActivity();
                    if (callingActivity != null && callingActivity.getPackageName().equals(CheckoutPresenterImpl.this.activity.getPackageName()) && CheckoutPresenterImpl.this.activity.getLocalClassName().contains("CheckoutActivity")) {
                        try {
                            CheckoutPresenterImpl.this.activity.startActivityForResult(intent2, 1001);
                            AnalyticsUtil.trackEvent(AnalyticsEvent.AUTO_READ_OTP_SMS_RETRIEVER_API_SHOWED_ONE_TIME_CONSENT);
                        } catch (ActivityNotFoundException e) {
                            AnalyticsUtil.reportError("AutoReadOtpHelper", "S0", e.getLocalizedMessage());
                        }
                    }
                }
            }
        };
        this.checkoutMessageQueue = new LinkedList();
        this.isCheckoutLoaded = false;
        this.integratedPluginsData = new JSONObject();
        this.truecallerLoginAttempt = false;
        this.activity = activity;
        this.view = checkoutView;
        this.pluginsMap = hashMap;
    }
}