正在查看: Housing v14.7.8 应用的 RazorpayPaymentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Housing v14.7.8 应用的 RazorpayPaymentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.razorpay.rn;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.RelativeLayout;
import com.newrelic.agent.android.api.v2.TraceFieldInterface;
import com.newrelic.agent.android.background.ApplicationStateMonitor;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.JSONObjectInstrumentation;
import com.newrelic.agent.android.instrumentation.LogInstrumentation;
import com.newrelic.agent.android.tracing.Trace;
import com.newrelic.agent.android.tracing.TraceMachine;
import com.razorpay.PaymentData;
import com.razorpay.PaymentResultWithDataListener;
import com.razorpay.Razorpay;
import java.util.ArrayList;
import org.json.JSONObject;
@Instrumented
public class RazorpayPaymentActivity extends Activity implements PaymentResultWithDataListener, TraceFieldInterface {
public static final int RZP_REQUEST_CODE = 62442;
public static final int RZP_RESULT_CODE = 62443;
public static final int RZP_UNKNOWN_ERROR_CODE = 6;
public static final int RZP_USER_BACK_PRESSED_ERROR_CODE = 5;
private static final String TAG = "RazorpayPaymentActivity";
public Trace _nr_trace;
private JSONObject payload;
private Razorpay razorpay;
private WebView webview;
private void createWebView() {
ViewGroup viewGroup = (ViewGroup) findViewById(android.R.id.content);
WebView webView = new WebView(this);
this.webview = webView;
webView.setScrollContainer(false);
this.webview.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
viewGroup.addView(this.webview);
this.razorpay.setWebView(this.webview);
}
private String getAndRemoveKeyFromOptions(JSONObject jSONObject) {
try {
if (!jSONObject.has(Constants.KEY_ID)) {
return null;
}
String string = jSONObject.getString(Constants.KEY_ID);
jSONObject.remove(Constants.KEY_ID);
return string;
} catch (Exception unused) {
return null;
}
}
private void initRazorpay() {
String andRemoveKeyFromOptions = getAndRemoveKeyFromOptions(this.payload);
if (andRemoveKeyFromOptions == null) {
this.razorpay = new Razorpay(this);
} else {
this.razorpay = new Razorpay(this, andRemoveKeyFromOptions);
}
}
public void returnErrorCallback(int i, String str, PaymentData paymentData) {
Intent intent = new Intent();
intent.putExtra(Constants.IS_SUCCESS, false);
intent.putExtra(Constants.ERROR_CODE, i);
intent.putExtra(Constants.ERROR_MESSAGE, str);
JSONObject data = paymentData.getData();
intent.putExtra(Constants.PAYMENT_DATA, data == null ? data.toString() : JSONObjectInstrumentation.toString(data));
setResult(RZP_RESULT_CODE, intent);
finish();
}
private void returnSuccessCallback(String str, PaymentData paymentData) {
Intent intent = new Intent();
intent.putExtra(Constants.IS_SUCCESS, true);
intent.putExtra(Constants.PAYMENT_ID, str);
JSONObject data = paymentData.getData();
intent.putExtra(Constants.PAYMENT_DATA, data == null ? data.toString() : JSONObjectInstrumentation.toString(data));
setResult(RZP_RESULT_CODE, intent);
finish();
}
private void sendRequest() {
try {
this.razorpay.submit(this.payload, this);
} catch (Exception e) {
LogInstrumentation.e(TAG, "Failed to submit.", e);
returnErrorCallback(6, "Failed to submit.", new PaymentData());
}
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
Razorpay razorpay = this.razorpay;
if (razorpay != null) {
razorpay.onActivityResult(i, i2, intent);
}
}
@Override
public void onBackPressed() {
new AlertDialog.Builder(this).setMessage(Constants.BACK_ALERT_MESSAGE).setPositiveButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}).setNegativeButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
RazorpayPaymentActivity.this.razorpay.onBackPressed();
RazorpayPaymentActivity.this.returnErrorCallback(5, "User pressed back button", new PaymentData());
}
}).show();
}
@Override
public void onCreate(Bundle bundle) {
TraceMachine.startTracing(TAG);
try {
TraceMachine.enterMethod(this._nr_trace, "RazorpayPaymentActivity#onCreate", (ArrayList) null);
} catch (NoSuchFieldError unused) {
TraceMachine.enterMethod((Trace) null, "RazorpayPaymentActivity#onCreate", (ArrayList) null);
}
super.onCreate(bundle);
try {
this.payload = new JSONObject(getIntent().getExtras().getString(Constants.OPTIONS));
} catch (Exception unused2) {
}
initRazorpay();
createWebView();
sendRequest();
TraceMachine.exitMethod();
}
@Override
public void onPaymentError(int i, String str, PaymentData paymentData) {
returnErrorCallback(i, str, paymentData);
}
@Override
public void onPaymentSuccess(String str, PaymentData paymentData) {
returnSuccessCallback(str, paymentData);
}
@Override
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
Razorpay razorpay = this.razorpay;
if (razorpay != null) {
razorpay.onRequestPermissionsResult(i, strArr, iArr);
}
}
@Override
public void onStart() {
super.onStart();
ApplicationStateMonitor.getInstance().activityStarted();
}
@Override
public void onStop() {
super.onStop();
ApplicationStateMonitor.getInstance().activityStopped();
}
}