Browse Source

Catch multi echo messages

hbw_build
Wong Joon Hui 2 years ago
parent
commit
879eda711d
  1. 17
      .idea/deploymentTargetDropDown.xml
  2. 9
      app/src/main/AndroidManifest.xml
  3. 23
      app/src/main/java/com/cst/im30/MainApplication.java
  4. 352
      app/src/main/java/com/cst/im30/PaymentHandler.java
  5. 434
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  6. 6
      app/src/main/java/com/cst/im30/activity/ResponseActivity.java
  7. 1
      app/src/main/java/com/cst/im30/common/Constants.java
  8. 12
      app/src/main/java/com/cst/im30/service/IDVerificationService.java
  9. 12
      app/src/main/java/com/cst/im30/service/PaymentService.java
  10. 2
      app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java
  11. 2
      app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java
  12. 2
      app/src/main/java/com/cst/im30/service/UploadTransactionSalePaymentService.java
  13. 7
      app/src/main/java/com/cst/im30/utility/Logger.java

17
.idea/deploymentTargetDropDown.xml

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="1640011591" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-04-19T01:28:28.927516800Z" />
</component>
</project>

9
app/src/main/AndroidManifest.xml

@ -32,12 +32,17 @@
<activity
android:name="com.cst.im30.activity.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="com.posapp.payactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
@ -47,11 +52,7 @@
android:launchMode="singleTask"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="com.posapp.payactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver

23
app/src/main/java/com/cst/im30/MainApplication.java

