导航菜单

页面标题

页面副标题

Clash Legends v0.0.1 - CheckoutUtils.java 源代码

正在查看: Clash Legends v0.0.1 应用的 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.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.widget.LinearLayout;
import com.payu.otpassist.utils.Constants;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

final class CheckoutUtils {
    private static Dialog dialog;

    interface BackButtonDialogCallback {
        void onNegativeButtonClick();

        void onPositiveButtonClick();
    }

    CheckoutUtils() {
    }

    static void addAddons(Context context, String merchantKey) {
        AnalyticsUtil.setup(context, merchantKey, Config.SDK_TYPE, Config.SDK_VERSION_CODE, Config.SDK_VERSION);
    }

    static String getCheckoutUrlWithOptions(CheckoutOptions checkoutOptions) {
        String url = addParamToUrl("https://api.razorpay.com/v1/checkout/public", "version", Config.SDK_VERSION);
        Map<String, String> urlConfigMap = Config.getInstance().getCheckoutUrlConfig();
        Set<String> urlConfigKeys = urlConfigMap.keySet();
        for (String key : urlConfigKeys) {
            url = addParamToUrl(url, key, urlConfigMap.get(key));
        }
        ArrayList<String> keys = Config.getInstance().getCheckoutAppendKeys();
        Iterator<String> it = keys.iterator();
        while (it.hasNext()) {
            String key2 = it.next();
            if (checkoutOptions.has(key2)) {
                url = addParamToUrl(url, key2, (String) checkoutOptions.get(key2));
            }
        }
        Logger.d("Modified Url: " + url);
        return url;
    }

    static boolean isCheckoutUrl(WebView webView) {
        String tag = webView.getTag() == null ? "" : webView.getTag().toString();
        if (tag.contains(Config.getInstance().getCheckoutEndpoint())) {
            return true;
        }
        return false;
    }

    static String addParamToUrl(String url, String key, String value) {
        if (url == null) {
            return null;
        }
        if (key == null) {
            return url;
        }
        String url2 = url + (url.contains("?") ? "&" : "?") + key;
        if (value == null) {
            return url2;
        }
        return url2 + "=" + value;
    }

    static void disableFullScreenMode(Activity activity) {
        activity.getWindow().addFlags(2048);
        activity.getWindow().clearFlags(LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY);
    }

    static boolean shouldRetryPayment(int paymentAttempts) {
        int retryMaxCount = Config.getInstance().getRetryMaxCount();
        if (!Config.getInstance().isRetryEnabled()) {
            return false;
        }
        if (retryMaxCount == -1 || retryMaxCount > paymentAttempts) {
            return true;
        }
        return false;
    }

    static String getBase64FromCurrentAppsResource(Activity a, int resourceId) {
        Resources resources = a.getResources();
        return BaseUtils.getBase64FromResource(resources, resourceId);
    }

    static void setUserEmail(Context context, String email) {
        SharedPreferences.Editor editor = SharedPreferenceUtil.getPrivateEditor(context);
        editor.putString("rzp_user_email", email);
        editor.commit();
    }

    static void setMerchantOptions(Context context, String merchantKey, String merchantOptions) {
        SharedPreferences.Editor editor = SharedPreferenceUtil.getPrivateEditor(context);
        if (merchantOptions == null) {
            editor.remove("pref_merchant_options_" + merchantKey);
        } else {
            editor.putString("pref_merchant_options_" + merchantKey, merchantOptions);
        }
        editor.apply();
    }

    static String getMerchantOptions(Context context, String merchantKey) {
        SharedPreferences prefs = SharedPreferenceUtil.getPrivatePrefs(context);
        return prefs.getString("pref_merchant_options_" + merchantKey, null);
    }

    static void setUserContact(Context context, String contact) {
        SharedPreferences.Editor editor = SharedPreferenceUtil.getPrivateEditor(context);
        editor.putString("rzp_user_contact", contact);
        editor.commit();
    }

    static String getUserEmail(Context context) {
        SharedPreferences sharedPref = SharedPreferenceUtil.getPrivatePrefs(context);
        return sharedPref.getString("rzp_user_email", null);
    }

    static String getUserContact(Context context) {
        SharedPreferences sharedPref = SharedPreferenceUtil.getPrivatePrefs(context);
        return sharedPref.getString("rzp_user_contact", null);
    }

