米游社.apk(点击下载) / PayTask.java


package com.alipay.sdk.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import com.alipay.sdk.app.PayResultActivity;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import h4.e;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import k4.a;
import n6.b;
import org.json.JSONObject;
import p4.f;
import r4.a;
import t4.d;
import t4.g;
import t4.h;
import t4.k;
import t4.m;

public class PayTask {

    /* renamed from: h  reason: collision with root package name */
    public static final Object f27257h = g.class;

    /* renamed from: i  reason: collision with root package name */
    public static long f27258i = 0;

    /* renamed from: j  reason: collision with root package name */
    public static final long f27259j = 3000;

    /* renamed from: k  reason: collision with root package name */
    public static long f27260k = -1;

    /* renamed from: a  reason: collision with root package name */
    public Activity f27261a;

    /* renamed from: b  reason: collision with root package name */
    public v4.a f27262b;

    /* renamed from: c  reason: collision with root package name */
    public final String f27263c = "wappaygw.alipay.com/service/rest.htm";

    /* renamed from: d  reason: collision with root package name */
    public final String f27264d = "mclient.alipay.com/service/rest.htm";

    /* renamed from: e  reason: collision with root package name */
    public final String f27265e = "mclient.alipay.com/home/exterfaceAssign.htm";

    /* renamed from: f  reason: collision with root package name */
    public final String f27266f = "mclient.alipay.com/cashier/mobilepay.htm";

    /* renamed from: g  reason: collision with root package name */
    public Map<String, c> f27267g = new HashMap();

    public class a implements Runnable {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ String f27268a;

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ boolean f27269b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ H5PayCallback f27270c;

        public a(String str, boolean z10, H5PayCallback h5PayCallback) {
            this.f27268a = str;
            this.f27269b = z10;
            this.f27270c = h5PayCallback;
        }

        public void run() {
            t4.a h5Pay = PayTask.this.h5Pay(new r4.a(PayTask.this.f27261a, this.f27268a, "payInterceptorWithUrl"), this.f27268a, this.f27269b);
            d.i(j4.a.f73114x, "inc finished: " + h5Pay.a());
            this.f27270c.onPayResult(h5Pay);
        }
    }

    public class b implements g.e {
        public b() {
        }

        @Override // t4.g.e
        public void a() {
            PayTask.this.dismissLoading();
        }

        @Override // t4.g.e
        public void b() {
        }
    }

    public PayTask(Activity activity) {
        this.f27261a = activity;
        r4.b.e().b(this.f27261a);
        this.f27262b = new v4.a(activity, v4.a.f143539j);
    }

    public static boolean b() {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        if (elapsedRealtime - f27260k < 3000) {
            return true;
        }
        f27260k = elapsedRealtime;
        return false;
    }

    public static synchronized boolean fetchSdkConfig(Context context) {
        synchronized (PayTask.class) {
            try {
                r4.b.e().b(context);
                long elapsedRealtime = SystemClock.elapsedRealtime() / 1000;
                if (elapsedRealtime - f27258i < ((long) k4.a.H().m())) {
                    return false;
                }
                f27258i = elapsedRealtime;
                k4.a.H().g(r4.a.o(), context.getApplicationContext(), false);
                return true;
            } catch (Exception e10) {
                d.d(e10);
                return false;
            }
        }
    }

    public final String c(String str, Map<String, String> map) throws UnsupportedEncodingException {
        String str2;
        String str3;
        boolean equals = "9000".equals(map.get(k.f134447a));
        String str4 = map.get("result");
        c remove = this.f27267g.remove(str);
        String[] strArr = new String[2];
        if (remove != null) {
            str2 = remove.a();
        } else {
            str2 = "";
        }
        strArr[0] = str2;
        if (remove != null) {
            str3 = remove.g();
        } else {
            str3 = "";
        }
        strArr[1] = str3;
        a(strArr);
        if (map.containsKey("callBackUrl")) {
            return map.get("callBackUrl");
        }
        if (str4.length() > 15) {
            String a10 = a(m.g("&callBackUrl=\"", "\"", str4), m.g("&call_back_url=\"", "\"", str4), m.g(j4.a.f73108r, "\"", str4), URLDecoder.decode(m.g(j4.a.f73109s, "&", str4), "utf-8"), URLDecoder.decode(m.g("&callBackUrl=", "&", str4), "utf-8"), m.g("call_back_url=\"", "\"", str4));
            if (!TextUtils.isEmpty(a10)) {
                return a10;
            }
        }
        if (remove != null) {
            String c10 = equals ? remove.c() : remove.e();
            if (!TextUtils.isEmpty(c10)) {
                return c10;
            }
        }
        if (remove != null) {
            return k4.a.H().B();
        }
        return "";
    }

