iKredit v1.2.0.3版本的 MD5 值为:2c00c5c79eecbd6be4c3c546c28d778d
以下内容为反编译后的 Checkout.java 源代码,内容仅作参考
package com.razorpay;
import android.app.Activity;
import android.app.Fragment;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.facebook.share.internal.ShareConstants;
import com.razorpay.AnalyticsProperty;
import java.lang.reflect.Method;
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;
public class Checkout extends Fragment {
private static WebView G__G_ = null;
public static final int INCOMPATIBLE_PLUGIN = 7;
public static final int INVALID_OPTIONS = 3;
public static final int NETWORK_ERROR = 2;
public static final int PAYMENT_CANCELED = 0;
private static long R$$r_ = 0;
public static final int RZP_REQUEST_CODE = 62442;
public static final int TLS_ERROR = 6;
private static PaymentData Y$_o$;
private static boolean a_$P$;
private static long d__1_;
private Activity B$$W$;
private String D$_X_;
private boolean E$_j$;
private boolean O_$B_;
private String Q_$2$;
private int b__J_;
private JSONObject r$_Y_;
public static class Builder {
private int Q_$2$;
private boolean R$$r_;
private String d__1_;
public Builder setKeyId(String str) {
this.d__1_ = str;
return this;
}
public Builder setImage(int i) {
this.Q_$2$ = i;
return this;
}
public Builder disableFullscreen(boolean z) {
this.R$$r_ = z;
return this;
}
public Checkout build() {
Checkout checkout = new Checkout();
checkout.setFullScreenDisable(this.R$$r_);
checkout.setImage(this.Q_$2$);
String str = this.d__1_;
if (str != null) {
checkout.setKeyID(str);
}
return checkout;
}
}
@Deprecated
public final void setPublicKey(String str) {
this.Q_$2$ = str;
}
public final void setImage(int i) {
this.b__J_ = i;
}
public final void setKeyID(String str) {
setPublicKey(str);
}
public final void setFullScreenDisable(boolean z) {
this.E$_j$ = z;
}
public final void open(Activity activity, JSONObject jSONObject) {
if (TextUtils.isEmpty(this.Q_$2$)) {
this.Q_$2$ = BaseUtils.getKeyId(activity);
}
if (TextUtils.isEmpty(this.Q_$2$)) {
throw new RuntimeException("Please set your Razorpay API key in AndroidManifest.xml");
}
if (jSONObject == null || jSONObject.length() == 0) {
throw new RuntimeException("Checkout options cannot be null or empty");
}
try {
jSONObject.put("key", this.Q_$2$);
} catch (JSONException e) {
AnalyticsUtil.reportError(e, "warning", e.getMessage());
}
long nanoTime = System.nanoTime();
try {
if (G__G_ != null) {
long longValue = nanoTime - ((Long) G__G_.getTag()).longValue();
R$$r_ = longValue;
BaseUtils.nanoTimeToSecondsString(longValue, 2);
}
} catch (Exception unused) {
}
try {
G__G_.stopLoading();
} catch (Exception unused2) {
}
G__G_ = null;
this.r$_Y_ = jSONObject;
this.D$_X_ = activity.getClass().getName();
this.B$$W$ = activity;
activity.getFragmentManager().beginTransaction().add(this, (String) null).commitAllowingStateLoss();
}
public static void preload(Context context) {
d__1_ = 0L;
R$$r_ = 0L;
a_$P$ = false;
Context applicationContext = context.getApplicationContext();
WebView webView = new WebView(applicationContext);
G__G_ = webView;
BaseUtils.setWebViewSettings(applicationContext, webView, false);
G__G_.setWebViewClient(new WebViewClient() {
private long a_$P$;
@Override
public final void onPageStarted(WebView webView2, String str, Bitmap bitmap) {
this.a_$P$ = System.nanoTime();
if (Checkout.G__G_ != null) {
Checkout.G__G_.setTag(Long.valueOf(this.a_$P$));
return;
}
HashMap hashMap = new HashMap();
hashMap.put("error_location", "Checkout->Preload()->onPageStarted");
AnalyticsUtil.trackEvent(AnalyticsEvent.WEB_VIEW_UNEXPECTED_NULL, hashMap);
}
@Override
public final void onReceivedError(WebView webView2, int i, String str, String str2) {
Checkout.a_$P$ = true;
}
@Override
public final void onReceivedError(WebView webView2, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
super.onReceivedError(webView2, webResourceRequest, webResourceError);
Checkout.a_$P$ = true;
}
@Override
public final void onPageFinished(WebView webView2, String str) {
long nanoTime = System.nanoTime();
if (!Checkout.a_$P$) {
long unused = Checkout.d__1_ = nanoTime - this.a_$P$;
BaseUtils.nanoTimeToSecondsString(Checkout.d__1_, 2);
}
Checkout.d__1_();
}
});
G__G_.setWebChromeClient(new WebChromeClient() {
@Override
public final void onProgressChanged(WebView webView2, int i) {
}
});
G__G_.loadUrl("https://api.razorpay.com/v1/checkout/public");
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (this.r$_Y_ != null) {
Intent intent = new Intent();
intent.setComponent(new ComponentName(getActivity().getPackageName(), "com.razorpay.CheckoutActivity"));
long j = d__1_;
if (j > 0) {
intent.putExtra("PRELOAD_COMPLETE_DURATION", j);
} else {
long j2 = R$$r_;
if (j2 > 0) {
intent.putExtra("PRELOAD_ABORT_DURATION", j2);
}
}
intent.putExtra("OPTIONS", this.r$_Y_.toString());
intent.putExtra(ShareConstants.IMAGE_URL, this.b__J_);
intent.putExtra("DISABLE_FULL_SCREEN", this.E$_j$);
this.r$_Y_ = null;
startActivityForResult(intent, RZP_REQUEST_CODE);
}
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
Bundle extras;
if (i != 62442) {
return;
}
Activity activity = getActivity();
this.B$$W$ = activity;
this.D$_X_ = activity.getClass().getName();
String string = (intent == null || (extras = intent.getExtras()) == null) ? null : extras.getString("RESULT");
if (i2 == 0 && (string == null || !string.contains("error"))) {
string = "Payment Cancelled";
}
R$$r_(this.B$$W$, string);
Q_$2$(i2, string);
if (i2 == 1) {
String paymentId = Y$_o$.getPaymentId();
if (paymentId != null) {
this.O_$B_ = true;
onSuccess(paymentId);
}
if (this.O_$B_) {
R$$r_(1, 1);
}
} else if (i2 == 4) {
if (getActivity() instanceof ExternalWalletListener) {
try {
ExternalWalletListener externalWalletListener = (ExternalWalletListener) getActivity();
String externalWallet = Y$_o$.getExternalWallet();
if (!TextUtils.isEmpty(externalWallet)) {
externalWalletListener.onExternalWalletSelected(externalWallet, Y$_o$);
AnalyticsUtil.trackEvent(AnalyticsEvent.MERCHANT_EXTERNAL_WALLET_SELECTED_CALLED);
AnalyticsUtil.postData();
}
} catch (Exception e) {
R$$r_(this.B$$W$, 4, "threw_error", e);
}
} else {
R$$r_(this.B$$W$, 4, "dne", new Exception());
}
} else {
this.O_$B_ = true;
onError(i2, string);
if (this.O_$B_) {
R$$r_(i2, 1);
}
}
try {
getActivity().getFragmentManager().beginTransaction().remove(this).commit();
} catch (Exception e2) {
AnalyticsUtil.reportError(e2, "error", e2.getMessage());
}
}
public void onSuccess(String str) {
this.O_$B_ = false;
if (d__1_(str)) {
return;
}
Method method = null;
try {
method = Class.forName(this.D$_X_).getMethod("onPaymentSuccess", String.class);
} catch (Exception e) {
R$$r_(this.B$$W$, 1, "dne", e);
}
try {
Object[] objArr = {str};
if (method != null) {
method.invoke(this.B$$W$, objArr);
}
R$$r_(1, 2);
} catch (Exception e2) {
R$$r_(this.B$$W$, 1, "threw_error", e2);
}
}
public void onError(int i, String str) {
this.O_$B_ = false;
if (a_$P$(i, str)) {
return;
}
Method method = null;
try {
method = Class.forName(this.D$_X_).getMethod("onPaymentError", Integer.TYPE, String.class);
} catch (Exception e) {
R$$r_(this.B$$W$, i, "dne", e);
}
try {
Object[] objArr = {Integer.valueOf(i), str};
if (method != null) {
method.invoke(this.B$$W$, objArr);
}
R$$r_(i, 2);
} catch (Exception e2) {
R$$r_(this.B$$W$, i, "threw_error", e2);
}
}
private boolean a_$P$(int i, String str) {
if (getActivity() instanceof PaymentResultListener) {
try {
((PaymentResultListener) getActivity()).onPaymentError(i, str);
R$$r_(i, 3);
} catch (Exception e) {
R$$r_(this.B$$W$, i, "threw_error", e);
}
return true;
}
if (!(getActivity() instanceof PaymentResultWithDataListener)) {
return false;
}
try {
((PaymentResultWithDataListener) getActivity()).onPaymentError(i, str, Y$_o$);
R$$r_(i, 3);
} catch (Exception e2) {
R$$r_(this.B$$W$, i, "threw_error", e2);
}
return true;
}
private boolean d__1_(String str) {
if (getActivity() instanceof PaymentResultListener) {
try {
((PaymentResultListener) getActivity()).onPaymentSuccess(str);
R$$r_(1, 3);
} catch (Exception e) {
R$$r_(this.B$$W$, 1, "threw_error", e);
}
return true;
}
if (!(getActivity() instanceof PaymentResultWithDataListener)) {
return false;
}
try {
((PaymentResultWithDataListener) getActivity()).onPaymentSuccess(str, Y$_o$);
R$$r_(1, 3);
} catch (Exception e2) {
R$$r_(this.B$$W$, 1, "threw_error", e2);
}
return true;
}
private static void R$$r_(int i, int i2) {
try {
HashMap hashMap = new HashMap();
hashMap.put("integration_type", Integer.toString(i2));
if (i == 1) {
AnalyticsUtil.trackEvent(AnalyticsEvent.MERCHANT_ON_SUCCESS_CALLED, hashMap);
} else {
AnalyticsUtil.trackEvent(AnalyticsEvent.MERCHANT_ON_ERROR_CALLED, hashMap);
}
AnalyticsUtil.postData();
} catch (Exception e) {
AnalyticsUtil.reportError(e, "warning", e.getMessage());
}
}
private static void Q_$2$(int i, String str) {
try {
AnalyticsUtil.addProperty("onActivityResult result", new AnalyticsProperty(str, AnalyticsProperty.d__1_.ORDER));
AnalyticsUtil.addProperty("onActivityResult resultCode", new AnalyticsProperty(String.valueOf(i), AnalyticsProperty.d__1_.ORDER));
if (i == 1) {
AnalyticsUtil.trackEvent(AnalyticsEvent.CALLING_ON_SUCCESS);
} else if (i == 4) {
AnalyticsUtil.trackEvent(AnalyticsEvent.CALLING_EXTERNAL_WALLET_SELECTED);
} else {
AnalyticsUtil.trackEvent(AnalyticsEvent.CALLING_ON_ERROR);
}
AnalyticsUtil.postData();
} catch (Exception e) {
AnalyticsUtil.reportError(e, "warning", e.getMessage());
}
}
private static void R$$r_(Activity activity, int i, String str, Exception exc) {
String str2;
String str3;
if (i == 1) {
str2 = "onPaymentSuccess";
str3 = "success";
} else if (i == 4) {
str2 = "onExternalWalletSelected";
str3 = "redirected";
} else {
str2 = "onPaymentError";
str3 = "error";
}
try {
HashMap hashMap = new HashMap();
hashMap.put("event_details", exc.getMessage());
hashMap.put("event_type", exc.getMessage());
hashMap.put("payment_status", str3);
AnalyticsUtil.trackEvent(AnalyticsEvent.HANDOVER_ERROR, hashMap);
AnalyticsUtil.postData();
} catch (Exception e) {
AnalyticsUtil.reportError(e, "error", e.getMessage());
}
if (str.equals("dne")) {
if (i == 4) {
Toast.makeText(activity, "Error: ExternalWalletListener probably not implemented in your activity", 0).show();
} else {
StringBuilder sb = new StringBuilder("Error: ");
sb.append(str2);
sb.append(" probably not implemented in your activity");
Toast.makeText(activity, sb.toString(), 0).show();
}
} else if (str.equals("threw_error")) {
StringBuilder sb2 = new StringBuilder("Your ");
sb2.append(str2);
sb2.append(" method is throwing an error. Wrap the entire code of the method inside a try catch.");
Toast.makeText(activity, sb2.toString(), 0).show();
}
AnalyticsUtil.reportError(exc, "error", exc.getMessage());
}
private static void R$$r_(Activity activity, String str) {
PaymentData paymentData = new PaymentData();
Y$_o$ = paymentData;
paymentData.a_$P$(I$_n_.Q_$2$(activity).getString("rzp_user_contact", null));
Y$_o$.R$$r_(I$_n_.Q_$2$(activity).getString("rzp_user_email", null));
try {
JSONObject jSONObject = new JSONObject(str);
Y$_o$.R$$r_(jSONObject);
if (jSONObject.has("razorpay_payment_id")) {
Y$_o$.G__G_(jSONObject.getString("razorpay_payment_id"));
}
if (jSONObject.has("razorpay_order_id")) {
Y$_o$.d__1_(jSONObject.getString("razorpay_order_id"));
}
if (jSONObject.has("razorpay_signature")) {
Y$_o$.Q_$2$(jSONObject.getString("razorpay_signature"));
}
if (jSONObject.has("external_wallet")) {
Y$_o$.r$_Y_(jSONObject.getString("external_wallet"));
}
} catch (JSONException e) {
AnalyticsUtil.reportError(e, "error", e.getMessage());
}
}
public static void handleActivityResult(Activity activity, int i, int i2, Intent intent, PaymentResultWithDataListener paymentResultWithDataListener, ExternalWalletListener externalWalletListener) {
Bundle extras;
if (i != 62442) {
return;
}
String string = (intent == null || (extras = intent.getExtras()) == null) ? null : extras.getString("RESULT");
if (i2 == 0) {
string = "Payment Cancelled";
}
R$$r_(activity, string);
Q_$2$(i2, string);
if (i2 == 1) {
try {
paymentResultWithDataListener.onPaymentSuccess(Y$_o$.getPaymentId(), Y$_o$);
return;
} catch (Exception e) {
R$$r_(activity, i2, "threw_error", e);
return;
}
}
if (i2 != 4) {
try {
paymentResultWithDataListener.onPaymentError(i2, string, Y$_o$);
return;
} catch (Exception e2) {
R$$r_(activity, i2, "threw_error", e2);
return;
}
}
if (externalWalletListener != null) {
try {
externalWalletListener.onExternalWalletSelected(Y$_o$.getExternalWallet(), Y$_o$);
} catch (Exception e3) {
R$$r_(activity, i2, "threw_error", e3);
}
}
}
public static void clearUserData(Context context) {
SharedPreferences.Editor R$$r_2 = I$_n_.R$$r_(context);
R$$r_2.putString("rzp_user_contact", null);
R$$r_2.commit();
SharedPreferences.Editor R$$r_3 = I$_n_.R$$r_(context);
R$$r_3.putString("rzp_user_email", null);
R$$r_3.commit();
I$_n_.G__G_(context).putString("rzp_device_token", null).apply();
CookieManager.getInstance().setCookie("https://api.razorpay.com", "razorpay_api_session=");
}
static void d__1_() {
try {
G__G_.stopLoading();
} catch (Exception unused) {
}
G__G_ = null;
}
}