导航菜单

页面标题

页面副标题

Hopscotch v9.7.2 - GoKwikActivity.java 源代码

正在查看: Hopscotch v9.7.2 应用的 GoKwikActivity.java JAVA 源代码文件

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


package com.gokwik.sdk;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.Toast;
import androidx.core.app.c;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.f0;
import androidx.media3.exoplayer.c0;
import androidx.media3.exoplayer.i0;
import androidx.media3.exoplayer.t;
import androidx.media3.exoplayer.u;
import com.facebook.stetho.common.Utf8Charset;
import com.gokwik.sdk.api.AnalyticsApiService;
import com.gokwik.sdk.api.ApiService;
import com.gokwik.sdk.api.models.CheckoutData;
import com.gokwik.sdk.api.models.VerifyOrderData;
import com.gokwik.sdk.api.requests.OrderStatusRequest;
import com.gokwik.sdk.api.requests.VerifyOrderRequest;
import com.gokwik.sdk.api.requests.analytics.CodLoadRequest;
import com.gokwik.sdk.api.requests.analytics.UpiAppClickRequest;
import com.gokwik.sdk.api.requests.analytics.UpiLoadRequest;
import com.gokwik.sdk.api.responses.CaptureOrderResponse;
import com.gokwik.sdk.api.responses.VerifyOrderResponse;
import com.gokwik.sdk.o;
import in.hopscotch.android.activity.v5;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.json.JSONObject;

public class GoKwikActivity extends com.gokwik.sdk.common.a implements o.a {
    public static final int m = 0;
    private AnalyticsApiService analyticsApiService;
    private ApiService apiService;
    private CheckoutData checkoutData;
    private io.reactivex.disposables.a compositeDisposable;
    public final String i;
    public int j;
    public boolean k;
    public boolean l;
    private ArrayList<PaymentOptions> paymentOptions;
    private androidx.activity.result.b<Intent> upiPaymentActivityResultLauncher;
    private VerifyOrderData verifyOrderData;

    public GoKwikActivity() {
        super(m.gk_activity_main);
        this.i = "GoKwikActivity";
        this.j = 0;
        this.k = false;
        this.l = false;
    }