    public final String d(String str, r4.a aVar) {
        String b10 = aVar.b(str);
        if (b10.contains("paymethod=\"expressGateway\"")) {
            return e(aVar, b10);
        }
        List<a.b> w10 = k4.a.H().w();
        if (!k4.a.H().f79172g || w10 == null) {
            w10 = h4.c.f69610d;
        }
        if (m.E(aVar, this.f27261a, w10)) {
            g gVar = new g(this.f27261a, aVar, i());
            d.i(j4.a.f73114x, "pay inner started: " + b10);
            String c10 = gVar.c(b10);
            d.i(j4.a.f73114x, "pay inner raw result: " + c10);
            gVar.i();
            if (TextUtils.equals(c10, g.f134419j) || TextUtils.equals(c10, g.f134420k)) {
                i4.a.c(aVar, i4.b.f70893l, i4.b.f70896m0);
                return e(aVar, b10);
            } else if (TextUtils.isEmpty(c10)) {
                return h4.d.a();
            } else {
                if (!c10.contains(PayResultActivity.f27245b)) {
                    return c10;
                }
                i4.a.c(aVar, i4.b.f70893l, i4.b.f70900o0);
                return a(aVar, b10, w10, c10, this.f27261a);
            }
        } else {
            i4.a.c(aVar, i4.b.f70893l, i4.b.f70898n0);
            return e(aVar, b10);
        }
    }

    public void dismissLoading() {
        v4.a aVar = this.f27262b;
        if (aVar != null) {
            aVar.c();
            this.f27262b = null;
        }
    }

    /* JADX INFO: finally extract failed */
    public final String e(r4.a aVar, String str) {
        showLoading();
        e eVar = null;
        try {
            JSONObject c10 = new f().f(aVar, this.f27261a.getApplicationContext(), str).c();
            String optString = c10.optString("end_code", null);
            List<q4.b> a10 = q4.b.a(c10.optJSONObject(j4.c.f73130c).optJSONObject(j4.c.f73131d));
            for (int i10 = 0; i10 < a10.size(); i10++) {
                if (a10.get(i10).b() == q4.a.Update) {
                    q4.b.c(a10.get(i10));
                }
            }
            j(aVar, c10);
            dismissLoading();
            i4.a.b(this.f27261a, aVar, str, aVar.f109828d);
            for (int i11 = 0; i11 < a10.size(); i11++) {
                q4.b bVar = a10.get(i11);
                if (bVar.b() == q4.a.WapPay) {
                    String g10 = g(aVar, bVar);
                    dismissLoading();
                    i4.a.b(this.f27261a, aVar, str, aVar.f109828d);
                    return g10;
                } else if (bVar.b() == q4.a.OpenWeb) {
                    String h10 = h(aVar, bVar, optString);
                    dismissLoading();
                    i4.a.b(this.f27261a, aVar, str, aVar.f109828d);
                    return h10;
                }
            }
            dismissLoading();
            i4.a.b(this.f27261a, aVar, str, aVar.f109828d);
        } catch (IOException e10) {
            e b10 = e.b(e.NETWORK_ERROR.b());
            i4.a.g(aVar, i4.b.f70891k, e10);
            dismissLoading();
            i4.a.b(this.f27261a, aVar, str, aVar.f109828d);
            eVar = b10;
        } catch (Throwable th2) {
            dismissLoading();
            i4.a.b(this.f27261a, aVar, str, aVar.f109828d);
            throw th2;
        }
        if (eVar == null) {
            eVar = e.b(e.FAILED.b());
        }
        return h4.d.b(eVar.b(), eVar.a(), "");
    }