    static void showDialog(Context context, String message, String positiveButtonText, String negativeButtonText, final BackButtonDialogCallback backButtonDialogCallback) {
        new AlertDialog.Builder(context).setMessage(message).setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                BackButtonDialogCallback.this.onPositiveButtonClick();
            }
        }).setNegativeButton(negativeButtonText, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                BackButtonDialogCallback.this.onNegativeButtonClick();
            }
        }).show();
    }

    static JSONObject isPackageInstalled(Context context, String packageName) {
        try {
            PackageManager packageManager = context.getPackageManager();
            ResolveInfo resolveInfo = new ResolveInfo();
            resolveInfo.resolvePackageName = packageManager.getPackageInfo(packageName, 0).packageName;
            return getAppExistenceDataInJson(context, resolveInfo);
        } catch (PackageManager.NameNotFoundException e) {
            return null;
        }
    }

    static JSONObject getAppExistenceDataInJson(Context context, ResolveInfo resolveInfo) {
        JSONObject jsonObject = new JSONObject();
        try {
            if (resolveInfo.resolvePackageName.equalsIgnoreCase(BaseConstants.CRED_PACKAGE)) {
                jsonObject.put("shortcode", "cred");
                jsonObject.put("uri", "credpay");
                jsonObject.put(Constants.PACKAGE_NAME, resolveInfo.resolvePackageName);
            } else if (resolveInfo.resolvePackageName.equalsIgnoreCase(BaseConstants.BHIM_PACKAGE_NAME)) {
                jsonObject.put("shortcode", "bhim");
                jsonObject.put("uri", "upi://pay");
                jsonObject.put(Constants.PACKAGE_NAME, resolveInfo.resolvePackageName);
            }
            return jsonObject;
        } catch (JSONException e) {
            AnalyticsUtil.reportError(e, "warning", e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    static JSONArray getUpiIntentsDataInJsonArray(Context context) {
        List<ResolveInfo> resolveInfoList = BaseUtils.getListOfAppsWhichHandleDeepLink(context, "upi://pay");
        if (resolveInfoList != null && resolveInfoList.size() > 0) {
            JSONArray jsonArray = new JSONArray();
            for (ResolveInfo resolveInfo : resolveInfoList) {
                jsonArray.put(getIntentDataInJson(context, resolveInfo));
            }
            return jsonArray;
        }
        return null;
    }

    static JSONArray getAppIntentDataInJsonArray(Context context) {
        List<ResolveInfo> resolveInfoList = BaseUtils.getListOfAppsWhichHandleDeepLink(context, "credpay://checkout");
        if (resolveInfoList != null && resolveInfoList.size() > 0) {
            JSONArray jsonArray = new JSONArray();
            for (ResolveInfo resolveInfo : resolveInfoList) {
                jsonArray.put(getAppIntentDataInJson(context, resolveInfo));
            }
            return jsonArray;
        }
        return null;
    }

    static JSONObject getAppIntentDataInJson(Context context, ResolveInfo resolveInfo) {
        JSONObject jsonObject = new JSONObject();
        try {
            if (resolveInfo.activityInfo.packageName.contains(BaseConstants.CRED_PACKAGE)) {
                jsonObject.put(Constants.PACKAGE_NAME, BaseConstants.CRED_PACKAGE);
                jsonObject.put("shortcode", "cred");
                jsonObject.put("uri", "credpay");
                return jsonObject;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            AnalyticsUtil.reportError(e, "error", e.getMessage());
            return null;
        }
    }

    static JSONObject getIntentDataInJson(Context context, ResolveInfo resolveInfo) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put(Constants.PACKAGE_NAME, resolveInfo.activityInfo.packageName);
            String appName = BaseUtils.getAppNameOfResolveInfo(resolveInfo, context);
            jsonObject.put("app_name", appName);
            jsonObject.put("app_icon", BaseUtils.getBase64FromOtherAppsResource(context, resolveInfo.activityInfo.packageName));
        } catch (Exception e) {
            AnalyticsUtil.reportError(e, "warning", e.getMessage());
            e.printStackTrace();
        }
        return jsonObject;
    }

    static void showLoader(Context context) {
        if (!Config.getInstance().isNativeLoaderEnabled() || context == null || ((Activity) context).isFinishing()) {
            return;
        }
        Dialog dialog2 = dialog;
        if (dialog2 != null && dialog2.isShowing()) {
            return;
        }
        Dialog dialog3 = new Dialog(context);
        dialog = dialog3;
        dialog3.requestWindowFeature(1);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        dialog.setContentView(R.layout.rzp_loader);
        CircularProgressView circularProgressView = (CircularProgressView) dialog.findViewById(R.id.progressBar);
        circularProgressView.setColor(Color.parseColor(Config.getInstance().getNativeLoaderColor()));
        LinearLayout loaderLL = (LinearLayout) dialog.findViewById(R.id.ll_loader);
        loaderLL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CheckoutUtils.dismissLoader();
            }
        });
        try {
            dialog.show();
        } catch (Exception e) {
            Logger.e("Error showing loader", e);
        }
    }

    static void dismissLoader() {
        Dialog dialog2 = dialog;
        if (dialog2 == null) {
            return;
        }
        if (dialog2.isShowing()) {
            try {
                dialog.dismiss();
            } catch (Exception e) {
                Logger.e("Error dismissing loader", e);
            }
        }
        dialog = null;
    }

    static void clearUserData(Context context) {
        setUserContact(context, null);
        setUserEmail(context, null);
        CardSaving.setDeviceToken(context, null);
        clearUserRelatedCookies();
    }

    static void clearUserRelatedCookies() {
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setCookie("https://api.razorpay.com", "razorpay_api_session=");
    }
}