导航菜单

页面标题

页面副标题

Chaupal v3.2 - RzpAssist.java 源代码

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

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


package com.razorpay;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.pm.PackageManager;
import android.os.Build;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.razorpay.AnalyticsProperty;
import java.util.HashMap;
import org.json.JSONObject;

public final class RzpAssist implements SmsAgentInterface {
    private Activity activity;
    private OtpElfData elfData;
    String lastSms;
    private String merchantKey;
    String message;
    private long pageStartTime;
    private String paymentId;
    private String sdkType;
    private String sdkVersion;
    private int sdkVersionCode;
    String sender;
    private B smsAgent;
    private WebView webview;
    private boolean hasOtpPermission = false;
    private String lastURL = "";
    private String currentLoadingUrl = "";
    private boolean isMagic = false;
    private boolean isRazorpayOtpReceived = false;
    private JSONObject otpElfPreferences = new JSONObject();
    private JSONObject paymentData = new JSONObject();
    private boolean isRzpAssistEnabled = false;
    private boolean otpRead = false;
    private boolean jsInsertedInCurrentPage = false;

    public RzpAssist(String str, Activity activity, WebView webView, String str2, int i, String str3) {
        this.sdkType = "standalone";
        if (e_$r$.a().isOTPElfEnabled().booleanValue()) {
            if (str == null || str.isEmpty()) {
                throw new RuntimeException("merchantKey cannot be null or empty");
            }
            this.sdkType = str2;
            this.sdkVersionCode = i;
            this.sdkVersion = str3;
            if (str2.equals("standalone") || str2.equalsIgnoreCase(BuildConfig.SDK_TYPE) || str2.equalsIgnoreCase("custom")) {
                AnalyticsUtil.setup(activity, str, str2, i, str3);
            }
            this.webview = webView;
            this.merchantKey = str;
            this.activity = activity;
            OtpElfData otpElfData = new OtpElfData(activity);
            this.elfData = otpElfData;
            otpElfData.checkForUpdates();
            setup();
            AnalyticsUtil.addProperty("OTPElf Version", new AnalyticsProperty(BaseUtils.getLocalVersion(activity, OtpElfData.versionKey), AnalyticsProperty.Scope.ORDER));
        }
    }

    private void handleJsInsertion() {
        try {
            JSONObject oTPElfSettings = e_$r$.a().getOTPElfSettings();
            oTPElfSettings.put("merchant_key", this.merchantKey);
            oTPElfSettings.put("otp_permission", this.hasOtpPermission);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("type", this.sdkType);
            jSONObject.put("version", this.sdkVersion);
            jSONObject.put("platform", "android");
            jSONObject.put("framework", "native");
            jSONObject.put(AppMeasurementSdk.ConditionalUserProperty.NAME, this.sdkType + "_android_native");
            oTPElfSettings.put("sdk", jSONObject);
            JSONObject jSONObject2 = new JSONObject();
            if (this.isMagic) {
                jSONObject2.put("type", "magic");
                jSONObject2.put("version_code", Z$_A_.d.intValue());
            } else {
                jSONObject2.put("type", "rzpassist");
                jSONObject2.put("version_code", Z$_A_.c.intValue());
            }
            oTPElfSettings.put("plugin", jSONObject2);
            oTPElfSettings.put("payment_data", this.paymentData);
            oTPElfSettings.put("preferences", this.otpElfPreferences);
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("package_name", this.activity.getApplicationContext().getPackageName());
            PackageManager packageManager = this.activity.getPackageManager();
            jSONObject3.put("app_name", AnalyticsUtil.returnUndefinedIfNull(packageManager.getPackageInfo(this.activity.getPackageName(), 0).applicationInfo.loadLabel(packageManager)));
            jSONObject3.put("platform", "mobile_sdk");
            jSONObject3.put("os", "android");
            jSONObject3.put("os_version", Build.VERSION.RELEASE);
            jSONObject3.put("data_network_type", BaseUtils.getDataNetworkType(this.activity).getNetworkTypeName());
            jSONObject3.put("framework", AnalyticsUtil.getFramework());
            jSONObject3.put("library", BuildConfig.SDK_TYPE);
            jSONObject3.put("sdk", jSONObject);
            oTPElfSettings.put("metadata", jSONObject3);
            injectJs("window.__rzp_options = " + oTPElfSettings.toString());
        } catch (Exception unused) {
        }
        injectJs(this.elfData.getOtpElfJs());
        AnalyticsUtil.trackEvent(AnalyticsEvent.OTPELF_INJECTED);
        String str = this.lastSms;
        if (str != null) {
            injectJs(String.format("OTPElf.showOTP('%s','%s')", str, this.sender));
            this.lastSms = null;
        }
    }

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

