导航菜单

页面标题

页面副标题

Chaupal v3.2 - CheckoutUtils.java 源代码

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

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


package com.razorpay;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ResolveInfo;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.ValueCallback;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.widget.LinearLayout;
import com.razorpay.CheckoutUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

final class CheckoutUtils {
    private static Dialog a;

    interface BackButtonDialogCallback {
        void onNegativeButtonClick();

        void onPositiveButtonClick();
    }

    CheckoutUtils() {
    }

    static void a(Context context, String str) {
        AnalyticsUtil.setup(context, str, p$_5$.a, p$_5$.c, p$_5$.b);
    }

    static boolean a(boolean z) {
        return false;
    }

    static void b(Context context, String str) {
        A.a(context, "rzp_user_email", str, null);
    }

    static String c(Context context, String str) {
        return A.a(context, "pref_merchant_options_" + str, null);
    }

    static void d(Context context, String str) {
        A.a(context, "rzp_user_contact", str, null);
    }

    static void e(Context context) {
        if (!p$_5$.a().f() || context == null || ((Activity) context).isFinishing()) {
            return;
        }
        Dialog dialog = a;
        if (dialog == null || !dialog.isShowing()) {
            Dialog dialog2 = new Dialog(context);
            a = dialog2;
            dialog2.requestWindowFeature(1);
            a.getWindow().setBackgroundDrawable(new ColorDrawable(0));
            a.setContentView(R.layout.rzp_loader);
            ((CircularProgressView) a.findViewById(R.id.progressBar)).setColor(Color.parseColor(p$_5$.a().e()));
            ((LinearLayout) a.findViewById(R.id.ll_loader)).setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    CheckoutUtils.a();
                }
            });
            try {
                a.show();
            } catch (Exception unused) {
            }
        }
    }

    static void f(Context context) {
        d(context, null);
        b(context, null);
        f$_G$.a(context, (String) null);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setCookie("https://api.razorpay.com", "razorpay_api_session=");
        WebStorage.getInstance().deleteAllData();
        if (Build.VERSION.SDK_INT >= 21) {
            cookieManager.removeSessionCookies(new ValueCallback<Boolean>() {
                @Override
                public final void onReceiveValue(Boolean bool) {
                    if (bool.booleanValue()) {
                        CookieManager.getInstance().removeAllCookies(null);
                        CookieManager.getInstance().flush();
                    }
                }
            });
        } else {
            cookieManager.removeAllCookie();
        }
    }

    static String a(L_$k$ l_$k$) {
        String a2 = a(c_$W_.g().d(), "version", p$_5$.b);
        Map<String, String> i = p$_5$.a().i();
        for (String str : i.keySet()) {
            a2 = a(a2, str, i.get(str));
        }
        Iterator<String> it = p$_5$.a().j().iterator();
        while (it.hasNext()) {
            String next = it.next();
            if (l_$k$.a(next)) {
                a2 = a(a2, next, (String) l_$k$.c(next));
            }
        }
        return a2;
    }

    static String b(Context context) {
        return A.a(context, "rzp_user_contact", null);
    }

    static JSONArray c(Context context) {
        List<ResolveInfo> listOfAppsWhichHandleDeepLink = BaseUtils.getListOfAppsWhichHandleDeepLink(context, "upi://pay");
        if (listOfAppsWhichHandleDeepLink == null || listOfAppsWhichHandleDeepLink.size() <= 0) {
            return null;
        }
        JSONArray jSONArray = new JSONArray();
        Iterator<ResolveInfo> it = listOfAppsWhichHandleDeepLink.iterator();
        while (it.hasNext()) {
            jSONArray.put(a(context, it.next()));
        }
        return jSONArray;
    }

    static JSONArray d(Context context) {
        ArrayList arrayList = new ArrayList();
        JSONArray jSONArray = new JSONArray();
        arrayList.add("credpay://checkout");
        arrayList.add("truecallersdk://truesdk");
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            List<ResolveInfo> listOfAppsWhichHandleDeepLink = BaseUtils.getListOfAppsWhichHandleDeepLink(context, (String) it.next());
            if (listOfAppsWhichHandleDeepLink != null && listOfAppsWhichHandleDeepLink.size() > 0) {
                Iterator<ResolveInfo> it2 = listOfAppsWhichHandleDeepLink.iterator();
                while (it2.hasNext()) {
                    jSONArray.put(a(it2.next()));
                }
            }
        }
        if (jSONArray.length() == 0) {
            return null;
        }
        return jSONArray;
    }

    static boolean a(Bundle bundle) {
        if (bundle == null) {
            return false;
        }
        return new L_$k$(bundle.getString("OPTIONS")).d().has("hosted_config");
    }

    static void e(Context context, String str) {
        if (context == null || ((Activity) context).isFinishing()) {
            return;
        }
        Dialog dialog = a;
        if (dialog == null || !dialog.isShowing()) {
            Dialog dialog2 = new Dialog(context);
            a = dialog2;
            dialog2.requestWindowFeature(1);
            a.getWindow().setBackgroundDrawable(new ColorDrawable(0));
            a.setContentView(R.layout.rzp_loader);
            ((CircularProgressView) a.findViewById(R.id.progressBar)).setColor(Color.parseColor(str));
            ((LinearLayout) a.findViewById(R.id.ll_loader)).setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    CheckoutUtils.a();
                }
            });
            try {
                a.show();
            } catch (Exception unused) {
            }
        }
    }

    static void a(String str, final String str2, final Callback callback) {
        final ResponseObject responseObject = new ResponseObject();
        e.a("https://api.razorpay.com/v2/preferences?key_id=" + str, "{\"query\":[{\"resource\":\"merchant_features\"}],\"action\":\"get\"}", new Callback() {
            @Override
            public final void run(ResponseObject responseObject2) {
                if (responseObject2 != null) {
                    try {
                        if (responseObject2.getResponseCode() >= 400) {
                            CheckoutUtils.a(false);
                            return;
                        }
                        if (responseObject2.getResponseResult() != null) {
                            JSONObject jSONObject = new JSONObject(responseObject2.getResponseResult());
                            if (jSONObject.has("features")) {
                                JSONObject jSONObject2 = jSONObject.getJSONObject("features");
                                if (jSONObject2.has("data")) {
                                    JSONObject jSONObject3 = jSONObject2.getJSONObject("data");
                                    if (jSONObject3.has(str2)) {
                                        responseObject.setResponseResult(String.valueOf(jSONObject3.getBoolean(str2)));
                                        callback.run(responseObject);
                                    }
                                }
                            }
                        }
                    } catch (JSONException e) {
                        AnalyticsUtil.reportError(CheckoutUtils.class.getName(), "S0", e.getMessage());
                        responseObject.setResponseResult("false");
                        callback.run(responseObject);
                    }
                }
            }
        });
    }

    static String a(L_$k$ l_$k$, String str) {
        JSONObject d = l_$k$.d();
        if (str != null) {
            if (!str.contains(".html")) {
                str = a(str, "version", p$_5$.b);
            }
            Map<String, String> i = p$_5$.a().i();
            for (String str2 : i.keySet()) {
                str = a(str, str2, i.get(str2));
            }
            Iterator<String> it = p$_5$.a().j().iterator();
            while (it.hasNext()) {
                String next = it.next();
                if (l_$k$.a(next)) {
                    str = a(str, next, (String) l_$k$.c(next));
                }
            }
            return str;
        }
        if (l_$k$.a("hosted_config")) {
            try {
                JSONObject jSONObject = d.getJSONObject("hosted_config");
                StringBuilder sb2 = new StringBuilder();
                sb2.append(jSONObject.getString("frame"));
                boolean z = true;
                for (int i2 = 0; i2 < jSONObject.length(); i2++) {
                    String string = jSONObject.names().getString(i2);
                    if (!string.equals("frame")) {
                        if (z) {
                            sb2.append("?");
                            z = false;
                        } else {
                            sb2.append("&");
                        }
                        String encode = URLEncoder.encode(string, "UTF-8");
                        String encode2 = URLEncoder.encode(jSONObject.getString(string), "UTF-8");
                        sb2.append(encode);
                        sb2.append("=");
                        sb2.append(encode2);
                    }
                }
                return a(l_$k$, sb2.toString());
            } catch (UnsupportedEncodingException | JSONException unused) {
                return a(l_$k$);
            }
        }
        return a(l_$k$);
    }

    static boolean a(WebView webView) {
        return (webView.getTag() == null ? "" : webView.getTag().toString()).contains(c_$W_.g().a());
    }

    private static String a(String str, String str2, String str3) {
        if (str == null) {
            return null;
        }
        if (str2 == null) {
            return str;
        }
        StringBuilder sb2 = new StringBuilder();
        sb2.append(str);
        sb2.append(str.contains("?") ? "&" : "?");
        sb2.append(str2);
        String sb3 = sb2.toString();
        if (str3 == null) {
            return sb3;
        }
        return sb3 + "=" + str3;
    }

    static void a(Activity activity) {
        activity.getWindow().addFlags(2048);
        activity.getWindow().clearFlags(1024);
    }

    static boolean a(int i) {
        int h = p$_5$.a().h();
        if (p$_5$.a().g()) {
            return h == -1 || h >= i;
        }
        return false;
    }

    static String a(Activity activity, int i) {
        return BaseUtils.getBase64FromResource(activity.getResources(), i);
    }

    static void a(Context context, String str, String str2) {
        if (str2 == null) {
            A.b(context, "pref_merchant_options_" + str);
        } else {
            A.a(context, "pref_merchant_options_" + str, str2, null);
        }
    }

    static String a(Context context) {
        return A.a(context, "rzp_user_email", null);
    }

    static void a(Context context, String str, String str2, String str3, final BackButtonDialogCallback backButtonDialogCallback) {
        new AlertDialog.Builder(context).setMessage(str).setPositiveButton(str2, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                CheckoutUtils.BackButtonDialogCallback.this.onPositiveButtonClick();
            }
        }).setNegativeButton(str3, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                CheckoutUtils.BackButtonDialogCallback.this.onNegativeButtonClick();
            }
        }).show();
    }

    private static JSONObject a(ResolveInfo resolveInfo) {
        JSONObject jSONObject = new JSONObject();
        try {
            if (resolveInfo.activityInfo.packageName.contains(BaseConstants.CRED_PACKAGE)) {
                jSONObject.put("package_name", BaseConstants.CRED_PACKAGE);
                jSONObject.put("shortcode", "cred");
                jSONObject.put("uri", "credpay");
            } else if (resolveInfo.activityInfo.packageName.contains("com.truecaller")) {
                jSONObject.put("package_name", "com.truecaller");
                jSONObject.put("shortcode", (Object) null);
                jSONObject.put("uri", (Object) null);
            }
            return jSONObject;
        } catch (Exception e) {
            e.printStackTrace();
            AnalyticsUtil.reportError(e.getMessage(), "S1", e.getMessage());
            return null;
        }
    }

    private static JSONObject a(Context context, ResolveInfo resolveInfo) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("package_name", resolveInfo.activityInfo.packageName);
            jSONObject.put("app_name", BaseUtils.getAppNameOfResolveInfo(resolveInfo, context));
            jSONObject.put("app_icon", BaseUtils.getBase64FromOtherAppsResource(context, resolveInfo.activityInfo.packageName));
        } catch (Exception e) {
            AnalyticsUtil.reportError(e.getMessage(), "S2", e.getMessage());
            e.printStackTrace();
        }
        return jSONObject;
    }

    static void a() {
        Dialog dialog = a;
        if (dialog == null) {
            return;
        }
        if (dialog.isShowing()) {
            try {
                a.dismiss();
            } catch (Exception unused) {
            }
        }
        a = null;
    }

    public static void a(WebView webView, boolean z) {
        if (webView != null) {
            if (z) {
                webView.setBackgroundColor(Color.parseColor("#99000000"));
                return;
            }
            Drawable background = webView.getBackground();
            if (background instanceof ColorDrawable) {
                int color = ((ColorDrawable) background).getColor();
                if (Color.alpha(color) != 0 && color != Color.parseColor("#99000000")) {
                    webView.setBackgroundColor(Color.parseColor("#99000000"));
                    return;
                } else {
                    webView.setBackgroundColor(-1);
                    return;
                }
            }
            webView.setBackgroundColor(Color.parseColor("#99000000"));
        }
    }
}