Browse Source

Accept IC Cancel

hbw_build
Wong Joon Hui 3 years ago
parent
commit
ba1b0ad51b
  1. 4
      app/src/main/java/com/cst/im30/MainApplication.java
  2. 9
      app/src/main/java/com/cst/im30/activity/ICCActivity.java
  3. 32
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  4. 3
      app/src/main/java/com/cst/im30/common/Constants.java
  5. 2
      app/src/main/java/com/cst/im30/model/EventLogDetailed.java
  6. 2
      app/src/main/java/com/cst/im30/service/IDVerificationService.java

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

@ -10,6 +10,8 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.activity.MainActivity; import com.cst.im30.activity.MainActivity;
import com.cst.im30.model.CancelRequest; import com.cst.im30.model.CancelRequest;
import com.cst.im30.model.CancelResponse; import com.cst.im30.model.CancelResponse;
@ -28,6 +30,8 @@ public class MainApplication extends Application {
public static MainApplication instance; public static MainApplication instance;
public static AppCompatActivity currentActivity;
public static boolean working = false; public static boolean working = false;
public static String incomingCode = null; public static String incomingCode = null;

9
app/src/main/java/com/cst/im30/activity/ICCActivity.java

@ -20,6 +20,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.MainApplication;
import com.cst.im30.R; import com.cst.im30.R;
import com.cst.im30.utility.IccTester; import com.cst.im30.utility.IccTester;
import com.cst.im30.utility.Logger; import com.cst.im30.utility.Logger;
@ -280,7 +281,7 @@ public class ICCActivity extends AppCompatActivity {
insertCard(); insertCard();
} }
private void cancel() { public void cancel() {
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
finish(); finish();
} }
@ -527,4 +528,10 @@ public class ICCActivity extends AppCompatActivity {
} }
} }
@Override
protected void onResume() {
super.onResume();
MainApplication.currentActivity = this;
}
} }

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

@ -10,6 +10,7 @@ import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
@ -113,6 +114,8 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
MainApplication.currentActivity = this;
Intent incomingIntent = getIntent(); Intent incomingIntent = getIntent();
String action = incomingIntent.getAction(); String action = incomingIntent.getAction();
if (Constants.INTENT_REFRESH.equalsIgnoreCase(action)) { if (Constants.INTENT_REFRESH.equalsIgnoreCase(action)) {
@ -316,7 +319,6 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
PaymentService service = new PaymentService(this); PaymentService service = new PaymentService(this);
service.getEventLog(MainApplication.incomingCode); service.getEventLog(MainApplication.incomingCode);
} }
} }
private void receiveMessageIC(Object... args) { private void receiveMessageIC(Object... args) {
@ -331,16 +333,6 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
e.printStackTrace(); e.printStackTrace();
} }
// todo adapt for cancel on kiosk / polling
if (MainApplication.working) {
Logger.logE("Received IC Verification Message but IM30 is currently working!");
IDVerificationService service = new IDVerificationService(this);
service.verifyReject(MainApplication.incomingCode);
return;
} else {
startWork();
}
if (MainApplication.incomingCode != null && !MainApplication.incomingCode.isEmpty()) { if (MainApplication.incomingCode != null && !MainApplication.incomingCode.isEmpty()) {
initViews(); initViews();
IDVerificationService service = new IDVerificationService(this); IDVerificationService service = new IDVerificationService(this);
@ -354,10 +346,26 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
// NRIC // NRIC
if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_GET_EVENT_LOG)) { if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_GET_EVENT_LOG)) {
EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object;
boolean cancelAction = incomingEventLogDetailed.getAction().equalsIgnoreCase(Constants.IC_FUNCTION_CANCEL);
if (cancelAction) {
if (MainApplication.working && MainApplication.currentActivity instanceof ICCActivity) {
((ICCActivity) MainApplication.currentActivity).cancel();
}
} else {
if (MainApplication.working) {
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; MainApplication.currentCode = MainApplication.incomingCode;
MainApplication.currentEventLogDetailed = (EventLogDetailed) object; MainApplication.currentEventLogDetailed = incomingEventLogDetailed;
Intent i = new Intent(MainActivity.this, ICCActivity.class); Intent i = new Intent(MainActivity.this, ICCActivity.class);
icVerificationLauncher.launch(i); icVerificationLauncher.launch(i);
}
}
} else if (source.equalsIgnoreCase(IDVerificationService.FAIL_GET_EVENT_LOG)) { } else if (source.equalsIgnoreCase(IDVerificationService.FAIL_GET_EVENT_LOG)) {
resetView(); //todo try again? fail? resetView(); //todo try again? fail?
} }

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

@ -6,6 +6,9 @@ public class Constants {
public static final String INTENT_ACTION = "com.posapp.payactivity"; public static final String INTENT_ACTION = "com.posapp.payactivity";
public static final String INTENT_REFRESH = "refresh"; public static final String INTENT_REFRESH = "refresh";
public static final String IC_FUNCTION_VERIFY = "verify";
public static final String IC_FUNCTION_CANCEL = "cancel";
public static final String PAY_FUNCTION_SALE = "01"; public static final String PAY_FUNCTION_SALE = "01";
public static final String PAY_FUNCTION_VOID = "02"; public static final String PAY_FUNCTION_VOID = "02";
public static final String PAY_FUNCTION_INQUIRY = "03"; public static final String PAY_FUNCTION_INQUIRY = "03";

2
app/src/main/java/com/cst/im30/model/EventLogDetailed.java

@ -14,7 +14,7 @@ public class EventLogDetailed implements Serializable {
private String remark; private String remark;
// IC Verification // IC Verification
private String documentType, documentNumber, firstName, lastName; private String documentType, documentNumber, firstName, lastName, action;
// Payment / Pre Auth / Sale Completion // Payment / Pre Auth / Sale Completion
private String payableAmount, payFunction, confirmationNumber, referenceNumber; private String payableAmount, payFunction, confirmationNumber, referenceNumber;

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

@ -179,12 +179,14 @@ public class IDVerificationService {
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception { private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception {
String type = jsonObject.getJSONObject("data").getString("type"); String type = jsonObject.getJSONObject("data").getString("type");
String status = jsonObject.getJSONObject("data").getString("status"); String status = jsonObject.getJSONObject("data").getString("status");
String action = jsonObject.getJSONObject("data").getString("action");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type"); String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number"); String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number");
String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name"); String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name");
String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name"); String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name");
EventLogDetailed eventLogDetailed = new EventLogDetailed(); EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setAction(action);
eventLogDetailed.setType(type); eventLogDetailed.setType(type);
eventLogDetailed.setStatus(status); eventLogDetailed.setStatus(status);
eventLogDetailed.setDocumentType(documentType); eventLogDetailed.setDocumentType(documentType);

Loading…
Cancel
Save