    private void postStatsToAPI() {
        try {
            String constructBasicAuth = BaseUtils.constructBasicAuth(this.merchantKey);
            HashMap hashMap = new HashMap();
            hashMap.put("Authorization", "Basic " + constructBasicAuth);
            hashMap.put("Content-Type", "application/json");
            if (this.paymentId == null) {
                return;
            }
            e.a("https://api.razorpay.com/v1/payments/" + this.paymentId + "/metadata", D$_X_.a(this.otpRead).toString(), hashMap, new C0215r(this));
        } catch (Exception e) {
            AnalyticsUtil.reportError("RzpAssist", "S0", e.getMessage());
        }
    }

    private void setup() {
        this.smsAgent = B.a();
        this.webview.addJavascriptInterface(this, "OTPElfBridge");
        this.webview.getSettings().setUseWideViewPort(true);
    }

    @JavascriptInterface
    public final void copyToClipboard(String str) {
        ((ClipboardManager) this.activity.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("rzp_clip_data", str));
    }

    final void enableMagic() {
        this.isMagic = true;
    }

    final String getCurrentLoadingUrl() {
        return this.currentLoadingUrl;
    }

    final String getLastLoadedUrl() {
        return this.lastURL;
    }

    final boolean isRazorpayOtpReceived() {
        return this.isRazorpayOtpReceived;
    }

    @JavascriptInterface
    public final void onOtpParsed(String str) {
        this.activity.runOnUiThread(new v(this, str));
    }

    public final void onPageFinished(WebView webView, String str) {
        AnalyticsUtil.trackPageLoadEnd(str, System.nanoTime() - this.pageStartTime);
        this.lastURL = str;
        this.currentLoadingUrl = "";
        if (e_$r$.a().isOTPElfEnabled().booleanValue() && !this.jsInsertedInCurrentPage) {
            handleJsInsertion();
            this.jsInsertedInCurrentPage = true;
        }
    }

    public final void onPageStarted(WebView webView, String str) {
        AnalyticsUtil.trackPageLoadStart(str);
        this.pageStartTime = System.nanoTime();
        this.currentLoadingUrl = str;
        this.jsInsertedInCurrentPage = false;
    }

    public final void onProgressChanged(int i) {
        e_$r$.a().isOTPElfEnabled().booleanValue();
    }

    final void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        B b = this.smsAgent;
        if (i != 1) {
            return;
        }
        if (iArr.length <= 0 || iArr[0] != 0) {
            AnalyticsUtil.trackEvent(AnalyticsEvent.SMS_PERMISSION_NOW_DENIED);
        } else {
            b.b();
            AnalyticsUtil.trackEvent(AnalyticsEvent.SMS_PERMISSION_NOW_GRANTED);
        }
    }

    @JavascriptInterface
    public final void openKeyboard() {
        this.activity.runOnUiThread(new t(this));
    }

    public final void paymentFlowEnd() {
        if (this.sdkType.equals("standalone")) {
            AnalyticsUtil.postData();
        }
        if (e_$r$.a().isOTPElfEnabled().booleanValue()) {
            this.smsAgent.a(this.activity);
        }
    }

    @Override
    public final void postSms(String str, String str2) {
        if (this.isRzpAssistEnabled) {
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("sender", str);
                jSONObject.put("message", str2);
                this.sender = str;
                this.message = str2;
                this.lastSms = jSONObject.toString();
                injectJs(String.format("OTPElf.showOTP('%s','%s')", str2, str));
            } catch (Exception unused) {
            }
        }
    }

    public final void reset() {
        postStatsToAPI();
        this.lastURL = "";
        this.currentLoadingUrl = "";
        this.otpRead = false;
    }

    final void setOTPEnabled(boolean z) {
        this.hasOtpPermission = z;
        AnalyticsUtil.addProperty("otp_autoreading_access", new AnalyticsProperty(z, AnalyticsProperty.Scope.ORDER));
    }

    public final void setOtpElfPreferences(JSONObject jSONObject) {
        this.otpElfPreferences = jSONObject;
    }

    final void setPaymentData(JSONObject jSONObject) {
        this.paymentData = jSONObject;
    }

    final void setPaymentId(String str) {
        this.paymentId = str;
    }

    final void setRzpAssistEnabled(boolean z) {
        this.isRzpAssistEnabled = z;
    }

    @Override
    public final void setSmsPermission(boolean z) {
        setOTPEnabled(z);
    }

    @JavascriptInterface
    public final void setUseWideViewPort(boolean z) {
        this.activity.runOnUiThread(new s(this, z));
    }

    @JavascriptInterface
    public final void toast(String str) {
        this.activity.runOnUiThread(new u(this, str));
    }

    @JavascriptInterface
    public final void trackEvent(String str, String str2) {
        try {
            AnalyticsEvent analyticsEvent = AnalyticsEvent.JS_EVENT;
            analyticsEvent.setEventName(str);
            AnalyticsUtil.trackEvent(analyticsEvent, new JSONObject(str2));
        } catch (Exception unused) {
        }
    }

    @JavascriptInterface
    public final void trackEvent(String str) {
        AnalyticsEvent analyticsEvent = AnalyticsEvent.JS_EVENT;
        analyticsEvent.setEventName(str);
        AnalyticsUtil.trackEvent(analyticsEvent);
    }
}