    /* JADX WARNING: Code restructure failed: missing block: B:31:0x011b, code lost:
        if (k4.a.H().C() == false) goto L_0x0173;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x0171, code lost:
        if (k4.a.H().C() != false) goto L_0x0180;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:0x0173, code lost:
        k4.a.H().g(r6, r5.f27261a.getApplicationContext(), false);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x0180, code lost:
        dismissLoading();
        i4.a.h(r5.f27261a.getApplicationContext(), r6, r7, r6.f109828d);
        t4.d.i(j4.a.f73114x, "pay returning: " + r8);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:0x01a5, code lost:
        return r8;
     */
    public final synchronized String f(r4.a aVar, String str, boolean z10) {
        if (b()) {
            i4.a.i(aVar, i4.b.f70893l, "RepPay", "");
            return h4.d.e();
        }
        if (z10) {
            showLoading();
        }
        if (str.contains("payment_inst=")) {
            String substring = str.substring(str.indexOf("payment_inst=") + 13);
            int indexOf = substring.indexOf(38);
            if (indexOf > 0) {
                substring = substring.substring(0, indexOf);
            }
            h4.c.b(substring.replaceAll("\"", "").toLowerCase(Locale.getDefault()).replaceAll("alipay", ""));
        } else {
            h4.c.b("");
        }
        if (str.contains(j4.a.f73110t)) {
            j4.a.f73111u = true;
        }
        if (j4.a.f73111u) {
            if (str.startsWith(j4.a.f73112v)) {
                str = str.substring(str.indexOf(j4.a.f73112v) + 53);
            } else if (str.startsWith(j4.a.f73113w)) {
                str = str.substring(str.indexOf(j4.a.f73113w) + 52);
            }
        }
        String str2 = "";
        try {
            d.i(j4.a.f73114x, "pay prepared: " + str);
            str2 = d(str, aVar);
            d.i(j4.a.f73114x, "pay raw result: " + str2);
            h.c(aVar, this.f27261a.getApplicationContext(), str2);
            i4.a.d(aVar, i4.b.f70893l, i4.b.Z, "" + SystemClock.elapsedRealtime());
            i4.a.d(aVar, i4.b.f70893l, i4.b.f70881a0, k.a(str2, k.f134447a) + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + k.a(str2, k.f134448b));
        } catch (Throwable th2) {
            i4.a.d(aVar, i4.b.f70893l, i4.b.Z, "" + SystemClock.elapsedRealtime());
            i4.a.d(aVar, i4.b.f70893l, i4.b.f70881a0, k.a(str2, k.f134447a) + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + k.a(str2, k.f134448b));
            if (!k4.a.H().C()) {
                k4.a.H().g(aVar, this.f27261a.getApplicationContext(), false);
            }
            dismissLoading();
            i4.a.h(this.f27261a.getApplicationContext(), aVar, str, aVar.f109828d);
            throw th2;
        }
    }

