导航菜单

页面标题

页面副标题

imToken v3.28.8 - JDPayWebView.java 源代码

正在查看: imToken v3.28.8 应用的 JDPayWebView.java JAVA 源代码文件

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


package com.pingplusplus.android.wap;

import android.app.Activity;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.webkit.WebView;
import com.pingplusplus.android.PingppLog;
import com.pingplusplus.android.PingppWebView;
import com.pingplusplus.android.WebViewEx;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Iterator;
import kotlin.Metadata;
import kotlin.TypeCastException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Charsets;
import kotlin.text.StringsKt;
import org.json.JSONObject;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0005\u0018\u0000 \u000f2\u00020\u0001:\u0002\u000f\u0010B\u0019\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\b\u0010\u0004\u001a\u0004\u0018\u00010\u0005¢\u0006\u0002\u0010\u0006J\u0010\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u0005H\u0014J\b\u0010\u000e\u001a\u00020\fH\u0014R\u0010\u0010\u0007\u001a\u0004\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\t\u001a\u0004\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\bX\u0082D¢\u0006\u0002\n\u0000¨\u0006\u0011"}, d2 = {"Lcom/pingplusplus/android/wap/JDPayWebView;", "Lcom/pingplusplus/android/PingppWebView;", "activity", "Landroid/app/Activity;", "credential", "Lorg/json/JSONObject;", "(Landroid/app/Activity;Lorg/json/JSONObject;)V", "fail_url", "", "jdpayResultUrl", "jdpayResultUrl2", "initData", "", "chargeJson", "initWebView", "Companion", "WebViewClientInner", "pingpp-android_release"}, k = 1, mv = {1, 1, 16})
public final class JDPayWebView extends PingppWebView {
    private String p;
    private final String q;
    private String r;

    public static final class a {
        private a() {
        }

        public a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }
    }

    public final class b extends WebViewEx.c {
        public b() {
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            Intrinsics.checkParameterIsNotNull(webView, "view");
            Intrinsics.checkParameterIsNotNull(str, "url");
            super.onPageFinished(webView, str);
            JDPayWebView.this.c().setVisibility(8);
        }

        @Override
        public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
            Intrinsics.checkParameterIsNotNull(webView, "view");
            Intrinsics.checkParameterIsNotNull(str, "url");
            super.onPageStarted(webView, str, bitmap);
            if (JDPayWebView.this.p != null) {
                String str2 = JDPayWebView.this.p;
                if (str2 == null) {
                    Intrinsics.throwNpe();
                }
                if (StringsKt.startsWith$default(str, str2, false, 2, (Object) null)) {
                    if (((PingppWebView) JDPayWebView.this).h) {
                        ((PingppWebView) JDPayWebView.this).b.a("success");
                    } else {
                        ((PingppWebView) JDPayWebView.this).b.e = "success";
                        ((PingppWebView) JDPayWebView.this).j = true;
                    }
                }
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            String str2;
            Intrinsics.checkParameterIsNotNull(webView, "view");
            Intrinsics.checkParameterIsNotNull(str, "url");
            String str3 = JDPayWebView.this.p;
            if (str3 == null) {
                Intrinsics.throwNpe();
            }
            if (StringsKt.startsWith$default(str, str3, false, 2, (Object) null)) {
                ((PingppWebView) JDPayWebView.this).b.a("success");
                WebViewEx webViewEx = ((PingppWebView) JDPayWebView.this).a;
                if (webViewEx == null) {
                    Intrinsics.throwNpe();
                }
                webViewEx.destroy();
                ((PingppWebView) JDPayWebView.this).a = null;
                str2 = "jdPay success";
            } else {
                if (!str.equals(JDPayWebView.this.r)) {
                    if ("https://www.jdpay.com/".equals(str)) {
                        JDPayWebView.this.a(str);
                    } else if (StringsKt.startsWith$default(str, JDPayWebView.this.q, false, 2, (Object) null)) {
                        ((PingppWebView) JDPayWebView.this).k = false;
                    }
                    return super.shouldOverrideUrlLoading(webView, str);
                }
                ((PingppWebView) JDPayWebView.this).b.a("fail");
                WebViewEx webViewEx2 = ((PingppWebView) JDPayWebView.this).a;
                if (webViewEx2 == null) {
                    Intrinsics.throwNpe();
                }
                webViewEx2.destroy();
                ((PingppWebView) JDPayWebView.this).a = null;
                str2 = "jdPay fail";
            }
            PingppLog.d(str2);
            return true;
        }
    }

    static {
        new a(null);
    }

    public JDPayWebView(Activity activity, JSONObject jSONObject) {
        super(activity, jSONObject);
        if (activity == null) {
            Intrinsics.throwNpe();
        }
        if (jSONObject == null) {
            Intrinsics.throwNpe();
        }
        this.q = "https://h5pay.jd.com/jdpay/payResult?";
    }

    @Override
    protected void a(JSONObject jSONObject) {
        Intrinsics.checkParameterIsNotNull(jSONObject, "chargeJson");
        JSONObject optJSONObject = jSONObject.optJSONObject("extra");
        this.p = optJSONObject.optString("success_url");
        this.r = optJSONObject.optString("fail_url");
        JSONObject jSONObject2 = jSONObject.getJSONObject("credential");
        JSONObject jSONObject3 = jSONObject2.getJSONObject("jdpay_wap");
        PingppLog.d("PaymentActivity start jdpay_wap credential : " + jSONObject2);
        ArrayList arrayList = new ArrayList();
        Iterator<String> keys = jSONObject3.keys();
        String str = "https://m.jdpay.com/wepay/web/pay";
        while (keys.hasNext()) {
            String next = keys.next();
            if (Intrinsics.areEqual("channelUrl", next)) {
                str = jSONObject3.getString(next);
            } else {
                ArrayList arrayList2 = new ArrayList();
                arrayList2.add(next);
                try {
                    arrayList2.add(URLEncoder.encode(jSONObject3.getString(next), "UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                arrayList.add(TextUtils.join("=", arrayList2));
            }
        }
        if (arrayList.size() == 0) {
            this.b.a("fail", "invalid_credential");
            return;
        }
        String join = TextUtils.join("&", arrayList);
        Intrinsics.checkExpressionValueIsNotNull(join, "orderInfo");
        Charset charset = Charsets.UTF_8;
        if (join == null) {
            throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
        }
        byte[] bytes = join.getBytes(charset);
        Intrinsics.checkExpressionValueIsNotNull(bytes, "(this as java.lang.String).getBytes(charset)");
        a(str, bytes);
    }

    @Override
    protected void f() {
        WebViewEx webViewEx = this.a;
        if (webViewEx == null) {
            Intrinsics.throwNpe();
        }
        webViewEx.setWebViewClient(new b());
    }
}