正在查看: St.John's v1.0.9 应用的 OnlinePaymentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 OnlinePaymentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Utility;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class OnlinePaymentActivity extends AppCompatActivity {
private static final String TAG = "com.mcb.stjohnsemschool.activity.OnlinePaymentActivity";
public static Activity myActivity;
private Context context;
private WebView mPaymentView;
private ProgressDialog mProgress;
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_online_payment);
myActivity = this;
this.context = getApplicationContext();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Payment");
String string = getIntent().getExtras().getString("PayOnlineUrl");
WebView webView = (WebView) findViewById(2131364517);
this.mPaymentView = webView;
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.getAllowContentAccess();
settings.setDomStorageEnabled(true);
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
this.context.getSharedPreferences("", 0);
final String str = getString(R.string.payonline_url) + "/OnlinePaymentReceipt_app.aspx";
final String str2 = getString(R.string.payonline_url) + "/OnlinePaymentReceipt_AppCancel.aspx";
this.mProgress = ProgressDialog.show(myActivity, "", "Please wait for a moment...");
this.mPaymentView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView webView2, String str3, Bitmap bitmap) {
super.onPageStarted(webView2, str3, bitmap);
}
@Override
public void onPageFinished(WebView webView2, String str3) {
if (OnlinePaymentActivity.this.mProgress.isShowing()) {
OnlinePaymentActivity.this.mProgress.dismiss();
}
if (str3.toLowerCase().startsWith(str.toLowerCase()) || str3.toLowerCase().startsWith(str2.toLowerCase())) {
OnlinePaymentActivity.this.getTransactionStatus();
}
}
});
this.mPaymentView.loadUrl(string);
this.mPaymentView.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (i != 4 || !OnlinePaymentActivity.this.mPaymentView.canGoBack()) {
return false;
}
OnlinePaymentActivity.this.showAlert();
return true;
}
});
this.mPaymentView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView webView2, String str3, String str4, JsResult jsResult) {
return super.onJsAlert(webView2, str3, str4, jsResult);
}
});
}
public void getTransactionStatus() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
getTransactionStatusByPaymentId();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getTransactionStatusByPaymentId() {
ProgressDialog progressDialog = this.mProgress;
if (progressDialog != null && !progressDialog.isShowing()) {
this.mProgress.show();
}
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getTransactionStatusByPaymentId(getIntent().getExtras().getString("OnlinePaymentId", "0"), Utility.getSchoolApiKey(getApplicationContext())).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (OnlinePaymentActivity.this.mProgress != null && OnlinePaymentActivity.this.mProgress.isShowing()) {
OnlinePaymentActivity.this.mProgress.dismiss();
}
if (response != null && response.body() != null) {
if (((String) response.body()).equalsIgnoreCase("Y")) {
OnlinePaymentActivity.this.showSuccessOrderDialog();
return;
} else {
OnlinePaymentActivity.this.showCancelOrderDialog();
return;
}
}
Utility.showAlertDialog(OnlinePaymentActivity.myActivity);
}
public void onFailure(Call<String> call, Throwable th) {
if (OnlinePaymentActivity.this.mProgress != null && OnlinePaymentActivity.this.mProgress.isShowing()) {
OnlinePaymentActivity.this.mProgress.dismiss();
}
Utility.showAlertDialog(OnlinePaymentActivity.myActivity);
}
});
}
public void showSuccessOrderDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(myActivity, R.style.MyDialogTheme));
builder.setCancelable(false);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
if (SelectPaymentGateWayActivity.mActivityObj != null) {
SelectPaymentGateWayActivity.mActivityObj.finish();
}
OnlinePaymentActivity.this.finish();
}
});
builder.setTitle("Acknowledgement");
builder.setMessage("Dear Parent your payment is successful");
builder.create().show();
}
public void showCancelOrderDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(myActivity, R.style.MyDialogTheme));
builder.setCancelable(false);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
Intent intent = new Intent(OnlinePaymentActivity.this.getApplicationContext(), (Class<?>) TransactionCancelACtivity.class);
intent.putExtra("ToActivity", "feedetails");
intent.putExtra("FromActivity", "PaymentCancel");
OnlinePaymentActivity.this.startActivity(intent);
if (NavigationActivity.mActivityObj != null) {
NavigationActivity.mActivityObj.finish();
}
if (SelectPaymentGateWayActivity.mActivityObj != null) {
SelectPaymentGateWayActivity.mActivityObj.finish();
}
OnlinePaymentActivity.this.finish();
}
});
builder.setTitle("Acknowledgement");
builder.setMessage("Transaction Failed");
builder.create().show();
}
public void showAlert() {
AlertDialog.Builder builder = new AlertDialog.Builder(myActivity);
builder.setMessage("Are you sure you want to cancel transaction?");
builder.setCancelable(false);
builder.setPositiveButton("PROCEED TO PAY", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
OnlinePaymentActivity.this.onBack();
}
});
builder.create().show();
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public void onBackPressed() {
showAlert();
}
public void onBack() {
Intent intent = new Intent(getApplicationContext(), (Class<?>) TransactionCancelACtivity.class);
intent.putExtra("ToActivity", "feedetails");
intent.putExtra("FromActivity", "PaymentCancel");
startActivity(intent);
finish();
}
protected void onResume() {
super.onResume();
String string = getSharedPreferences("", 0).getString("usernamekey", "");
Bundle bundle = new Bundle();
bundle.putString("user_name", string);
FirebaseAnalytics.getInstance(this).logEvent("PAGE_ONLINE_PAYMENT", bundle);
}
}