@ -39,7 +39,7 @@ public class MainApplication extends Application {
public static boolean paymentIsConnected = false;
public static boolean icIsConnected = false;
public static final int MAX_RETRY = 5;
public static final int MAX_RETRY = 10;
public static int failCountIC = 0;
public static int failCountPayment = 0;
@ -64,26 +64,13 @@ public class MainApplication extends Application {
public static SaleCompletionRequest currentSaleCompletionRequest = null;
public static SaleCompletionResponse currentSaleCompletionResponse = null;
public static String code;
public static String status;
public static MainApplication getInstance() {
return instance;
}
public EchoClient getPaymentClient() {
return paymentClient;
}
public void setPaymentClient(EchoClient paymentClient) {
this.paymentClient = paymentClient;
}
public EchoClient getIcClient() {
return icClient;
}
public void setIcClient(EchoClient icClient) {
this.icClient = icClient;
}
public static void reset() {
working = false;
incomingCode = null;
@ -99,6 +86,8 @@ public class MainApplication extends Application {
currentPreAuthResponse = null;
currentSaleCompletionRequest = null;
currentSaleCompletionResponse = null;
code = null;
status = null;
Logger.logD("RESET");
}

352
app/src/main/java/com/cst/im30/PaymentHandler.java

@ -0,0 +1,352 @@
package com.cst.im30;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.cst.im30.activity.ResponseActivity;
import com.cst.im30.common.Constants;
import com.cst.im30.model.CancelRequest;
import com.cst.im30.model.CancelResponse;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.PreAuthResponse;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleCompletionResponse;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.model.VoidRequest;
import com.cst.im30.model.VoidResponse;
import com.cst.im30.service.UploadTransactionPreAuthPaymentService;
import com.cst.im30.service.UploadTransactionSaleCompletionPaymentService;
import com.cst.im30.service.UploadTransactionSalePaymentService;
import com.cst.im30.utility.Logger;
import com.cst.im30.utility.PaymentUtils;
public class PaymentHandler {
private final Context context;
public PaymentHandler(Context context) {
this.context = context;
}
public void handlePayFunctionSale(EventLogDetailed eventLogDetailed) {
SaleRequest request = PaymentUtils.createSaleRequest(eventLogDetailed);
if (PaymentUtils.validateSaleRequest(request)) {
initSalePayment(request);
} else {
Toast.makeText(context, "Invalid Sale Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Sale Request: " + request.toString());
}
}
public void handlePayFunctionVoid(EventLogDetailed eventLogDetailed) {
VoidRequest request = PaymentUtils.createVoidRequest(eventLogDetailed);
if (PaymentUtils.validateVoidRequest(request)) {
initVoid(request);
} else {
Toast.makeText(context, "Invalid Void Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Void Request: " + request.toString());
}
}
public void handlePayFunctionCancel() {
CancelRequest request = new CancelRequest();
initCancel(request);
}
public void handlePayFunctionPreAuth(EventLogDetailed eventLogDetailed) {
PreAuthRequest request = PaymentUtils.createPreAuthRequest(eventLogDetailed);
if (PaymentUtils.validatePreAuthRequest(request)) {
initPreAuth(request);
} else {
Toast.makeText(context, "Invalid Pre Auth Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Pre Auth Request: " + request.toString());
}
}
public void handlePayFunctionSaleCompletion(EventLogDetailed eventLogDetailed) {
SaleCompletionRequest request = PaymentUtils.createSaleCompletionRequest(eventLogDetailed);
if (PaymentUtils.validateSaleCompletionRequest(request)) {
initSaleCompletion(request);
} else {
Toast.makeText(context, "Invalid Sale Completion Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Sale Completion Request: " + request.toString());
}
}
public void initSalePayment(SaleRequest request) {
Logger.logD("Direct Payment: " + request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_type", request.getPayType());
String payCameraMode = request.getPayCameraMode();
if (payCameraMode != null && !payCameraMode.isEmpty()) {
extra.putString("pay_camera_mode", payCameraMode);
}
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
MainApplication.currentSaleRequest = request;
app2app(extra);
}
public void initVoid(VoidRequest request) {
Logger.logD("Void Payment: " + request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
extra.putString("pay_trace_no", request.getPayTraceNo());
extra.putString("pay_invoice_no", request.getPayInvoiceNo());
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
MainApplication.currentVoidRequest = request;
app2app(extra);
}
public void initCancel(CancelRequest request) {
Logger.logD(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
MainApplication.currentCancelRequest = request;
app2app(extra);
}
public void initPreAuth(PreAuthRequest request) {
Logger.logD(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
MainApplication.currentPreAuthRequest = request;
app2app(extra);
}
public void initSaleCompletion(SaleCompletionRequest request) {
Logger.logD(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_auth_code", request.getPayAuthCode());
extra.putString("pay_ref_num", request.getPayRefNum());
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
extra.putString("token", request.getToken());
MainApplication.currentSaleCompletionRequest = request;
app2app(extra);
}
private void app2app(Bundle bundle) {
Intent intent = new Intent(Constants.APP_2_APP);
intent.putExtras(bundle);
Logger.logD("App2App Call to: " + Constants.APP_2_APP);
context.startActivity(intent);
}
public void handlePayFunctionSaleResponse(Bundle extra) {
SaleResponse response = new SaleResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayCameraMode(extra.getString("pay_camera_mode"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCardAid(extra.getString("pay_resp_card_aid"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespQrTxnId(extra.getString("pay_resp_qr_txn_id"));
response.setPayRespQrWalletId(extra.getString("pay_resp_qr_wallet_id"));
response.setPayRespCustomerId(extra.getString("pay_resp_customer_id"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
response.setPayRespHashPan(extra.getString("pay_resp_hash_pan"));
Logger.logD(response.toString());
MainApplication.currentSaleResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
public void handlePayFunctionVoidResponse(Bundle extra) {
VoidResponse response = new VoidResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespQrTxnId(extra.getString("pay_resp_qr_txn_id"));
response.setPayRespQrWalletId(extra.getString("pay_resp_qr_wallet_id"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCustomerId(extra.getString("pay_resp_customer_id"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
Logger.logD(response.toString());
MainApplication.currentVoidResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
public void handlePayFunctionCancelResponse(Bundle extra) {
CancelResponse response = new CancelResponse();
response.setPayFunction(extra.getString("pay_function"));
response.setPayRespCode(extra.getString("pay_resp_code"));
Logger.logD(response.toString());
MainApplication.currentCancelResponse = response;
}
public void handlePayFunctionPreAuthResponse(Bundle extra) {
PreAuthResponse response = new PreAuthResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCardAid(extra.getString("pay_resp_card_aid"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
response.setPayRespHashPan(extra.getString("pay_resp_hash_pan"));
response.setToken(extra.getString("token"));
Logger.logD(response.toString());
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
MainApplication.currentPreAuthResponse = response;
}
public void handlePayFunctionSaleCompletionResponse(Bundle extra) {
SaleCompletionResponse response = new SaleCompletionResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCardAid(extra.getString("pay_resp_card_aid"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
response.setPayRespHashPan(extra.getString("pay_resp_hash_pan"));
Logger.logD(response.toString());
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
MainApplication.currentSaleCompletionResponse = response;
}
}

434
app/src/main/java/com/cst/im30/activity/MainActivity.java

@ -32,17 +32,26 @@ import androidx.core.content.ContextCompat;
import com.cst.im30.BuildConfig;
import com.cst.im30.EchoClient;
import com.cst.im30.MainApplication;
import com.cst.im30.PaymentHandler;
import com.cst.im30.R;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.common.Constants;
import com.cst.im30.model.CancelRequest;
import com.cst.im30.model.CancelResponse;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.PreAuthResponse;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleCompletionResponse;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.model.VoidRequest;
import com.cst.im30.model.VoidResponse;
import com.cst.im30.service.IDVerificationService;
import com.cst.im30.service.PaymentService;
import com.cst.im30.service.UploadTransactionPreAuthPaymentService;
import com.cst.im30.service.UploadTransactionSaleCompletionPaymentService;
import com.cst.im30.service.UploadTransactionSalePaymentService;
import com.cst.im30.utility.Logger;
import com.cst.im30.utility.PaymentUtils;
import com.daimajia.slider.library.SliderLayout;
@ -75,6 +84,8 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
private SliderLayout sliderLayout;
private PaymentHandler paymentHandler;
ActivityResultLauncher<Intent> icVerificationLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
@ -127,30 +138,24 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
load = findViewById(R.id.loading_image_mt);
//setupTextSlider();
paymentHandler = new PaymentHandler(this);
}
@Override
protected void onResume() {
super.onResume();
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (!MainApplication.icIsConnected) {
initEchoClientIC();
connectEchoClientIC();
}
if (!MainApplication.paymentIsConnected) {
initEchoClientPayment();
connectEchoClientPayment();
String action = intent.getAction();
if (Constants.INTENT_ACTION.equalsIgnoreCase(action)) {
Logger.logD("Received Intent: " + action);
handlePaymentResponse(intent);
return;
}
MainApplication.currentActivity = this;
Intent incomingIntent = getIntent();
String action = incomingIntent.getAction();
if (Constants.INTENT_REFRESH.equalsIgnoreCase(action)) {
String code = incomingIntent.getStringExtra("code");
String status = incomingIntent.getStringExtra("status");
String code = intent.getStringExtra("code");
String status = intent.getStringExtra("status");
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
Logger.logV("VALID - Code: " + code + " | Status: " + status);
@ -163,45 +168,88 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
resetView();
return;
}
if (Constants.INTENT_RESET.equalsIgnoreCase(action)) {
resetView();
}
}
private void showStatusDialog(boolean success, String msg) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
LayoutInflater inflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.pop_up_notification, null);
private void processPaymentResponse() {
String code = MainApplication.code;
String status = MainApplication.status;
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
Logger.logV("VALID - Code: " + code + " | Status: " + status);
String msg = "Payment Successful";
showStatusDialog(true, msg);
} else {
Logger.logV("INVALID - Code: " + code + " | Status: " + status);
String msg = "Payment Failed!" + "\n" + code + "\n" + status;
showStatusDialog(false, msg);
}
}
TextView title = view.findViewById(R.id.title);
ImageView image = view.findViewById(R.id.image);
TextView message = view.findViewById(R.id.message);
private void handlePaymentResponse(Intent intent) {
Bundle extra = intent.getExtras();
if (success) {
title.setText(R.string.success);
image.setImageResource(R.drawable.ic_status_success_fancy);
if (extra == null) {
Logger.logW("Intent.getExtras() is null!");
return;
}
String payFunction = extra.getString("pay_function");
Logger.logV("Pay Function: " + payFunction);
if (Constants.PAY_FUNCTION_SALE.equalsIgnoreCase(payFunction)) {
paymentHandler.handlePayFunctionSaleResponse(extra);
UploadTransactionSalePaymentService service = new UploadTransactionSalePaymentService(this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentSaleRequest, MainApplication.currentSaleResponse);
} else if (Constants.PAY_FUNCTION_VOID.equalsIgnoreCase(payFunction)) {
paymentHandler.handlePayFunctionVoidResponse(extra);
//todo upload void payment?
/*UploadTransactionSalePaymentService service = new UploadTransactionSalePaymentService(this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentVoidRequest, MainApplication.currentSaleResponse);*/
} else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) {
paymentHandler.handlePayFunctionCancelResponse(extra);
resetView();
} else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) {
paymentHandler.handlePayFunctionPreAuthResponse(extra);
UploadTransactionPreAuthPaymentService service = new UploadTransactionPreAuthPaymentService(this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentPreAuthRequest, MainApplication.currentPreAuthResponse);
} else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) {
paymentHandler.handlePayFunctionSaleCompletionResponse(extra);
UploadTransactionSaleCompletionPaymentService service = new UploadTransactionSaleCompletionPaymentService(this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentSaleCompletionRequest, MainApplication.currentSaleCompletionResponse);
} else if (payFunction == null || payFunction.isEmpty()) {
resetView();
} else {
title.setText(R.string.fail);
image.setImageResource(R.drawable.ic_status_fail_fancy);
Logger.logW("Unsupported Pay Function: " + payFunction);
}
message.setText(msg);
}
builder.setCancelable(false);
builder.setView(view);
@Override
protected void onResume() {
super.onResume();
final AlertDialog dlg = builder.create();
Objects.requireNonNull(dlg.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
if (!MainApplication.icIsConnected) {
initEchoClientIC();
connectEchoClientIC();
}
dlg.show();
if (!MainApplication.paymentIsConnected) {
initEchoClientPayment();
connectEchoClientPayment();
}
Handler mHandler = new Handler();
Runnable mRunnable = () -> {
if (dlg.isShowing()) {
dlg.dismiss();
}
};
mHandler.postDelayed(mRunnable,3000);
refreshUI();
MainApplication.currentActivity = this;
}
private void setupTextSlider() {
TextSliderView textSliderView = new TextSliderView(this);
//textSliderView.description("Welcome to XXX.");
@ -254,7 +302,9 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
runOnUiThread(() -> {
//sliderLayout.setVisibility(View.VISIBLE);
testTitle.setVisibility(View.VISIBLE);
animationDrawable.stop();
if (animationDrawable != null) {
animationDrawable.stop();
}
load.setVisibility(View.GONE);
echoStatusLayout.setVisibility(View.VISIBLE);
@ -271,21 +321,21 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
assert !payFunction.isEmpty();
if (Constants.PAY_FUNCTION_SALE.equalsIgnoreCase(payFunction)) {
handlePayFunctionSale(eventLogDetailed);
paymentHandler.handlePayFunctionSale(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_VOID.equalsIgnoreCase(payFunction)) {
handlePayFunctionVoid(eventLogDetailed);
paymentHandler.handlePayFunctionVoid(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_INQUIRY.equalsIgnoreCase(payFunction)) {
//handlePayFunctionPreAuth(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) {
handlePayFunctionCancel();
paymentHandler.handlePayFunctionCancel();
} else if (Constants.PAY_FUNCTION_SETTLEMENT.equalsIgnoreCase(payFunction)) {
//handlePayFunctionPreAuth(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_SET_DATE_TIME.equalsIgnoreCase(payFunction)) {
//handlePayFunctionPreAuth(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) {
handlePayFunctionPreAuth(eventLogDetailed);
paymentHandler.handlePayFunctionPreAuth(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) {
handlePayFunctionSaleCompletion(eventLogDetailed);
paymentHandler.handlePayFunctionSaleCompletion(eventLogDetailed);
} else {
String msg = "Unsupported Pay Function: " + payFunction;
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
@ -294,50 +344,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
}
private void handlePayFunctionSale(EventLogDetailed eventLogDetailed) {
SaleRequest request = PaymentUtils.createSaleRequest(eventLogDetailed);
if (PaymentUtils.validateSaleRequest(request)) {
initSalePayment(request);
} else {
Toast.makeText(MainActivity.this, "Invalid Sale Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Sale Request: " + request.toString());
}
}
private void handlePayFunctionVoid(EventLogDetailed eventLogDetailed) {
VoidRequest request = PaymentUtils.createVoidRequest(eventLogDetailed);
if (PaymentUtils.validateVoidRequest(request)) {
initVoid(request);
} else {
Toast.makeText(MainActivity.this, "Invalid Void Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Void Request: " + request.toString());
}
}
private void handlePayFunctionCancel() {
CancelRequest request = new CancelRequest();
initCancel(request);
}
private void handlePayFunctionPreAuth(EventLogDetailed eventLogDetailed) {
PreAuthRequest request = PaymentUtils.createPreAuthRequest(eventLogDetailed);
if (PaymentUtils.validatePreAuthRequest(request)) {
initPreAuth(request);
} else {
Toast.makeText(MainActivity.this, "Invalid Pre Auth Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Pre Auth Request: " + request.toString());
}
}
private void handlePayFunctionSaleCompletion(EventLogDetailed eventLogDetailed) {
SaleCompletionRequest request = PaymentUtils.createSaleCompletionRequest(eventLogDetailed);
if (PaymentUtils.validateSaleCompletionRequest(request)) {
initSaleCompletion(request);
} else {
Toast.makeText(MainActivity.this, "Invalid Sale Completion Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Sale Completion Request: " + request.toString());
}
}
private void receiveMessagePayment(Object... args) {
Logger.logD("Received Payment Message");
@ -381,6 +388,9 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
public void callBack(String source, Object object) {
Logger.logD(source);
String code = MainApplication.code;
String status = MainApplication.status;
// NRIC
if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_GET_EVENT_LOG)) {
EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object;
@ -394,9 +404,11 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
} else {
if (MainApplication.working) {
Logger.logE("Received IC Verification Message but IM30 is currently working!");
IDVerificationService service = new IDVerificationService(this);
service.verifyReject(MainApplication.incomingCode);
if (!MainApplication.incomingCode.equals(MainApplication.currentCode)) {
Logger.logE("Received IC Verification Message but IM30 is currently working!");
IDVerificationService service = new IDVerificationService(this);
service.verifyReject(MainApplication.incomingCode);
}
} else {
startWork();
MainApplication.currentCode = MainApplication.incomingCode;
@ -426,9 +438,11 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
paymentProcess(MainApplication.currentEventLogDetailed);
} else {
if (MainApplication.working) {
Logger.logE("Received Payment Message but IM30 is currently working!");
PaymentService service = new PaymentService(this);
service.verifyReject(MainApplication.incomingCode);
if (!MainApplication.incomingCode.equals(MainApplication.currentCode)) {
Logger.logE("Received Payment Message but IM30 is currently working!");
PaymentService service = new PaymentService(this);
service.verifyReject(MainApplication.incomingCode);
}
} else {
startWork();
MainApplication.currentCode = MainApplication.incomingCode;
@ -447,11 +461,60 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
else if (source.equalsIgnoreCase(IDVerificationService.REJECT_EVENT_LOG)) {
String code = (String) object;
Logger.logI("Rejected Broadcast: " + code);
String codeReject = (String) object;
Logger.logI("Rejected Broadcast: " + codeReject);
MainApplication.incomingCode = null;
} else if (source.equalsIgnoreCase(PaymentService.REJECT_EVENT_LOG)) {
String code = (String) object;
Logger.logI("Rejected Broadcast: " + code);
String codeReject = (String) object;
Logger.logI("Rejected Broadcast: " + codeReject);
MainApplication.incomingCode = null;
}
// Payment Response
else if (UploadTransactionSalePaymentService.SUCCESS.equalsIgnoreCase(source)) {
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
PaymentService service = new PaymentService(this);
service.verifySuccess(MainApplication.currentCode);
} else {
PaymentService service = new PaymentService(this);
service.verifyFail(MainApplication.currentCode);
}
} else if (UploadTransactionPreAuthPaymentService.SUCCESS.equalsIgnoreCase(source)) {
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
PaymentService service = new PaymentService(this);
service.verifySuccess(MainApplication.currentCode);
} else {
PaymentService service = new PaymentService(this);
service.verifyFail(MainApplication.currentCode);
}
} else if (UploadTransactionSaleCompletionPaymentService.SUCCESS.equalsIgnoreCase(source)) {
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
PaymentService service = new PaymentService(this);
service.verifySuccess(MainApplication.currentCode);
} else {
PaymentService service = new PaymentService(this);
service.verifyFail(MainApplication.currentCode);
}
}
else if (UploadTransactionSalePaymentService.FAIL.equalsIgnoreCase(source)) {
PaymentService service = new PaymentService(this);
service.verifyFail(MainApplication.currentCode);
} else if (UploadTransactionPreAuthPaymentService.FAIL.equalsIgnoreCase(source)) {
PaymentService service = new PaymentService(this);
service.verifyFail(MainApplication.currentCode);
} else if (UploadTransactionSaleCompletionPaymentService.FAIL.equalsIgnoreCase(source)) {
PaymentService service = new PaymentService(this);
service.verifyFail(MainApplication.currentCode);
}
else if (PaymentService.SUCCESS_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) {
processPaymentResponse();
resetView();
} else if (PaymentService.FAIL_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) {
processPaymentResponse();
resetView();
}
}
@ -502,112 +565,9 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
// --- PAYMENT ---------------------------------------------------------------------------------
private void initSalePayment(SaleRequest request) {
Logger.logD("Direct Payment: " + request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_type", request.getPayType());
String payCameraMode = request.getPayCameraMode();
if (payCameraMode != null && !payCameraMode.isEmpty()) {
extra.putString("pay_camera_mode", payCameraMode);
}
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
MainApplication.currentSaleRequest = request;
app2app(extra);
}
private void initVoid(VoidRequest request) {
Logger.logD("Void Payment: " + request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
extra.putString("pay_trace_no", request.getPayTraceNo());
extra.putString("pay_invoice_no", request.getPayInvoiceNo());
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
MainApplication.currentVoidRequest = request;
app2app(extra);
}
private void initCancel(CancelRequest request) {
Logger.logD(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
MainApplication.currentCancelRequest = request;
app2app(extra);
}
private void initPreAuth(PreAuthRequest request) {
Logger.logD(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
MainApplication.currentPreAuthRequest = request;
app2app(extra);
}
private void initSaleCompletion(SaleCompletionRequest request) {
Logger.logD(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_auth_code", request.getPayAuthCode());
extra.putString("pay_ref_num", request.getPayRefNum());
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
extra.putString("token", request.getToken());
MainApplication.currentSaleCompletionRequest = request;
app2app(extra);
}
private void app2app(Bundle bundle) {
Intent intent = new Intent(Constants.APP_2_APP);
intent.putExtras(bundle);
Logger.logD("App2App Call to: " + Constants.APP_2_APP);
startActivity(intent);
}
// --- MISC ------------------------------------------------------------------------------------
@ -630,10 +590,12 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
private void connectEchoClientIC() {
if (MainApplication.icIsConnected) { return; }
MainApplication.icClient.connect(this::onConnectSuccessIC, this::onConnectFailureIC);
}
private void connectEchoClientPayment() {
if (MainApplication.paymentIsConnected) { return; }
MainApplication.paymentClient.connect(this::onConnectSuccessPayment, this::onConnectFailurePayment);
}
@ -670,13 +632,14 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
MainApplication.paymentIsConnected = false;
if (MainApplication.failCountIC == 0) {
Logger.logW("Failed To Connect to Payment Socket. Retrying up to " + MainApplication.MAX_RETRY + " times");
refreshUI();
}
MainApplication.failCountPayment++;
if (MainApplication.failCountPayment >= MainApplication.MAX_RETRY) {
/*if (MainApplication.failCountPayment >= MainApplication.MAX_RETRY) {
Logger.logE("Payment Echo Connection Failed More than " + MainApplication.MAX_RETRY + " times! Restarting app...");
ProcessPhoenix.triggerRebirth(MainActivity.this);
}
}*/
updatePaymentOffline();
}
@ -701,18 +664,33 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
private void onConnectFailureIC(Object[] args) {
MainApplication.icIsConnected = false;
if (MainApplication.failCountIC == 0) {
Logger.logW("Failed To Connect toIC Socket. Retrying up to " + MainApplication.MAX_RETRY + " times");
Logger.logW("Failed To Connect to IC Socket. Retrying up to " + MainApplication.MAX_RETRY + " times");
refreshUI();
}
MainApplication.failCountIC++;
if (MainApplication.failCountIC >= MainApplication.MAX_RETRY) {
/*if (MainApplication.failCountIC >= MainApplication.MAX_RETRY) {
Logger.logE("IC Echo Connection Failed More than " + MainApplication.MAX_RETRY + " times! Restarting app...");
ProcessPhoenix.triggerRebirth(MainActivity.this);
}
}*/
updateICOffline();
}
private void refreshUI() {
if (MainApplication.paymentClient.isConnected()) {
updatePaymentOnline();
} else {
updatePaymentOffline();
}
if (MainApplication.icClient.isConnected()) {
updateICOnline();
} else {
updateICOffline();
}
}
private void updatePaymentOnline() {
runOnUiThread(() -> {
paymentEchoStatusImageView.setImageResource(R.drawable.echo_payment_online);
@ -778,6 +756,42 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
}
private void showStatusDialog(boolean success, String msg) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
LayoutInflater inflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.pop_up_notification, null);
TextView title = view.findViewById(R.id.title);
ImageView image = view.findViewById(R.id.image);
TextView message = view.findViewById(R.id.message);
if (success) {
title.setText(R.string.success);
image.setImageResource(R.drawable.ic_status_success_fancy);
} else {
title.setText(R.string.fail);
image.setImageResource(R.drawable.ic_status_fail_fancy);
}
message.setText(msg);
builder.setCancelable(false);
builder.setView(view);
final AlertDialog dlg = builder.create();
Objects.requireNonNull(dlg.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dlg.show();
Handler mHandler = new Handler();
Runnable mRunnable = () -> {
if (dlg.isShowing()) {
dlg.dismiss();
}
};
mHandler.postDelayed(mRunnable,3000);
}
/*private void setupCloudWatch() {
String accessKey = "";
String secretKey = "";

6
app/src/main/java/com/cst/im30/activity/ResponseActivity.java

@ -315,17 +315,21 @@ public class ResponseActivity extends AppCompatActivity implements CallableInter
Intent intent = new Intent(ResponseActivity.this, MainActivity.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
if (showResult) {
intent.setAction(Constants.INTENT_REFRESH);
intent.putExtra("code", code);
intent.putExtra("status", status);
} else {
intent.setAction(Constants.INTENT_RESET);
}
startActivity(intent);
Logger.logV("Going back to MainActivity");
finishAffinity();
}
private String resolveStatus(String payRespErrorDesc) {

1
app/src/main/java/com/cst/im30/common/Constants.java

@ -5,6 +5,7 @@ public class Constants {
public static final String APP_2_APP = "com.revenue.edc.hlb.pro.app2app";
public static final String INTENT_ACTION = "com.posapp.payactivity";
public static final String INTENT_REFRESH = "refresh";
public static final String INTENT_RESET = "reset";
public static final String IC_FUNCTION_VERIFY = "verify";
public static final String IC_FUNCTION_CANCEL = "cancel";

12
app/src/main/java/com/cst/im30/service/IDVerificationService.java

@ -48,7 +48,7 @@ public class IDVerificationService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.getBroadcastEventLogDetails(clientId, clientSecret, code);
Logger.logV(code);
Logger.logAPI(code);
call.enqueue(new Callback<String>() {
@ -70,12 +70,12 @@ public class IDVerificationService {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_GET_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
EventLogDetailed eventLogDetailed = this.parseGetEventLogResponse(responseJSON);
callback.callBack(SUCCESS_GET_EVENT_LOG, eventLogDetailed);
}
@ -109,7 +109,7 @@ public class IDVerificationService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.updateBroadcastEventLogDetails(clientId, clientSecret, payload.toString(), code);
Logger.logV("Update: " + code + ":" + payload.toString());
Logger.logAPI("Update: " + code + ":" + payload.toString());
call.enqueue(new Callback<String>() {
@ -132,13 +132,13 @@ public class IDVerificationService {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
if (Constants.STATUS_REJECT.equalsIgnoreCase(status)) {
callback.callBack(REJECT_EVENT_LOG, code);

12
app/src/main/java/com/cst/im30/service/PaymentService.java

@ -49,7 +49,7 @@ public class PaymentService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.getBroadcastEventLogDetails(clientId, clientSecret, code);
Logger.logV(code);
Logger.logAPI(code);
call.enqueue(new Callback<String>() {
@ -71,12 +71,12 @@ public class PaymentService {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_GET_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
EventLogDetailed eventLogDetailed = this.parseGetEventLogResponse(responseJSON);
callback.callBack(SUCCESS_GET_EVENT_LOG, eventLogDetailed);
}
@ -110,7 +110,7 @@ public class PaymentService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.updateBroadcastEventLogDetails(clientId, clientSecret, payload.toString(), code);
Logger.logV("Update: " + code + ":" + payload.toString());
Logger.logAPI("Update: " + code + ":" + payload.toString());
call.enqueue(new Callback<String>() {
@ -132,13 +132,13 @@ public class PaymentService {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
Logger.logAPI(responseJSON.toString());
if (Constants.STATUS_REJECT.equalsIgnoreCase(status)) {
callback.callBack(REJECT_EVENT_LOG, code);

2
app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java

@ -53,7 +53,7 @@ public class UploadTransactionPreAuthPaymentService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.uploadRevPayTransaction(clientId, clientSecret, payload.toString());
Logger.logD(payload.toString());
Logger.logAPI(payload.toString());
call.enqueue(new Callback<String>() {
@Override

2
app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java

@ -53,7 +53,7 @@ public class UploadTransactionSaleCompletionPaymentService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.uploadRevPayTransaction(clientId, clientSecret, payload.toString());
Logger.logD(payload.toString());
Logger.logAPI(payload.toString());
call.enqueue(new Callback<String>() {
@Override

2
app/src/main/java/com/cst/im30/service/UploadTransactionSalePaymentService.java

@ -51,7 +51,7 @@ public class UploadTransactionSalePaymentService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.uploadRevPayTransaction(clientId, clientSecret, payload.toString());
Logger.logD(payload.toString());
Logger.logAPI(payload.toString());
call.enqueue(new Callback<String>() {
@Override

7
app/src/main/java/com/cst/im30/utility/Logger.java

@ -38,6 +38,13 @@ public class Logger {
Bugfender.t("VERBOSE", title + " - " + message);
}
public static void logAPI(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();
Log.v(TAG, title + " - " + message);
Bugfender.t("API", title + " - " + message);
}
public static void logE(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();

Loading…
Cancel
Save