    public synchronized String fetchOrderInfoFromH5PayUrl(String str) {
        try {
            if (!TextUtils.isEmpty(str)) {
                String trim = str.trim();
                if (trim.startsWith("https://wappaygw.alipay.com/service/rest.htm") || trim.startsWith("http://wappaygw.alipay.com/service/rest.htm")) {
                    String trim2 = trim.replaceFirst("(http|https)://wappaygw.alipay.com/service/rest.htm\\?", "").trim();
                    if (!TextUtils.isEmpty(trim2)) {
                        String g10 = m.g("<request_token>", "</request_token>", m.n(trim2).get("req_data"));
                        r4.a aVar = new r4.a(this.f27261a, "", "");
                        return "_input_charset=\"utf-8\"&ordertoken=\"" + g10 + "\"&pay_channel_id=\"alipay_sdk\"&bizcontext=\"" + aVar.c("sc", "h5tonative") + "\"";
                    }
                }
                if (trim.startsWith("https://mclient.alipay.com/service/rest.htm") || trim.startsWith("http://mclient.alipay.com/service/rest.htm")) {
                    String trim3 = trim.replaceFirst("(http|https)://mclient.alipay.com/service/rest.htm\\?", "").trim();
                    if (!TextUtils.isEmpty(trim3)) {
                        String g11 = m.g("<request_token>", "</request_token>", m.n(trim3).get("req_data"));
                        r4.a aVar2 = new r4.a(this.f27261a, "", "");
                        return "_input_charset=\"utf-8\"&ordertoken=\"" + g11 + "\"&pay_channel_id=\"alipay_sdk\"&bizcontext=\"" + aVar2.c("sc", "h5tonative") + "\"";
                    }
                }
                if ((trim.startsWith("https://mclient.alipay.com/home/exterfaceAssign.htm") || trim.startsWith("http://mclient.alipay.com/home/exterfaceAssign.htm")) && ((trim.contains("alipay.wap.create.direct.pay.by.user") || trim.contains("create_forex_trade_wap")) && !TextUtils.isEmpty(trim.replaceFirst("(http|https)://mclient.alipay.com/home/exterfaceAssign.htm\\?", "").trim()))) {
                    r4.a aVar3 = new r4.a(this.f27261a, "", "");
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("url", str);
                    jSONObject.put("bizcontext", aVar3.c("sc", "h5tonative"));
                    return "new_external_info==" + jSONObject.toString();
                }
                if (Pattern.compile("^(http|https)://(maliprod\\.alipay\\.com/w/trade_pay\\.do.?|mali\\.alipay\\.com/w/trade_pay\\.do.?|mclient\\.alipay\\.com/w/trade_pay\\.do.?)").matcher(str).find()) {
                    String g12 = m.g("?", "", str);
                    if (!TextUtils.isEmpty(g12)) {
                        Map<String, String> n10 = m.n(g12);
                        StringBuilder sb2 = new StringBuilder();
                        if (k(false, true, i4.b.I0, sb2, n10, i4.b.I0, "alipay_trade_no")) {
                            k(true, false, "pay_phase_id", sb2, n10, "payPhaseId", "pay_phase_id", "out_relation_id");
                            sb2.append("&biz_sub_type=\"TRADE\"");
                            sb2.append("&biz_type=\"trade\"");
                            String str2 = n10.get("app_name");
                            if (TextUtils.isEmpty(str2) && !TextUtils.isEmpty(n10.get("cid"))) {
                                str2 = "ali1688";
                            } else if (TextUtils.isEmpty(str2) && (!TextUtils.isEmpty(n10.get(b.a.F)) || !TextUtils.isEmpty(n10.get("s_id")))) {
                                str2 = TtmlNode.VERTICAL;
                            }
                            sb2.append("&app_name=\"" + str2 + "\"");
                            if (!k(true, true, "extern_token", sb2, n10, "extern_token", "cid", b.a.F, "s_id")) {
                                return "";
                            }
                            k(true, false, "appenv", sb2, n10, "appenv");
                            sb2.append("&pay_channel_id=\"alipay_sdk\"");
                            c cVar = new c(this, null);
                            cVar.d(n10.get("return_url"));
                            cVar.f(n10.get("show_url"));
                            cVar.b(n10.get("pay_order_id"));
                            r4.a aVar4 = new r4.a(this.f27261a, "", "");
                            String str3 = sb2.toString() + "&bizcontext=\"" + aVar4.c("sc", "h5tonative") + "\"";
                            this.f27267g.put(str3, cVar);
                            return str3;
                        }
                    }
                }
                if (trim.startsWith("https://mclient.alipay.com/cashier/mobilepay.htm") || trim.startsWith("http://mclient.alipay.com/cashier/mobilepay.htm") || (h4.a.b() && trim.contains("mobileclientgw.alipaydev.com/cashier/mobilepay.htm"))) {
                    String c10 = new r4.a(this.f27261a, "", "").c("sc", "h5tonative");
                    JSONObject jSONObject2 = new JSONObject();
                    jSONObject2.put("url", trim);
                    jSONObject2.put("bizcontext", c10);
                    return String.format("new_external_info==%s", jSONObject2.toString());
                } else if (k4.a.H().s() && Pattern.compile("^https?://(maliprod\\.alipay\\.com|mali\\.alipay\\.com)/batch_payment\\.do\\?").matcher(trim).find()) {
                    Uri parse = Uri.parse(trim);
                    String queryParameter = parse.getQueryParameter("return_url");
                    String queryParameter2 = parse.getQueryParameter("show_url");
                    String queryParameter3 = parse.getQueryParameter("pay_order_id");
                    String a10 = a(parse.getQueryParameter("trade_nos"), parse.getQueryParameter("alipay_trade_no"));
                    String a11 = a(parse.getQueryParameter("payPhaseId"), parse.getQueryParameter("pay_phase_id"), parse.getQueryParameter("out_relation_id"));
                    String[] strArr = new String[4];
                    strArr[0] = parse.getQueryParameter("app_name");
                    strArr[1] = !TextUtils.isEmpty(parse.getQueryParameter("cid")) ? "ali1688" : "";
                    strArr[2] = !TextUtils.isEmpty(parse.getQueryParameter(b.a.F)) ? TtmlNode.VERTICAL : "";
                    strArr[3] = !TextUtils.isEmpty(parse.getQueryParameter("s_id")) ? TtmlNode.VERTICAL : "";
                    String a12 = a(strArr);
                    String a13 = a(parse.getQueryParameter("extern_token"), parse.getQueryParameter("cid"), parse.getQueryParameter(b.a.F), parse.getQueryParameter("s_id"));
                    String a14 = a(parse.getQueryParameter("appenv"));
                    if (!TextUtils.isEmpty(a10) && !TextUtils.isEmpty(a12) && !TextUtils.isEmpty(a13)) {
                        String format = String.format("trade_no=\"%s\"&pay_phase_id=\"%s\"&biz_type=\"trade\"&biz_sub_type=\"TRADE\"&app_name=\"%s\"&extern_token=\"%s\"&appenv=\"%s\"&pay_channel_id=\"alipay_sdk\"&bizcontext=\"%s\"", a10, a11, a12, a13, a14, new r4.a(this.f27261a, "", "").c("sc", "h5tonative"));
                        c cVar2 = new c(this, null);
                        cVar2.d(queryParameter);
                        cVar2.f(queryParameter2);
                        cVar2.b(queryParameter3);
                        cVar2.h(a10);
                        this.f27267g.put(format, cVar2);
                        return format;
                    }
                }
            }
        } catch (Throwable th2) {
            d.d(th2);
        }
        return "";
    }