    public static void S0(GoKwikActivity goKwikActivity, VerifyOrderResponse verifyOrderResponse, Throwable th) {
        goKwikActivity.a1(Boolean.FALSE);
        String str = goKwikActivity.i;
        if (th != null) {
            Log.d(str, "Error: " + th.getMessage());
            a.a().b.a(th.getMessage() != null ? th.getMessage() : "");
            goKwikActivity.finish();
            return;
        }
        if (verifyOrderResponse != null && verifyOrderResponse.getStatusCode() != 200) {
            Log.d(str, "Error: " + verifyOrderResponse.getStatusMessage());
            a.a().b.a(verifyOrderResponse.getStatusMessage() != null ? verifyOrderResponse.getStatusMessage() : "");
            goKwikActivity.finish();
            return;
        }
        try {
            Log.d(str, "Verify success: " + verifyOrderResponse.toString());
            goKwikActivity.verifyOrderData = verifyOrderResponse.getData();
            if (goKwikActivity.checkoutData.getOrderType().equalsIgnoreCase("cod")) {
                Log.d(str, "otpverified: " + goKwikActivity.verifyOrderData.getOtpVerified());
                if (goKwikActivity.verifyOrderData.isMerchantUserVerified() || goKwikActivity.verifyOrderData.getOtpVerified() != null) {
                    goKwikActivity.b1("instant");
                    v5.a aVar = a.a().b;
                    JSONObject jSONObject = new JSONObject(new com.google.gson.k().h(goKwikActivity.verifyOrderData));
                    aVar.getClass();
                    Log.e("GoKwik", jSONObject.toString());
                    goKwikActivity.finish();
                } else {
                    Bundle bundle = new Bundle();
                    bundle.putParcelable("verify_order_data", goKwikActivity.verifyOrderData);
                    bundle.putParcelable("checkout_data", goKwikActivity.checkoutData);
                    bundle.putString("phone_number", goKwikActivity.verifyOrderData.getPhone());
                    int i = l.fragment_container_view;
                    FragmentManager supportFragmentManager = goKwikActivity.getSupportFragmentManager();
                    supportFragmentManager.getClass();
                    androidx.fragment.app.a aVar2 = new androidx.fragment.app.a(supportFragmentManager);
                    ((f0) aVar2).p = true;
                    aVar2.b(i, d.class, bundle, "d");
                    aVar2.j();
                    aVar2.p(false);
                    goKwikActivity.b1("otp");
                }
            } else if (goKwikActivity.checkoutData.getUpiApp() == null || goKwikActivity.checkoutData.getUpiApp().isEmpty()) {
                goKwikActivity.l = false;
                goKwikActivity.paymentOptions = com.gokwik.sdk.common.d.a(goKwikActivity.getPackageManager(), goKwikActivity.verifyOrderData.getUapp());
                Bundle bundle2 = new Bundle();
                bundle2.putParcelable("verify_order_data", goKwikActivity.verifyOrderData);
                bundle2.putParcelable("checkout_data", goKwikActivity.checkoutData);
                bundle2.putParcelableArrayList("payment_options", goKwikActivity.paymentOptions);
                int i2 = l.fragment_container_view;
                FragmentManager supportFragmentManager2 = goKwikActivity.getSupportFragmentManager();
                supportFragmentManager2.getClass();
                androidx.fragment.app.a aVar3 = new androidx.fragment.app.a(supportFragmentManager2);
                ((f0) aVar3).p = true;
                aVar3.b(i2, p.class, bundle2, "p");
                aVar3.j();
                aVar3.p(false);
                goKwikActivity.d1(goKwikActivity.paymentOptions.size(), "upi");
                if (goKwikActivity.paymentOptions.size() == 0) {
                    io.reactivex.disposables.b subscribe = io.reactivex.l.timer(10L, TimeUnit.SECONDS).subscribeOn(io.reactivex.schedulers.a.b).observeOn(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).subscribe(new t(goKwikActivity, 11));
                    goKwikActivity.compositeDisposable.d();
                    goKwikActivity.compositeDisposable.b(subscribe);
                }
            } else {
                goKwikActivity.Z0(goKwikActivity.checkoutData.getUpiApp(), goKwikActivity.verifyOrderData);
                goKwikActivity.d1(0, "instant");
                goKwikActivity.c1(com.gokwik.sdk.common.d.b(goKwikActivity.checkoutData.getUpiApp()));
                goKwikActivity.l = true;
            }
        } catch (Exception e) {
            Log.e(str, "Json error: " + e.getMessage());
        }
    }

    public static void T0(final GoKwikActivity goKwikActivity, final boolean z, CaptureOrderResponse captureOrderResponse, Throwable th) {
        if (!goKwikActivity.k && goKwikActivity.j > 24) {
            a.a().b.a("Capture Order Timeout");
            goKwikActivity.compositeDisposable.dispose();
            goKwikActivity.finish();
            return;
        }
        String str = goKwikActivity.i;
        if (th != null) {
            Log.d(str, "Error: " + th.getMessage());
            a.a().b.a(th.getMessage() != null ? th.getMessage() : "");
            goKwikActivity.finish();
            return;
        }
        if (captureOrderResponse != null && captureOrderResponse.getStatusCode() != 200) {
            Log.d(str, "Error: " + captureOrderResponse.getStatusMessage());
            a.a().b.a(captureOrderResponse.getStatusMessage() != null ? captureOrderResponse.getStatusMessage() : "");
            goKwikActivity.finish();
            return;
        }
        Log.d(str, "checkOrderStatus api call success: " + captureOrderResponse.toString());
        if (captureOrderResponse.getData() == null || captureOrderResponse.getData().getPaymentStatus() == null || !captureOrderResponse.getData().getPaymentStatus().equalsIgnoreCase("PAID")) {
            io.reactivex.disposables.b subscribe = io.reactivex.l.timer(5L, TimeUnit.SECONDS).subscribeOn(io.reactivex.schedulers.a.b).observeOn(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).subscribe(new io.reactivex.functions.f() {
                public final void accept(Object obj) {
                    GoKwikActivity goKwikActivity2 = GoKwikActivity.this;
                    goKwikActivity2.j++;
                    goKwikActivity2.V0(z);
                }
            });
            goKwikActivity.compositeDisposable.d();
            goKwikActivity.compositeDisposable.b(subscribe);
        } else {
            v5.a aVar = a.a().b;
            JSONObject jSONObject = new JSONObject(new com.google.gson.k().h(captureOrderResponse));
            aVar.getClass();
            Log.e("GoKwik", jSONObject.toString());
            goKwikActivity.compositeDisposable.dispose();
            goKwikActivity.finish();
        }
    }

