package com.pingplusplus.android; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; import android.view.ViewGroup; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import asmack.org.jivesoftware.smackx.Form; import com.baidu.paysdk.api.BaiduPay; import com.unionpay.C0441a; import com.unionpay.uppay.PayActivity; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import org.json.JSONException; import org.json.JSONObject; public class PaymentActivity extends Activity { /* renamed from: a */ private static String f11993a; /* renamed from: b */ private String f11994b = null; /* renamed from: c */ public int f11995c = 0; /* renamed from: d */ private int f11996d = 0; /* renamed from: e */ private ProgressDialog f11997e = null; /* renamed from: f */ private String f11998f = Form.TYPE_CANCEL; /* renamed from: g */ private JSONObject f11999g; /* renamed from: h */ private l f12000h = null; private boolean i = false; WebViewClient j = new d(this); WebViewClient k = new e(this); WebViewClient l = new f(this); private Handler m = new g(this); private void a(JSONObject jSONObject) { JSONObject jSONObject2 = jSONObject.getJSONObject("alipay"); a.b("PaymentActivity start alipay credential : " + jSONObject); new b(this, jSONObject2.getString("orderInfo")).start(); } private boolean a(JSONObject jSONObject, String str, String str2) { return (str2 == null || str2.equals(str)) && jSONObject.has(str) && !jSONObject.getString(str).equals("[]") && !jSONObject.getString(str).equals("{}"); } private void b(String str, String str2) { a.b("模拟支付页面: 支付渠道 " + str2); WebView webView = new WebView(this); webView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1)); setContentView(webView); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setUserAgentString(String.format("%s; %s/%s", settings.getUserAgentString(), "PingppAndroidSDK", "2.0.7")); webView.addJavascriptInterface(new h(this, this), "PingppAndroidSDK"); webView.setWebViewClient(this.j); String format = String.format("http://sissi.pingxx.com/mock.php?ch_id=%s&channel=%s", str, str2); a.a(format); webView.loadUrl(format); this.f11997e = ProgressDialog.show(this, "", "Loading", true); } private void b(JSONObject jSONObject) { JSONObject jSONObject2 = jSONObject.getJSONObject("wx"); a.b("PaymentActivity start wx credential : " + jSONObject); String string = jSONObject2.getString("appId"); i.a().a(string); try { this.f12000h = new l(this, string); i.a().a(this.f12000h); if (!this.f12000h.a()) { a("invalid", "wx_app_not_installed"); return; } if (this.f12000h.b() >= 570425345) { this.f11995c = 1; this.f12000h.a(jSONObject2); return; } a("fail", "wx_app_not_support"); } catch (NoClassDefFoundError e2) { e2.printStackTrace(); String c2 = i.a().c(); a("fail", "channel_sdk_not_included:" + c2, "不支持该渠道: " + c2 + "。缺少微信的 SDK。"); } } private void c(JSONObject jSONObject) { String str; StringBuilder sb; JSONObject jSONObject2; if (jSONObject.has("upacp")) { jSONObject2 = jSONObject.getJSONObject("upacp"); sb = new StringBuilder(); str = "PaymentActivity start upacp credential : "; } else { jSONObject2 = jSONObject.getJSONObject("upmp"); sb = new StringBuilder(); str = "PaymentActivity start upmp credential : "; } sb.append(str); sb.append(jSONObject); a.b(sb.toString()); try { C0441a.a(this, PayActivity.class, (String) null, (String) null, jSONObject2.getString("tn"), jSONObject2.getString("mode")); } catch (NoClassDefFoundError e2) { e2.printStackTrace(); String c2 = i.a().c(); a("fail", "channel_sdk_not_included:" + c2, "不支持该渠道: " + c2 + "。缺少银联的 SDK。"); } } private void d(JSONObject jSONObject) { JSONObject jSONObject2 = jSONObject.getJSONObject("bfb"); a.b("PaymentActivity start bfb credential : " + jSONObject); try { BaiduPay.getInstance(); HashMap hashMap = new HashMap(); hashMap.put("cashier_type", "0"); ArrayList arrayList = new ArrayList(); Iterator<String> keys = jSONObject2.keys(); while (keys.hasNext()) { String next = keys.next(); ArrayList arrayList2 = new ArrayList(); arrayList2.add(next); arrayList2.add(jSONObject2.getString(next)); arrayList.add(TextUtils.join("=", arrayList2)); } if (arrayList.size() == 0) { a("fail", "invalid_credential"); return; } String join = TextUtils.join("&", arrayList); this.f11996d = 1; BaiduPay.getInstance().doPay(this, join, new c(this), hashMap); } catch (NoClassDefFoundError e2) { e2.printStackTrace(); String c2 = i.a().c(); a("fail", "channel_sdk_not_included:" + c2, "不支持该渠道: " + c2 + "。缺少百度钱包的 SDK。"); } } /* JADX WARNING: Removed duplicated region for block: B:12:0x008f */ /* JADX WARNING: Removed duplicated region for block: B:13:0x0092 */ private void e(JSONObject jSONObject) { String str; UnsupportedEncodingException e2; JSONObject jSONObject2 = jSONObject.getJSONObject("yeepay_wap"); a.b("PaymentActivity start yeepay_wap credential : " + jSONObject); String string = jSONObject2.getString("merchantaccount"); String str2 = null; try { str = URLEncoder.encode(jSONObject2.getString("encryptkey"), "UTF-8"); try { str2 = URLEncoder.encode(jSONObject2.getString("data"), "UTF-8"); } catch (UnsupportedEncodingException e3) { e2 = e3; } } catch (UnsupportedEncodingException e4) { e2 = e4; str = null; e2.printStackTrace(); String string2 = jSONObject2.getString("mode"); WebView webView = new WebView(this); webView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1)); setContentView(webView); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setUserAgentString(String.format("%s; %s/%s", settings.getUserAgentString(), "PingppAndroidSDK", "2.0.7")); webView.addJavascriptInterface(new h(this, this), "PingppAndroidSDK"); webView.setWebViewClient(this.k); webView.loadUrl(String.format(!"live".equals(string2) ? "https://ok.yeepay.com/paymobile/api/pay/request?merchantaccount=%s&encryptkey=%s&data=%s" : "http://mobiletest.yeepay.com/paymobile/api/pay/request?merchantaccount=%s&encryptkey=%s&data=%s", string, str, str2)); this.f11997e = ProgressDialog.show(this, "", "Loading", true); } String string22 = jSONObject2.getString("mode"); WebView webView2 = new WebView(this); webView2.setLayoutParams(new ViewGroup.LayoutParams(-1, -1)); setContentView(webView2); WebSettings settings2 = webView2.getSettings(); settings2.setJavaScriptEnabled(true); settings2.setUserAgentString(String.format("%s; %s/%s", settings2.getUserAgentString(), "PingppAndroidSDK", "2.0.7")); webView2.addJavascriptInterface(new h(this, this), "PingppAndroidSDK"); webView2.setWebViewClient(this.k); webView2.loadUrl(String.format(!"live".equals(string22) ? "https://ok.yeepay.com/paymobile/api/pay/request?merchantaccount=%s&encryptkey=%s&data=%s" : "http://mobiletest.yeepay.com/paymobile/api/pay/request?merchantaccount=%s&encryptkey=%s&data=%s", string, str, str2)); this.f11997e = ProgressDialog.show(this, "", "Loading", true); } private void f(JSONObject jSONObject) { JSONObject jSONObject2 = jSONObject.getJSONObject("jdpay_wap"); a.b("PaymentActivity start jdpay_wap credential : " + jSONObject); WebView webView = new WebView(this); webView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1)); setContentView(webView); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setUserAgentString(String.format("%s; %s/%s", settings.getUserAgentString(), "PingppAndroidSDK", "2.0.7")); webView.addJavascriptInterface(new h(this, this), "PingppAndroidSDK"); webView.setWebViewClient(this.l); ArrayList arrayList = new ArrayList(); Iterator<String> keys = jSONObject2.keys(); while (keys.hasNext()) { String next = keys.next(); ArrayList arrayList2 = new ArrayList(); arrayList2.add(next); try { arrayList2.add(URLEncoder.encode(jSONObject2.getString(next), "UTF-8")); } catch (UnsupportedEncodingException e2) { e2.printStackTrace(); } arrayList.add(TextUtils.join("=", arrayList2)); } if (arrayList.size() == 0) { a("fail", "invalid_credential"); return; } String join = TextUtils.join("&", arrayList); a.b("jdPay orderInfo: " + join); webView.postUrl(f11993a, join.getBytes()); this.f11997e = ProgressDialog.show(this, "", "Loading", true); } public void a() { int i2 = i.a().f12017d; if (i2 == 0) { a("success"); } else if (i2 == -2) { a(Form.TYPE_CANCEL, "user_cancelled"); } else { a("fail", "channel_returns_fail", "wx_err_code:" + i2); } i.a().f12017d = -10; } public void a(String str) { a(str, ""); } public void a(String str, String str2) { a(str, str2, ""); } public void a(String str, String str2, String str3) { a.a("setResultAndFinish result=" + str + " isWXPayEntryActivity=" + this.i); i.a().b(null); i.a().a((l) null); Intent intent = new Intent(); intent.putExtra("pay_result", str); intent.putExtra("error_msg", str2); intent.putExtra("extra_msg", str3); setResult(-1, intent); finish(); } public void onActivityResult(int i2, int i3, Intent intent) { String str; super.onActivityResult(i2, i3, intent); if (i.a().c() != null && !i.a().c().equalsIgnoreCase("upmp") && !i.a().c().equalsIgnoreCase("upacp")) { return; } if (intent == null) { a("fail", ""); return; } String string = intent.getExtras().getString("pay_result"); if (string == null) { a("fail"); } else if (string.equalsIgnoreCase("success")) { a("success"); } else { if (string.equalsIgnoreCase("fail")) { str = "channel_returns_fail"; } else if (string.equalsIgnoreCase(Form.TYPE_CANCEL)) { a(Form.TYPE_CANCEL, "user_cancelled"); return; } else { str = "unknown_error"; } a("fail", str); } } public void onBackPressed() { i.a().b(null); Intent intent = new Intent(); intent.putExtra("pay_result", this.f11998f); setResult(-1, intent); super.onBackPressed(); } /* JADX WARNING: Removed duplicated region for block: B:21:0x0080 */ /* JADX WARNING: Removed duplicated region for block: B:47:0x011a */ public void onCreate(Bundle bundle) { JSONObject jSONObject; super.onCreate(bundle); a.a("onCreate"); if (bundle == null) { this.f11999g = null; String stringExtra = getIntent().getStringExtra("com.pingplusplus.android.PaymentActivity.CHARGE"); if (stringExtra != null) { a.b("PaymentActivity received charge: " + stringExtra); try { this.f11999g = new JSONObject(stringExtra); if (this.f11999g.has("credential")) { this.f11994b = this.f11999g.getString("channel"); if (!this.f11999g.has("livemode") || this.f11999g.getBoolean("livemode")) { jSONObject = this.f11999g.getJSONObject("credential"); if (jSONObject == null) { i.a().b(this.f11994b); a.b("PaymentActivity received channel: " + this.f11994b); try { if (!a(jSONObject, "upmp", this.f11994b)) { if (!a(jSONObject, "upacp", this.f11994b)) { if (a(jSONObject, "wx", this.f11994b)) { b(jSONObject); return; } else if (a(jSONObject, "alipay", this.f11994b)) { a(jSONObject); return; } else if (a(jSONObject, "bfb", this.f11994b)) { d(jSONObject); return; } else if (a(jSONObject, "yeepay_wap", this.f11994b)) { e(jSONObject); return; } else if (a(jSONObject, "jdpay_wap", this.f11994b)) { f(jSONObject); return; } else { i.a().b(null); a("fail", "invalid_charge_no_such_channel"); return; } } } c(jSONObject); return; } catch (JSONException unused) { i.a().b(null); a("fail", "invalid_credential"); return; } } else if (i.a().b() != null) { a.a("isWXPayEntryActivity"); this.i = true; this.f12000h = i.a().d(); l lVar = this.f12000h; if (lVar != null) { lVar.a(this); this.f12000h.a(getIntent()); return; } return; } else { return; } } else { b(this.f11999g.getString("id"), this.f11994b); return; } } else { a("fail", "invalid_charge_no_credential"); } } catch (JSONException unused2) { a("fail", "invalid_charge_json_decode_fail"); } } jSONObject = null; if (jSONObject == null) { } } } public void onDestroy() { super.onDestroy(); a.a("onDestroy isWXPayEntryActivity=" + this.i); } public void onNewIntent(Intent intent) { super.onNewIntent(intent); a.a("onNewIntent isWXPayEntryActivity=" + this.i); if (this.f12000h != null) { setIntent(intent); this.f12000h.a(getIntent()); } } public void onPause() { super.onPause(); if (this.f11995c == 1) { this.f11995c = 2; } else if (this.f11996d == 1 && i.a().c() != null && i.a().c().equalsIgnoreCase("bfb")) { this.f11996d = 2; } } public void onResume() { super.onResume(); a.a("onResume wxPayStatus=" + this.f11995c + " isWXPayEntryActivity=" + this.i); int i2 = this.f11995c; if (i2 == 2 || this.f11996d == 2) { a(Form.TYPE_CANCEL, "user_cancelled"); } else if (i2 == 0 && i.a().f12017d != -10 && i.a().c().equals("wx")) { a(); } } }