    public synchronized String fetchTradeToken() {
        return h.b(new r4.a(this.f27261a, "", "fetchTradeToken"), this.f27261a.getApplicationContext());
    }

    public final String g(r4.a aVar, q4.b bVar) {
        String[] g10 = bVar.g();
        Intent intent = new Intent(this.f27261a, H5PayActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("url", g10[0]);
        if (g10.length == 2) {
            bundle.putString("cookie", g10[1]);
        }
        intent.putExtras(bundle);
        a.C1038a.c(aVar, intent);
        this.f27261a.startActivity(intent);
        Object obj = f27257h;
        synchronized (obj) {
            try {
                obj.wait();
            } catch (InterruptedException e10) {
                d.d(e10);
                return h4.d.a();
            }
        }
        String g11 = h4.d.g();
        return TextUtils.isEmpty(g11) ? h4.d.a() : g11;
    }

    public String getVersion() {
        return "15.8.02";
    }

    public final String h(r4.a aVar, q4.b bVar, String str) {
        boolean f10;
        String g10;
        String[] g11 = bVar.g();
        Intent intent = new Intent(this.f27261a, H5PayActivity.class);
        try {
            JSONObject T = m.T(new String(l4.a.d(g11[2])));
            intent.putExtra("url", g11[0]);
            intent.putExtra("title", g11[1]);
            intent.putExtra("version", com.alipay.sdk.widget.c.f27279d);
            intent.putExtra("method", T.optString("method", "POST"));
            h4.d.d(false);
            h4.d.c(null);
            a.C1038a.c(aVar, intent);
            this.f27261a.startActivity(intent);
            Object obj = f27257h;
            synchronized (obj) {
                try {
                    obj.wait();
                    f10 = h4.d.f();
                    g10 = h4.d.g();
                    h4.d.d(false);
                    h4.d.c(null);
                } catch (InterruptedException e10) {
                    d.d(e10);
                    return h4.d.a();
                }
            }
            String str2 = "";
            if (f10) {
                try {
                    List<q4.b> a10 = q4.b.a(m.T(new String(l4.a.d(g10))));
                    int i10 = 0;
                    while (true) {
                        if (i10 >= a10.size()) {
                            break;
                        }
                        q4.b bVar2 = a10.get(i10);
                        if (bVar2.b() == q4.a.SetResult) {
                            String[] g12 = bVar2.g();
                            str2 = h4.d.b(Integer.valueOf(g12[1]).intValue(), g12[0], m.Q(aVar, g12[2]));
                            break;
                        }
                        i10++;
                    }
                } catch (Throwable th2) {
                    d.d(th2);
                    i4.a.f(aVar, i4.b.f70893l, i4.b.F, th2, g10);
                }
            }
            if (!TextUtils.isEmpty(str2)) {
                return str2;
            }
            try {
                return h4.d.b(Integer.valueOf(str).intValue(), "", "");
            } catch (Throwable th3) {
                i4.a.f(aVar, i4.b.f70893l, i4.b.F, th3, "endCode: " + str);
                return h4.d.b(8000, "", "");
            }
        } catch (Throwable th4) {
            d.d(th4);
            i4.a.f(aVar, i4.b.f70893l, i4.b.F, th4, Arrays.toString(g11));
            return h4.d.a();
        }
    }

    public synchronized t4.a h5Pay(r4.a aVar, String str, boolean z10) {
        t4.a aVar2;
        aVar2 = new t4.a();
        try {
            String[] split = f(aVar, str, z10).split(h.f134437b);
            HashMap hashMap = new HashMap();
            for (String str2 : split) {
                int indexOf = str2.indexOf("={");
                if (indexOf >= 0) {
                    String substring = str2.substring(0, indexOf);
                    hashMap.put(substring, b(str2, substring));
                }
            }
            if (hashMap.containsKey(k.f134447a)) {
                aVar2.c(hashMap.get(k.f134447a));
            }
            aVar2.d(c(str, hashMap));
            if (TextUtils.isEmpty(aVar2.b())) {
                i4.a.i(aVar, i4.b.f70893l, i4.b.f70908s0, "");
            }
        } catch (Throwable th2) {
            i4.a.e(aVar, i4.b.f70893l, i4.b.f70910t0, th2);
            d.d(th2);
        }
        return aVar2;
    }

    public final g.e i() {
        return new b();
    }

    public final void j(r4.a aVar, JSONObject jSONObject) {
        try {
            String optString = jSONObject.optString("tid");
            String optString2 = jSONObject.optString(s4.c.f114550j);
            if (!TextUtils.isEmpty(optString) && !TextUtils.isEmpty(optString2)) {
                s4.c.a(r4.b.e().c()).c(optString, optString2);
            }
        } catch (Throwable th2) {
            i4.a.e(aVar, i4.b.f70893l, i4.b.T, th2);
        }
    }

    public final boolean k(boolean z10, boolean z11, String str, StringBuilder sb2, Map<String, String> map, String... strArr) {
        String str2;
        int length = strArr.length;
        int i10 = 0;
        while (true) {
            if (i10 >= length) {
                str2 = "";
                break;
            }
            String str3 = strArr[i10];
            if (!TextUtils.isEmpty(map.get(str3))) {
                str2 = map.get(str3);
                break;
            }
            i10++;
        }
        if (TextUtils.isEmpty(str2)) {
            if (z11) {
                return false;
            }
            return true;
        } else if (z10) {
            sb2.append("&");
            sb2.append(str);
            sb2.append("=\"");
            sb2.append(str2);
            sb2.append("\"");
            return true;
        } else {
            sb2.append(str);
            sb2.append("=\"");
            sb2.append(str2);
            sb2.append("\"");
            return true;
        }
    }

    public synchronized String pay(String str, boolean z10) {
        return f(new r4.a(this.f27261a, str, "pay"), str, z10);
    }

    public synchronized boolean payInterceptorWithUrl(String str, boolean z10, H5PayCallback h5PayCallback) {
        String fetchOrderInfoFromH5PayUrl;
        fetchOrderInfoFromH5PayUrl = fetchOrderInfoFromH5PayUrl(str);
        if (!TextUtils.isEmpty(fetchOrderInfoFromH5PayUrl)) {
            d.i(j4.a.f73114x, "intercepted: " + fetchOrderInfoFromH5PayUrl);
            new Thread(new a(fetchOrderInfoFromH5PayUrl, z10, h5PayCallback)).start();
        }
        return !TextUtils.isEmpty(fetchOrderInfoFromH5PayUrl);
    }

    public synchronized Map<String, String> payV2(String str, boolean z10) {
        r4.a aVar;
        aVar = new r4.a(this.f27261a, str, "payV2");
        return k.d(aVar, f(aVar, str, z10));
    }

    public void showLoading() {
        v4.a aVar = this.f27262b;
        if (aVar != null) {
            aVar.j();
        }
    }

    public static final String a(String... strArr) {
        if (strArr == null) {
            return "";
        }
        for (String str : strArr) {
            if (!TextUtils.isEmpty(str)) {
                return str;
            }
        }
        return "";
    }

    public static String a(r4.a aVar, String str, List<a.b> list, String str2, Activity activity) {
        m.c r10 = m.r(aVar, activity, list);
        if (r10 == null || r10.b(aVar) || r10.a() || !TextUtils.equals(r10.f134460a.packageName, PayResultActivity.f27247d)) {
            return str2;
        }
        d.g(j4.a.f73114x, "PayTask not_login");
        String valueOf = String.valueOf(str.hashCode());
        Object obj = new Object();
        HashMap<String, Object> hashMap = PayResultActivity.f27246c;
        hashMap.put(valueOf, obj);
        Intent intent = new Intent(activity, PayResultActivity.class);
        intent.putExtra(PayResultActivity.f27249f, str);
        intent.putExtra(PayResultActivity.f27250g, activity.getPackageName());
        intent.putExtra(PayResultActivity.f27248e, valueOf);
        a.C1038a.c(aVar, intent);
        activity.startActivity(intent);
        synchronized (hashMap.get(valueOf)) {
            try {
                d.g(j4.a.f73114x, "PayTask wait");
                hashMap.get(valueOf).wait();
            } catch (InterruptedException unused) {
                d.g(j4.a.f73114x, "PayTask interrupted");
                return h4.d.a();
            }
        }
        String str3 = PayResultActivity.b.f27256b;
        d.g(j4.a.f73114x, "PayTask ret: " + str3);
        return str3;
    }

    public final String b(String str, String str2) {
        String str3 = str2 + "={";
        return str.substring(str.indexOf(str3) + str3.length(), str.lastIndexOf(h.f134439d));
    }

    public class c {

        /* renamed from: a  reason: collision with root package name */
        public String f27273a;

        /* renamed from: b  reason: collision with root package name */
        public String f27274b;

        /* renamed from: c  reason: collision with root package name */
        public String f27275c;

        /* renamed from: d  reason: collision with root package name */
        public String f27276d;

        public c() {
            this.f27273a = "";
            this.f27274b = "";
            this.f27275c = "";
            this.f27276d = "";
        }

        public String a() {
            return this.f27275c;
        }

        public void b(String str) {
            this.f27275c = str;
        }

        public String c() {
            return this.f27273a;
        }

        public void d(String str) {
            this.f27273a = str;
        }

        public String e() {
            return this.f27274b;
        }

        public void f(String str) {
            this.f27274b = str;
        }

        public String g() {
            return this.f27276d;
        }

        public void h(String str) {
            this.f27276d = str;
        }

        public /* synthetic */ c(PayTask payTask, a aVar) {
            this();
        }
    }
}