    public final void V0(boolean z) {
        Log.d(this.i, "checkOrderStatus::::::::::");
        if (this.l) {
            a1(Boolean.TRUE);
        } else if (z) {
            findViewById(l.progress_bar_upi).setVisibility(0);
            findViewById(l.select_any_app).setVisibility(8);
            findViewById(l.upi_app_list).setVisibility(8);
        }
        this.apiService.checkOrderStatus(new OrderStatusRequest(this.checkoutData, this.verifyOrderData.getAuthToken(), this.verifyOrderData.getPhone())).g(io.reactivex.schedulers.a.b).d(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).e(new f(this, z));
    }

    public final String W0() {
        try {
            return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public final void X0() {
        Dialog dialog = new Dialog(this);
        dialog.setContentView(m.gk_alert_dialog);
        ((Button) dialog.findViewById(l.yes)).setOnClickListener(new h(this, dialog));
        ((Button) dialog.findViewById(l.no)).setOnClickListener(new i(this, dialog));
        dialog.show();
        dialog.getWindow().setLayout(-1, -2);
    }

    public final void Y0(int i) {
        Z0(this.paymentOptions.get(i).e(), this.verifyOrderData);
        c1(this.paymentOptions.get(i).d().name());
    }

    public final void Z0(String str, VerifyOrderData verifyOrderData) {
        try {
            Uri parse = Uri.parse(URLDecoder.decode(verifyOrderData.getUlink(), Utf8Charset.NAME));
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(parse);
            intent.setPackage(str);
            this.upiPaymentActivityResultLauncher.b(intent, (c.a) null);
        } catch (Exception e) {
            Log.e(this.i, e.getMessage());
        }
    }

    public final void a1(Boolean bool) {
        findViewById(l.progress_bar_main).setVisibility(bool.booleanValue() ? 0 : 8);
    }

    public final void b1(String str) {
        String platform = this.checkoutData.getPlatform();
        try {
            this.analyticsApiService.triggerOnShowOtpDialogAnalytics(new CodLoadRequest("otp_dialog_load", str, this.checkoutData.getOrderType(), this.checkoutData.getMid(), this.checkoutData.getGokwikOid(), this.checkoutData.getRequestId(), W0(), platform)).g(io.reactivex.schedulers.a.b).d(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).e(new e(this, 1));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void c1(String str) {
        String platform = this.checkoutData.getPlatform();
        try {
            this.analyticsApiService.triggerOnClickAnalytics(new UpiAppClickRequest("click", str, this.checkoutData.getOrderType(), this.checkoutData.getMid(), this.checkoutData.getGokwikOid(), this.checkoutData.getRequestId(), W0(), platform)).g(io.reactivex.schedulers.a.b).d(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).e(new i0(this, 7));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void d1(int i, String str) {
        String platform = this.checkoutData.getPlatform();
        try {
            this.analyticsApiService.triggerOnLoadAnalytics(new UpiLoadRequest("page_load", str, String.valueOf(i), this.checkoutData.getOrderType(), this.checkoutData.getMid(), this.checkoutData.getGokwikOid(), this.checkoutData.getRequestId(), W0(), platform)).g(io.reactivex.schedulers.a.b).d(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).e(new u(this, 8));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void e1(ArrayList<String> arrayList) {
        NetworkInfo activeNetworkInfo;
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
        if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isConnected() || !activeNetworkInfo.isConnectedOrConnecting() || !activeNetworkInfo.isAvailable()) {
            Log.e("UPI", "Internet connection  not available");
            if (!this.l) {
                Toast.makeText((Context) this, (CharSequence) "Internet connection failed. Please check connection and try again", 0).show();
                return;
            }
            a.a().b.a("Internet connection not available.");
            this.compositeDisposable.dispose();
            finish();
            return;
        }
        String str = arrayList.get(0);
        Log.e("UPIPAY", "upiPaymentDataOperation: " + str);
        if (str == null) {
            str = "discard";
        }
        String str2 = "";
        String str3 = "";
        String str4 = str3;
        for (String str5 : str.split("&")) {
            String[] split = str5.split("=");
            if (split.length < 2) {
                str3 = "Payment cancelled by user.";
            } else if (split[0].equalsIgnoreCase("Status")) {
                str2 = split[1].toLowerCase();
            } else if (split[0].equalsIgnoreCase("ApprovalRefNo") || split[0].equalsIgnoreCase("txnRef")) {
                str4 = split[1];
            }
        }
        if (str2.equals("success")) {
            Log.e("UPI", "payment successfull: " + str4);
            this.j = 0;
            this.k = false;
            V0(true);
            return;
        }
        if ("Payment cancelled by user.".equals(str3)) {
            Log.e("UPI", "payment cancelled: " + str4);
            if (!this.l) {
                Toast.makeText((Context) this, (CharSequence) "Payment cancelled. Please try again", 0).show();
                return;
            }
            a.a().b.a("Payment cancelled.");
            this.compositeDisposable.dispose();
            finish();
            return;
        }
        Log.e("UPI", "payment failed: " + str4);
        if (!this.l) {
            Toast.makeText((Context) this, (CharSequence) "Transaction failed. Please try again", 0).show();
            return;
        }
        a.a().b.a("Transaction failed.");
        this.compositeDisposable.dispose();
        finish();
    }

    public final void onBackPressed() {
        X0();
    }

    @Override
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.checkoutData = (CheckoutData) getIntent().getParcelableExtra("checkout_data");
        this.apiService = R0().c(this.checkoutData.getIsProduction());
        this.analyticsApiService = R0().b(this.checkoutData.getIsProduction());
        if (a.a().b == null) {
            finish();
        } else {
            CheckoutData checkoutData = this.checkoutData;
            if (checkoutData == null) {
                a.a().b.a("invalid checkout data");
                finish();
            } else if (checkoutData.getOrderType() == null || !this.checkoutData.getOrderType().equalsIgnoreCase("non-gk")) {
                a1(Boolean.TRUE);
                this.apiService.verifyOrderRequest(new VerifyOrderRequest(this.checkoutData)).g(io.reactivex.schedulers.a.b).d(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).e(new e(this, 0));
            } else {
                a1(Boolean.TRUE);
                this.apiService.updateNonGkOrder(this.checkoutData.getRequestId(), this.checkoutData.getMoid()).g(io.reactivex.schedulers.a.b).d(com.gokwik.sdk.common.rxandroid.schedulers.a.a()).e(new c0(this, 6));
            }
        }
        this.upiPaymentActivityResultLauncher = registerForActivityResult(new androidx.activity.result.contract.e(), new com.facebook.login.d(this, 1));
        this.compositeDisposable = new io.reactivex.disposables.a();
    }

    public final boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

    public final boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
        }
        X0();
        return true;
    }
}