导航菜单

页面标题

页面副标题

CityMall v1.42.1 - TrackerFallback.java 源代码

正在查看: CityMall v1.42.1 应用的 TrackerFallback.java JAVA 源代码文件

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


package in.juspay.hypersdk.utils;

import androidx.annotation.Nullable;
import com.simpl.android.fingerprint.BuildConfig;
import in.juspay.hyper.constants.LogCategory;
import in.juspay.hyper.core.ExecutorManager;
import in.juspay.hypersdk.core.JuspayServices;
import in.juspay.hypersdk.core.PaymentConstants;
import in.juspay.hypersdk.utils.TrackerFallback;
import in.juspay.hypersdk.utils.network.NetUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.json.JSONObject;

public class TrackerFallback {
    private int count;
    private boolean enableTrackerFallback;

    @Nullable
    private NetUtils netUtils;

    @Nullable
    private List<String> requiredKeysList;

    public TrackerFallback(JSONObject jSONObject) {
        this.count = 3;
        if (jSONObject == null || !jSONObject.has("enableTrackerFallback")) {
            return;
        }
        try {
            this.netUtils = new NetUtils(0, 0);
            this.enableTrackerFallback = jSONObject.optBoolean("enableTrackerFallback", true);
            this.count = jSONObject.optInt("trackerFallbackAttempts", 3);
            this.requiredKeysList = Arrays.asList(LogCategory.ACTION, PaymentConstants.ORDER_ID_CAMEL, PaymentConstants.CLIENT_ID_CAMEL, PaymentConstants.MERCHANT_ID_CAMEL, "customerId", "os", "os_version", "app_version", "requestId");
        } catch (Exception unused) {
        }
    }

    private HashMap<String, String> getQueryParams(JuspayServices juspayServices, JSONObject jSONObject, LogType logType) {
        String optString;
        String optString2;
        ArrayList arrayList = new ArrayList();
        LogType logType2 = LogType.PROCESS_END;
        if (logType == logType2) {
            arrayList.add("errorMessage");
            arrayList.add("errorCode");
        }
        if (logType == LogType.INITIATE_RESULT || logType == logType2) {
            arrayList.add(PaymentConstants.CLIENT_ID);
            arrayList.add(PaymentConstants.MERCHANT_ID);
        }
        JSONObject optJSONObject = jSONObject.optJSONObject(PaymentConstants.PAYLOAD);
        JSONObject sessionData = juspayServices.getSessionInfo().getSessionData();
        HashMap<String, String> hashMap = new HashMap<>();
        List<String> list = this.requiredKeysList;
        if (list != null) {
            for (String str : list) {
                if (optJSONObject != null && optJSONObject.has(str)) {
                    optString2 = optJSONObject.optString(str, BuildConfig.FLAVOR);
                } else if (sessionData.has(str)) {
                    optString2 = sessionData.optString(str, BuildConfig.FLAVOR);
                } else if (jSONObject.has(str)) {
                    optString2 = jSONObject.optString(str, BuildConfig.FLAVOR);
                }
                hashMap.put(str, optString2);
            }
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            String str2 = (String) it.next();
            if (optJSONObject != null && optJSONObject.has(str2)) {
                optString = optJSONObject.optString(str2, BuildConfig.FLAVOR);
            } else if (jSONObject.has(str2)) {
                optString = jSONObject.optString(str2, BuildConfig.FLAVOR);
            }
            hashMap.put(str2, optString);
        }
        hashMap.put("sessionId", juspayServices.getSessionInfo().getSessionId());
        hashMap.put("logtype", logType.name());
        return hashMap;
    }

    public void lambda$log$0(JuspayServices juspayServices, JSONObject jSONObject, LogType logType) {
        try {
            if (!this.enableTrackerFallback || this.netUtils == null) {
                return;
            }
            for (int i = 0; i < this.count; i++) {
                if (this.netUtils.doGet("https://assets.juspay.in/a.html", new HashMap(), getQueryParams(juspayServices, jSONObject, logType), new JSONObject()).getResponseCode() == 200) {
                    return;
                }
            }
        } catch (Exception unused) {
        }
    }

    public void log(final JSONObject jSONObject, final JuspayServices juspayServices, final LogType logType) {
        ExecutorManager.runOnBackgroundThread(new Runnable() {
            @Override
            public final void run() {
                TrackerFallback.this.lambda$log$0(juspayServices, jSONObject, logType);
            }
        });
    }
}