正在查看: OLX India v19.42.007 应用的 GPayResponseActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: OLX India v19.42.007 应用的 GPayResponseActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.payu.gpay;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.payu.checkoutpro.parser.constants.PayUHybridKeys;
import com.payu.checkoutpro.utils.PayUCheckoutProConstants;
import com.payu.custombrowser.util.CBConstant;
import com.payu.otpassist.utils.Constants;
import com.payu.payuanalytics.analytics.model.PayUAnalytics;
import com.payu.socketverification.interfaces.PayUSocketEventListener;
import com.payu.socketverification.socket.SocketHandler;
import com.payu.socketverification.socket.SocketPaymentResponse;
import com.payu.socketverification.util.PayUNetworkConstant;
import com.payu.socketverification.widgets.PayUProgressDialog;
import com.payu.ui.model.utils.AnalyticsConstant;
import com.payu.ui.model.utils.SdkUiConstants;
import com.payu.upisdk.util.UpiConstant;
import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class GPayResponseActivity extends Activity implements PayUSocketEventListener {
private com.google.android.apps.nbu.paisa.inapp.client.api.b a;
private com.payu.gpay.intent.a b;
private PayUAnalytics c;
private String d;
private String e;
private WebView f;
private com.payu.gpay.c g;
private SocketPaymentResponse h;
private boolean i;
private String j;
private String k;
private int l;
private int m;
private AlertDialog n;
class a extends WebViewClient {
a() {
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
if (GPayResponseActivity.this.isFinishing() || GPayResponseActivity.this.isDestroyed()) {
return;
}
com.payu.gpay.utils.b.i(GPayResponseActivity.this);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
super.onPageStarted(webView, str, bitmap);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
String uri = webResourceRequest.getUrl().toString();
if (uri != null && uri.startsWith(UpiConstant.UPI_INTENT_S)) {
try {
String stringExtra = Intent.parseUri(uri, 1).getStringExtra(CBConstant.BROWSER_FALLBACK_URL);
if (stringExtra != null) {
webView.loadUrl(stringExtra);
return true;
}
} catch (URISyntaxException unused) {
}
}
return false;
}
}
class b extends WebChromeClient {
b(GPayResponseActivity gPayResponseActivity) {
}
@Override
public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
return super.onJsConfirm(webView, str, str2, jsResult);
}
}
class c implements DialogInterface.OnClickListener {
c() {
}
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i != -1) {
if (i == -2) {
dialogInterface.dismiss();
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onBackDismiss();
return;
}
return;
}
return;
}
GPayResponseActivity.this.t();
com.payu.gpay.utils.a aVar2 = com.payu.gpay.utils.a.SINGLETON;
if (aVar2.getPayUGPayCallback() != null) {
aVar2.getPayUGPayCallback().onBackApprove();
}
GPayResponseActivity.this.c.log(com.payu.gpay.utils.b.e(GPayResponseActivity.this.getApplicationContext(), "tez_payment_app_response", "cancel_back_button", GPayResponseActivity.this.e, GPayResponseActivity.this.j, "info"));
if (GPayResponseActivity.this.isFinishing() || GPayResponseActivity.this.isDestroyed()) {
return;
}
GPayResponseActivity.this.finish();
}
}
class d implements Runnable {
d() {
}
@Override
public void run() {
try {
if (new com.payu.gpay.utils.b().h("https://secure.payu.in/paytxn", null, -1, new com.payu.gpay.utils.b().d(GPayResponseActivity.this.getApplicationContext(), "https://secure.payu.in")).getResponseCode() != 200) {
com.payu.gpay.utils.c.a("BackButtonClick - UnSuccessful post to Paytxn");
} else {
com.payu.gpay.utils.c.a("BackButtonClick - Successful post to Paytxn");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private com.payu.gpay.c a(JSONObject jSONObject) {
com.payu.gpay.utils.c.a("Json " + jSONObject);
if (TextUtils.isEmpty(jSONObject.optString("returnUrl")) || TextUtils.isEmpty(jSONObject.optString("merchantVpa")) || TextUtils.isEmpty(jSONObject.optString(Constants.REFERENCE_ID))) {
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() == null) {
return null;
}
aVar.getPayUGPayCallback().onGpayErrorReceived(3, "Merchant Info Not present.");
return null;
}
com.payu.gpay.c cVar = new com.payu.gpay.c();
cVar.j(jSONObject.optString(PayUHybridKeys.CheckoutProConfig.merchantName));
cVar.l(jSONObject.optString("merchantVpa"));
cVar.n(jSONObject.optString(Constants.REFERENCE_ID));
cVar.p(jSONObject.optString("returnUrl"));
cVar.f(jSONObject.optString("amount"));
cVar.r((String) com.payu.gpay.utils.b.s(this.d).get("txnid"));
cVar.t(jSONObject.optString("vpaRegex"));
cVar.h(jSONObject.optString("mcc"));
cVar.c(Boolean.valueOf(jSONObject.optBoolean("cardSupported")));
cVar.d(jSONObject.optString("allowedCardNetworks"));
SocketPaymentResponse socketPaymentResponse = new SocketPaymentResponse();
socketPaymentResponse.setUpiPushDisabled(jSONObject.optString("upiPushDisabled"));
socketPaymentResponse.setPushServiceUrl(jSONObject.optString("pushServiceUrl"));
socketPaymentResponse.setUpiServicePollInterval(jSONObject.optString("upiServicePollInterval"));
socketPaymentResponse.setSdkUpiPushExpiry(jSONObject.optString("sdkUpiPushExpiry"));
socketPaymentResponse.setSdkUpiVerificationInterval(jSONObject.optString("sdkUpiVerificationInterval"));
cVar.b(socketPaymentResponse);
return cVar;
}
private JSONObject d(com.payu.gpay.c cVar) {
JSONObject jSONObject = new JSONObject();
if (cVar != null) {
try {
JSONArray jSONArray = new JSONArray();
com.payu.gpay.utils.c.a("Current FLow " + com.payu.gpay.utils.a.SINGLETON.getCurrentPaymentType());
if (this.l == 1) {
jSONArray.put(e("UPI"));
}
if (this.m == 1 && com.payu.gpay.utils.b.k(cVar)) {
jSONArray.put(e("CARD"));
}
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("totalPriceStatus", "FINAL");
jSONObject2.put("totalPrice", cVar.e());
jSONObject2.put("currencyCode", PayUCheckoutProConstants.CP_BASE_CURRENCY_VALUE);
if (cVar.k() != null) {
jSONObject2.put("transactionNote", cVar.k() + " Order Id " + cVar.u());
}
jSONObject.put("apiVersion", 2);
jSONObject.put("apiVersionMinor", 0);
jSONObject.put("allowedPaymentMethods", jSONArray);
jSONObject.put("transactionInfo", jSONObject2);
} catch (JSONException e) {
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onGpayErrorReceived(2, "Please check input data.");
}
e.printStackTrace();
}
} else {
com.payu.gpay.utils.a.SINGLETON.getPayUGPayCallback().onGpayErrorReceived(2, "Payment Response Getting Null...");
finish();
}
return jSONObject;
}
private JSONObject e(String str) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("type", str);
JSONObject jSONObject2 = new JSONObject();
JSONObject jSONObject3 = new JSONObject();
if (str.equals("UPI")) {
jSONObject3.put("type", "DIRECT");
jSONObject2.put("payeeVpa", this.g.m());
jSONObject2.put("payeeName", this.g.k());
jSONObject2.put("referenceUrl", this.g.q());
jSONObject2.put("mcc", this.g.i());
jSONObject2.put("transactionReferenceId", this.g.o());
jSONObject2.put(PayUHybridKeys.PaymentParam.transactionId, this.j);
} else if (str.equals("CARD")) {
jSONObject3.put("type", "PAYMENT_GATEWAY");
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("gateway", "payuindia");
jSONObject4.put("gatewayMerchantId", this.e);
jSONObject4.put("gatewayTransactionId", this.g.o());
jSONObject3.put("parameters", jSONObject4);
JSONArray jSONArray = new JSONArray();
ArrayList g = com.payu.gpay.utils.b.g(this.g.a());
if (g.contains(SdkUiConstants.CP_CC)) {
jSONArray.put("VISA");
jSONArray.put("MASTERCARD");
} else {
for (int i = 0; i < g.size(); i++) {
if (g.get(i).equals("MAST")) {
jSONArray.put("MASTERCARD");
} else {
jSONArray.put(g.get(i));
}
}
}
jSONObject2.put("allowedCardNetworks", jSONArray);
}
jSONObject.put("parameters", jSONObject2);
jSONObject.put("tokenizationSpecification", jSONObject3);
return jSONObject;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
private void f() {
com.payu.gpay.utils.c.a("oncreate class name:" + getClass().getCanonicalName());
u();
if (!isFinishing() && !isDestroyed()) {
com.payu.gpay.utils.b.j(this, com.payu.gpay.utils.a.SINGLETON.getPayUCustomDialogView());
}
com.payu.gpay.utils.c.a("Postdata:-------------> " + this.d);
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "gpay_payment_option", "gpay_collect", this.e, this.j, "info"));
m(com.payu.gpay.utils.a.SINGLETON.getPostUrl(), this.d);
}
private void g(Bundle bundle) {
this.i = false;
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "gpay_payment_option", "gpay_inapp", this.e, this.j, "info"));
String q = q();
com.payu.gpay.utils.c.a("Response GPay Embedded flow" + q);
try {
com.google.android.apps.nbu.paisa.inapp.client.api.b a2 = com.google.android.apps.nbu.paisa.inapp.client.api.c.a();
this.a = a2;
a2.a(this, q, 101);
} catch (NoSuchAlgorithmException unused) {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "gpay_payment_option", "embed_fail_intent_fallback", this.e, this.j, "info"));
k(bundle);
}
}
private void h(String str, String str2) {
if (this.g.s().getUpiPushDisabled() != null && this.g.s().getUpiPushDisabled().equals("0")) {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), PayUNetworkConstant.UPI_SOCKET, "push_enabled", this.e, this.j, "info"));
s();
return;
}
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "long_polling_from", "verify_using_http", this.e, this.j, "info"));
if (isFinishing() || isDestroyed()) {
return;
}
this.b.d(str, null, this, this.g, str2);
}
private void j() {
c cVar = new c();
if (isFinishing() || isDestroyed()) {
return;
}
AlertDialog.Builder a2 = com.payu.gpay.utils.b.a(this, cVar, getString(e.payu_gpay_ok), getString(e.payu_gpay_cancel), null, getString(e.payu_gpay_do_you_really_want_to_cancel_the_transaction));
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onBackButton(a2);
AlertDialog create = a2.create();
this.n = create;
create.show();
}
}
private void k(Bundle bundle) {
this.i = false;
if (bundle.get("_payment_response") == null || this.d == null) {
return;
}
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "gpay_payment_option", "gpay_intent", this.e, this.j, "info"));
if (isFinishing() || isDestroyed()) {
return;
}
this.b.c(getIntent().getExtras().getString("_payment_response"), this.d, this);
}
private void l(String str) {
if (isFinishing() || isDestroyed()) {
return;
}
this.b = new com.payu.gpay.intent.a(this, str);
}
private void m(String str, String str2) {
WebView webView = this.f;
if (webView != null) {
this.i = true;
webView.setVisibility(0);
this.f.postUrl(str, str2.getBytes());
}
}
private void o() {
this.h.setReferenceId(this.g.o());
this.h.setTxnId(this.j);
this.h.setUpiPushDisabled(this.g.s().getUpiPushDisabled());
this.h.setUpiServicePollInterval(this.g.s().getUpiServicePollInterval());
this.h.setSdkUpiPushExpiry(this.g.s().getSdkUpiPushExpiry());
this.h.setSdkUpiVerificationInterval(this.g.s().getSdkUpiVerificationInterval());
this.h.setPushServiceUrl(this.g.s().getPushServiceUrl());
}
private void p(String str) {
if ("success".equalsIgnoreCase(str)) {
this.b.b(str, this.g);
}
}
private String q() {
return String.valueOf(d(this.g));
}
private void r() {
if (getIntent() == null || getIntent().getExtras() == null || getIntent().getExtras().get("paymentway") == null || !getIntent().getExtras().getString("paymentway").equals("collect")) {
return;
}
setTheme(f.gpay_opaque_screen);
}
private void s() {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "verify_type", "socket", this.e, this.j, "info"));
this.h = new SocketPaymentResponse();
o();
SocketHandler.getInstance().createSocket(this.h, this, this);
}
private void u() {
WebView webView = this.f;
if (webView != null) {
webView.getSettings().setJavaScriptEnabled(true);
this.f.addJavascriptInterface(new com.payu.gpay.intent.b(this, this.c), "PayU");
this.f.setVisibility(8);
this.f.setWebViewClient(new a());
this.f.setWebChromeClient(new b(this));
}
}
String b(int i) {
String str;
if (i != 10) {
if (i != 405) {
if (i == 409) {
str = "buyer_account_error";
} else if (i != 412) {
str = "internal_error";
}
}
str = "unsupported_api_version";
} else {
str = "developer_error";
}
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", str, this.e, this.j, "info"));
return str;
}
@Override
public void errorReceived(int i, String str) {
com.payu.gpay.utils.c.a("Error Received " + str);
if (i == 1003) {
if (isFinishing() || isDestroyed()) {
return;
}
this.b.d("success", "success", this, this.g, null);
return;
}
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onPaymentFailure(str, null);
}
}
@Override
public void getSocketResult(String str, String str2, String str3, boolean z) {
if (str3.equals("success")) {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "trxn_status_gpay_sdk", "success_transaction", this.e, this.j, "info"));
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onPaymentSuccess(str2, null);
}
} else {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "trxn_status_gpay_sdk", "failure_transaction", this.e, this.j, "error"));
com.payu.gpay.utils.a aVar2 = com.payu.gpay.utils.a.SINGLETON;
if (aVar2.getPayUGPayCallback() != null) {
aVar2.getPayUGPayCallback().onPaymentFailure(str2, null);
}
}
if (isFinishing() || isDestroyed()) {
return;
}
finish();
}
@Override
protected void onActivityResult(int i, int i2, Intent intent) {
if (i != 101) {
if (i == 103) {
if (i2 != -1 || intent == null) {
com.payu.gpay.utils.c.a("Cancel return");
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", "cancel", this.e, this.j, "info"));
if (isFinishing() || isDestroyed()) {
return;
}
this.b.d("cancel", "cancelled", this, this.g, null);
return;
}
if (!"success".equalsIgnoreCase(intent.getStringExtra(AnalyticsConstant.CP_GV_STATUS))) {
com.payu.gpay.utils.c.a("Failure return");
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", "failure", this.e, this.j, "info"));
h("failure", "INTENT");
return;
}
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", "success", this.e, this.j, "info"));
h("success", "INTENT");
com.payu.gpay.utils.c.a("Is UpiDisabled ... " + this.g.s().getUpiPushDisabled());
com.payu.gpay.utils.c.a("Success return");
return;
}
return;
}
if (com.payu.gpay.utils.a.SINGLETON.getCurrentPaymentType() == h.IN_APP) {
if (i2 != -1) {
if (i2 == 0) {
com.payu.gpay.utils.c.a("Payment Data Cancelled <> ");
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", "cancelled", this.e, this.j, "info"));
if (isFinishing() || isDestroyed()) {
return;
}
this.b.d("cancel", "cancelled", this, this.g, null);
return;
}
if (i2 != 1) {
return;
}
Bundle extras = intent.getExtras();
if (extras != null) {
for (String str : extras.keySet()) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" : ");
sb.append(extras.get(str) != null ? extras.get(str) : "NULL");
Log.v("PAYU", sb.toString());
}
}
int intExtra = intent.getIntExtra("errorCode", 8);
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", "failure", this.e, this.j, "info"));
if (isFinishing() || isDestroyed()) {
return;
}
this.b.d(CBConstant.FAIL, b(intExtra), this, this.g, null);
return;
}
String a2 = com.google.android.apps.nbu.paisa.inapp.client.api.d.a(intent);
com.payu.gpay.utils.c.a("Payment Data " + a2);
try {
JSONObject jSONObject = new JSONObject(a2);
String string = jSONObject.optJSONObject("paymentMethodData").getString("type");
JSONObject jSONObject2 = new JSONObject(new JSONObject(jSONObject.optJSONObject("paymentMethodData").optJSONObject("tokenizationData").optString(PayUCheckoutProConstants.CP_TOKEN)).optString("signedMessage"));
com.payu.gpay.utils.c.a("Status>>>>> " + jSONObject2.optJSONObject("paymentMethodDetails").optString("status"));
p(jSONObject2.optJSONObject("paymentMethodDetails").optString("status"));
if (string.equalsIgnoreCase("UPI")) {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", a2, this.e, this.j, "info"));
h(jSONObject2.optJSONObject("paymentMethodDetails").optString("status"), string);
} else {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response_not_tez", a2, this.e, this.j, "info"));
if (!isFinishing() && !isDestroyed()) {
this.b.d(jSONObject2.optJSONObject("paymentMethodDetails").optString("status"), null, this, this.g, string);
}
}
} catch (JSONException e) {
this.c.log(com.payu.gpay.utils.b.e(getApplicationContext(), "tez_payment_app_response", "Getting incorrect response from Google.", this.e, this.j, "error"));
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onGpayErrorReceived(3, "Getting incorrect response from Google.");
}
e.printStackTrace();
}
}
}
@Override
public void onBackPressed() {
if (this.i) {
j();
return;
}
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onPaymentFailure(null, null);
if (isFinishing() || isDestroyed()) {
return;
}
finish();
}
}
@Override
protected void onCreate(android.os.Bundle r6) {
throw new UnsupportedOperationException("Method not decompiled: com.payu.gpay.GPayResponseActivity.onCreate(android.os.Bundle):void");
}
@Override
protected void onDestroy() {
super.onDestroy();
com.payu.gpay.utils.c.a("Gpay Activity Destroy");
SocketHandler.getInstance().onActivityDestroyed(this);
AlertDialog alertDialog = this.n;
if (alertDialog != null) {
alertDialog.dismiss();
}
com.payu.gpay.utils.b.a = null;
com.payu.gpay.utils.a aVar = com.payu.gpay.utils.a.SINGLETON;
if (aVar.getPayUGPayCallback() != null) {
aVar.getPayUGPayCallback().onPaymentTerminate();
}
PayUProgressDialog payUProgressDialog = com.payu.gpay.utils.b.a;
if (payUProgressDialog != null && payUProgressDialog.isShowing()) {
com.payu.gpay.utils.b.a.dismiss();
}
com.payu.gpay.utils.b.a = null;
}
@Override
protected void onPause() {
super.onPause();
SocketHandler.getInstance().onActivityPaused(this);
}
@Override
public void onSocketCreated() {
SocketHandler.getInstance().startSocketEvents(this.e, this.j, this, com.payu.gpay.utils.a.SINGLETON.getPayUCustomDialogView());
}
@Override
protected void onStop() {
super.onStop();
}
protected void t() {
Thread thread = new Thread(new d());
thread.setPriority(10);
thread.start();
}
@Override
public void transactionCancelled() {
if (isFinishing() || isDestroyed()) {
return;
}
this.b.d("cancel", null, this, this.g, null);
}
}