Browse Source

Update

hbw_build
Wong Joon Hui 2 years ago
parent
commit
39e6da812a
  1. 6
      .idea/misc.xml
  2. 17
      app/build.gradle
  3. 70
      app/src/main/java/com/cst/im30/MainApplication.java
  4. 14
      app/src/main/java/com/cst/im30/activity/ICCActivity.java
  5. 519
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  6. 450
      app/src/main/java/com/cst/im30/activity/ResponseActivity.java
  7. 8
      app/src/main/java/com/cst/im30/activity/SettingActivity.java
  8. 27
      app/src/main/java/com/cst/im30/activity/StatusActivity.java
  9. 29
      app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java
  10. 2
      app/src/main/java/com/cst/im30/api/RetrofitClient.java
  11. 2
      app/src/main/java/com/cst/im30/common/CallableInterface.java
  12. 39
      app/src/main/java/com/cst/im30/common/Constants.java
  13. 15
      app/src/main/java/com/cst/im30/model/EventLogDetailed.java
  14. 23
      app/src/main/java/com/cst/im30/model/PreAuthRequest.java
  15. 37
      app/src/main/java/com/cst/im30/model/PreAuthResponse.java
  16. 31
      app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java
  17. 36
      app/src/main/java/com/cst/im30/model/SaleCompletionResponse.java
  18. 28
      app/src/main/java/com/cst/im30/model/SaleRequest.java
  19. 40
      app/src/main/java/com/cst/im30/model/SaleResponse.java
  20. 165
      app/src/main/java/com/cst/im30/service/IDVerificationService.java
  21. 188
      app/src/main/java/com/cst/im30/service/PaymentService.java
  22. 156
      app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java
  23. 158
      app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java
  24. 159
      app/src/main/java/com/cst/im30/service/UploadTransactionSalePaymentService.java
  25. 42
      app/src/main/java/com/cst/im30/utility/JsonUtils.java
  26. 31
      app/src/main/java/com/cst/im30/utility/Logger.java
  27. 122
      app/src/main/java/com/cst/im30/utility/PaymentUtils.java
  28. 35
      app/src/main/res/layout/activity_main.xml
  29. 252
      app/src/main/res/layout/activity_response.xml
  30. 53
      app/src/main/res/layout/pop_up_notification.xml
  31. 2
      app/src/main/res/values/strings.xml
  32. 22
      gradle.properties

6
.idea/misc.xml

@ -3,7 +3,13 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/activity_icc.xml" value="0.19739583333333333" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/activity_main.xml" value="0.3546875" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/activity_response.xml" value="0.19739583333333333" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/activity_status.xml" value="0.3546875" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/pop_up_message_no_option.xml" value="0.3546875" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/pop_up_message_option.xml" value="0.3546875" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/pop_up_notification.xml" value="0.3546875" />
</map>
</option>
</component>

17
app/build.gradle

@ -14,6 +14,23 @@ android {
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "SERVER_URL", SERVER_URL)
buildConfigField("String", "CLIENT_ID", CLIENT_ID)
buildConfigField("String", "CLIENT_SECRET", CLIENT_SECRET)
buildConfigField("String", "ECHO_SERVER_URL", ECHO_SERVER_URL)
buildConfigField("String", "ECHO_SERVER_PORT", ECHO_SERVER_PORT)
buildConfigField("String", "KIOSK_CODE", KIOSK_CODE)
buildConfigField("String", "SOCKET_PREFIX", SOCKET_PREFIX)
buildConfigField("String", "PAYMENT_CHANNEL_ID", PAYMENT_CHANNEL_ID)
buildConfigField("String", "PAYMENT_EVENT_TYPE", PAYMENT_EVENT_TYPE)
buildConfigField("String", "IC_CHANNEL_ID", IC_CHANNEL_ID)
buildConfigField("String", "IC_EVENT_TYPE", IC_EVENT_TYPE)
}
buildTypes {

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

@ -1,10 +1,58 @@
package com.cst.im30;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.Application;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.cst.im30.activity.MainActivity;
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;
public class MainApplication extends Application {
public static MainApplication instance;
public static boolean working = false;
public static String currentCode = null;
public static EventLogDetailed currentEventLogDetailed = null;
public static SaleRequest currentSaleRequest = null;
public static SaleResponse currentSaleResponse = null;
public static PreAuthRequest currentPreAuthRequest = null;
public static PreAuthResponse currentPreAuthResponse = null;
public static SaleCompletionRequest currentSaleCompletionRequest = null;
public static SaleCompletionResponse currentSaleCompletionResponse = null;
public static MainApplication getInstance() {
return instance;
}
public static void reset() {
working = false;
currentCode = null;
currentEventLogDetailed = null;
currentSaleRequest = null;
currentSaleResponse = null;
currentPreAuthRequest = null;
currentPreAuthResponse = null;
currentSaleCompletionRequest = null;
currentSaleCompletionResponse = null;
}
@Override
public void onCreate() {
super.onCreate();
@ -18,8 +66,26 @@ public class MainApplication extends Application {
public void handleUncaughtException(Thread thread, Throwable e) {
if (e instanceof Exception) {
Log.e("CST-DBG", "Exception: " + Log.getStackTraceString(e));
System.out.println();
Log.e("CST", "Exception: " + Log.getStackTraceString(e));
}
if (isUIThread()) { // exception occurred from UI thread
restartApp();
} else { //handle non UI thread throw uncaught exception
new Handler(Looper.getMainLooper()).post(this::restartApp);
}
}
private boolean isUIThread() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
@SuppressLint("UnspecifiedImmutableFlag")
private void restartApp() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(MainApplication.getInstance().getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) MainApplication.getInstance().getApplicationContext().getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent);
System.exit(2);
}
}

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

@ -13,6 +13,7 @@ import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.Nullable;
@ -21,6 +22,7 @@ import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.R;
import com.cst.im30.utility.IccTester;
import com.cst.im30.utility.Logger;
import java.io.BufferedWriter;
import java.io.File;
@ -44,6 +46,8 @@ public class ICCActivity extends AppCompatActivity {
private String name;
private String cardNo;
private AlertDialog alertDialogPromptCard;
private Button buttonCancel;
@SuppressLint("HandlerLeak")
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
@ -172,7 +176,7 @@ public class ICCActivity extends AppCompatActivity {
outgoingIntent.putExtra("name", name);
outgoingIntent.putExtra("cardNo", cardNo);
Log.d(MainActivity.TAG, name + ":" + cardNo);
Logger.logD(name + ":" + cardNo);
setResult(RESULT_OK, outgoingIntent);
finish();
@ -264,6 +268,9 @@ public class ICCActivity extends AppCompatActivity {
setContentView(R.layout.activity_icc);
setTitle("Read Card");
buttonCancel = findViewById(R.id.button_cancel);
buttonCancel.setOnClickListener(v -> cancel());
name = "";
cardNo = "";
@ -272,6 +279,11 @@ public class ICCActivity extends AppCompatActivity {
insertCard();
}
private void cancel() {
setResult(RESULT_CANCELED);
finish();
}
@Override
public void finish() {
stopChecking = true;

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

@ -1,12 +1,16 @@
package com.cst.im30.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@ -16,13 +20,20 @@ import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.BuildConfig;
import com.cst.im30.EchoClient;
import com.cst.im30.MainApplication;
import com.cst.im30.R;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.common.Constants;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.service.IDVerificationService;
import com.cst.im30.service.PaymentService;
import com.cst.im30.utility.Logger;
import com.cst.im30.utility.PaymentUtils;
import com.daimajia.slider.library.SliderLayout;
import com.daimajia.slider.library.SliderTypes.BaseSliderView;
import com.daimajia.slider.library.SliderTypes.TextSliderView;
@ -32,32 +43,29 @@ import net.mrbin99.laravelechoandroid.EchoCallback;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Objects;
import java.util.regex.Pattern;
public class MainActivity extends AppCompatActivity implements CallableInterface {
public static final String TAG = "MainActivity.";
//Set value to get temp value-RefNum
private static String value;
//Set value to get temp value-Amount
private static String values;
ImageView load;
AnimationDrawable animationDrawable;
private EchoClient paymentClient;
private EchoClient icClient;
private boolean paymentIsConnected = false;
private boolean icIsConnected = false;
private String code;
private EventLogDetailed eventLogDetailed;
private String status;
private TextView testText;
private TextView testTitle; //todo until new screen
//private Toolbar toolbar;
private SliderLayout sliderLayout;
ActivityResultLauncher<Intent> icVerificationLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
IDVerificationService service = new IDVerificationService(MainActivity.this, MainActivity.this);
IDVerificationService service = new IDVerificationService(MainActivity.this);
if (result.getResultCode() == Activity.RESULT_OK) {
Intent incomingData = result.getData();
if (incomingData != null) {
@ -65,29 +73,23 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
String cardNo = incomingData.getStringExtra("cardNo");
if (verifyIC(name, cardNo)) {
Log.d(TAG, "Match");
service.verifySuccess(code);
showStatusDialog(true, "NRIC Match");
service.verifySuccess(MainApplication.currentCode);
} else {
Log.d(TAG, "Fail");
service.verifyFail(code);
showStatusDialog(false, "NRIC Not Match");
service.verifyFail(MainApplication.currentCode);
}
}
} else if (result.getResultCode() == Activity.RESULT_CANCELED) {
service.verifyCancel(code);
Logger.logV("IC Scan Cancelled");
showStatusDialog(false, "Scan Cancelled");
service.verifyCancel(MainApplication.currentCode);
} else {
service.verifyFail(code);
showStatusDialog(false, "Scan Failed");
service.verifyFail(MainApplication.currentCode);
}
resetView();
});
public static String getValue() {
return value;
}
public static String getValues() {
return values;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -96,15 +98,76 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
sliderLayout = findViewById(R.id.slider_layout_ma);
sliderLayout.setVisibility(View.INVISIBLE); //todo until get good image
testText = findViewById(R.id.testText);
testTitle = findViewById(R.id.testText);
load = findViewById(R.id.loading_image_mt);
setupTextSlider();
//setupTextSlider();
initEchoClient();
connectEchoClient();
checkPaymentResult();
//checkPaymentResult();
}
@Override
protected void onResume() {
super.onResume();
Intent incomingIntent = getIntent();
String action = incomingIntent.getAction();
if (Constants.INTENT_REFRESH.equalsIgnoreCase(action)) {
String code = incomingIntent.getStringExtra("code");
String status = incomingIntent.getStringExtra("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);
}
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);
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 setupTextSlider() {
@ -140,9 +203,11 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
private void initViews() {
startWork();
runOnUiThread(() -> {
sliderLayout.setVisibility(View.INVISIBLE);
testText.setVisibility(View.INVISIBLE);
testTitle.setVisibility(View.INVISIBLE);
animationDrawable = (AnimationDrawable) load.getDrawable();
animationDrawable.start();
load.setVisibility(View.VISIBLE);
@ -150,54 +215,67 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
private void resetView() {
this.code = null;
this.eventLogDetailed = null;
MainApplication.reset();
runOnUiThread(() -> {
//sliderLayout.setVisibility(View.VISIBLE);
testText.setVisibility(View.VISIBLE);
testTitle.setVisibility(View.VISIBLE);
load.setVisibility(View.GONE);
});
}
private void paymentProcess(String payment) {
stopWork();
}
//Get the amount from JSON Object
String payAmount = "";
try {
JSONObject jsonObject = new JSONObject(payment).getJSONObject("code");
payAmount = jsonObject.getString("payable_amount");
} catch (JSONException e) {
e.printStackTrace();
private void paymentProcess(EventLogDetailed eventLogDetailed) {
Logger.logD(eventLogDetailed.toString());
String payFunction = eventLogDetailed.getPayFunction();
assert payFunction != null;
assert !payFunction.isEmpty();
if (Constants.PAY_FUNCTION_SALE.equalsIgnoreCase(payFunction)) {
handlePayFunctionSale(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) {
handlePayFunctionPreAuth(eventLogDetailed);
} else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) {
handlePayFunctionSaleCompletion(eventLogDetailed);
} else {
String msg = "Unsupported Pay Function: " + payFunction;
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
resetView();
Logger.logWTF(msg);
}
}
//Convert double value of amount from UDC kiosk app to integer 1st
double doubleValue = Double.parseDouble(payAmount);
int correctAmount = (int) Math.round(doubleValue * 100);
String pay_amount = "";
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.logWTF("Invalid Sale Request: " + request.toString());
}
}
Bundle extra = new Bundle();
String pay_function = "01"; //Sale Payment Function
pay_amount = String.valueOf(correctAmount);
String pay_type = "01"; // Card Payment
String pay_camera_mode = "01"; // Internal Device Back/bottom Camera
String pay_print_receipt_id = "N"; //Set Requirement
String pay_resp_code = "";
//Pack Request Message
extra.putString("pay_function", pay_function);
extra.putString("pay_amount", pay_amount);
extra.putString("pay_type", pay_type);
extra.putString("pay_camera_mode", pay_camera_mode);
extra.putString("pay_print_receipt_id", pay_print_receipt_id);
extra.putString("pay_resp_code", pay_resp_code);
//API to call Payment App
Intent intent = new Intent("com.revenue.edc.hlb.pro.app2app");
intent.putExtras(extra);
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.logWTF("Invalid Pre Auth Request: " + request.toString());
}
}
startActivity(intent);
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.logWTF("Invalid Sale Completion Request: " + request.toString());
}
}
private void checkPaymentResult() {
@ -267,68 +345,219 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
private void receiveMessagePayment(Object... args) {
Logger.logD(TAG + "receiveMessagePayment()", "Received Payment Message");
Logger.logD("Received Payment Message");
//debug error
try {
//start main activity screen
initViews();
} catch (Exception ex) {
Log.e("Error on contact", ex.getMessage());
if (MainApplication.working) {
//todo hmmm
Logger.logE("Received Payment Message but IM30 is currently working!");
return;
}
JSONObject jsonObject = (JSONObject) args[1];
String data = null;
try {
data = jsonObject.getString("data");
data = jsonObject.getJSONObject("data").getString("code");
MainApplication.currentCode = data;
} catch (JSONException e) {
e.printStackTrace();
}
if (data != null) {
//hold the info from UDC kiosk donation received for 5 second then proceed to HLB app
final Handler handler = new Handler(Looper.getMainLooper());
String finalData = data;
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 5000ms = 5 seconds
paymentProcess(finalData);
//clearInfo();
}
}, 5000);
if (MainApplication.currentCode != null && !MainApplication.currentCode.isEmpty()) {
initViews();
PaymentService service = new PaymentService(this);
service.getEventLog(MainApplication.currentCode);
startWork();
}
}
private void receiveMessageIC(Object... args) {
Logger.logD(TAG + "receiveMessageIC()", "Received IC Message");
Logger.logD("Received IC Message");
//debug error
try {
//start main activity screen
initViews();
} catch (Exception ex) {
Log.e("Error on contact", ex.getMessage());
if (MainApplication.working) {
//todo hmmm
Logger.logE("Received IC Verification Message but IM30 is currently working!");
return;
}
JSONObject jsonObject = (JSONObject) args[1];
String data = null;
try {
data = jsonObject.getJSONObject("data").getString("code");
this.code = data;
MainApplication.currentCode = data;
} catch (JSONException e) {
e.printStackTrace();
}
if (data != null) {
IDVerificationService service = new IDVerificationService(this, this);
service.getEventLog(code);
if (MainApplication.currentCode != null && !MainApplication.currentCode.isEmpty()) {
initViews();
IDVerificationService service = new IDVerificationService(this);
service.getEventLog(MainApplication.currentCode);
startWork();
}
}
@Override
public void callBack(String source, Object object) {
Logger.logD(source);
// NRIC
if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_GET_EVENT_LOG)) {
MainApplication.currentEventLogDetailed = (EventLogDetailed) object;
Intent i = new Intent(MainActivity.this, ICCActivity.class);
icVerificationLauncher.launch(i);
} else if (source.equalsIgnoreCase(IDVerificationService.FAIL_GET_EVENT_LOG)) {
resetView(); //todo try again?
}
else if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_UPDATE_EVENT_LOG)) {
resetView();
} else if (source.equalsIgnoreCase(IDVerificationService.FAIL_UPDATE_EVENT_LOG)) {
resetView(); //todo try again?
}
// Payment
else if (source.equalsIgnoreCase(PaymentService.SUCCESS_GET_EVENT_LOG)) {
MainApplication.currentEventLogDetailed = (EventLogDetailed) object;
paymentProcess(MainApplication.currentEventLogDetailed);
startWork();
} else if (source.equalsIgnoreCase(PaymentService.FAIL_GET_EVENT_LOG)) {
resetView(); //todo try again?
}
else if (source.equalsIgnoreCase(PaymentService.SUCCESS_UPDATE_EVENT_LOG)) {
resetView();
} else if (source.equalsIgnoreCase(PaymentService.FAIL_UPDATE_EVENT_LOG)) {
resetView(); //todo try again?
}
}
// --- NRIC ------------------------------------------------------------------------------------
private boolean verifyIC(String name, String cardNo) {
boolean match = true;
String savedNo = MainApplication.currentEventLogDetailed.getDocumentNumber().trim();
String firstName = MainApplication.currentEventLogDetailed.getFirstName().trim().toUpperCase();
Logger.logD("Comparing: " + name + ":" + cardNo + " to " + savedNo + ":" + firstName);
// Verify Card No.
if (!cardNo.contains(savedNo)) {
match = false;
Toast.makeText(MainActivity.this, "Card Number not correct!", Toast.LENGTH_SHORT).show();
Logger.logD("Card Number not correct! " + cardNo + " : " + savedNo);
}
// Verify Name...
String[] firstNames = firstName.split(Pattern.quote(" "));
for (String s : firstNames) {
if (!name.contains(s)) {
match = false;
Toast.makeText(MainActivity.this, "First Name not found", Toast.LENGTH_SHORT).show();
Logger.logD("First Name Not Found! " + s + " : " + name);
break;
}
}
String lastNames = MainApplication.currentEventLogDetailed.getLastName().trim().toUpperCase();
String[] lastName = lastNames.split(Pattern.quote(" "));
for (String s : lastName) {
if (!name.contains(s)) {
match = false;
Toast.makeText(MainActivity.this, "Last Name not found", Toast.LENGTH_SHORT).show();
Logger.logD("Last Name Not Found! " + s + " : " + name);
break;
}
}
if (match) {
Logger.logD("NRIC MATCH!");
}
return match;
}
// --- 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 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);
}
//region Echo Client Stuff
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);
startWork();
}
// --- MISC ------------------------------------------------------------------------------------
@Override
public void onDestroy() {
super.onDestroy();
@ -336,9 +565,9 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
private void initEchoClient() {
Logger.logD(TAG + "initEchoClient()", "echoClient: " + Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT);
paymentClient = new EchoClient(this, Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT);
icClient = new EchoClient(this, Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT);
Logger.logD("echoClient: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
paymentClient = new EchoClient(this, BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
icClient = new EchoClient(this, BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
}
private void connectEchoClient() {
@ -351,19 +580,19 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
paymentIsConnected = false;
icClient.disconnect();
icIsConnected = false;
Logger.logD(TAG + "disconnectEchoClient()", "");
Logger.logD("Disconnect EchoClient");
}
private void onConnectSuccessPayment(Object[] args) {
paymentIsConnected = true;
try {
String channelID = Constants.SOCKET_PREFIX + Constants.PAYMENT_CHANNEL_ID + Constants.KIOSK_CODE;
String eventType = Constants.PAYMENT_EVENT_TYPE;
String channelID = BuildConfig.SOCKET_PREFIX + BuildConfig.PAYMENT_CHANNEL_ID + BuildConfig.KIOSK_CODE;
String eventType = BuildConfig.PAYMENT_EVENT_TYPE;
EchoCallback echoCallback = this::receiveMessagePayment;
paymentClient.channel(channelID).listen(eventType, echoCallback);
Logger.logD(TAG + "onConnectSuccessPayment()", "Listening to: " + eventType + " on " + channelID);
Logger.logD("Listening to: " + eventType + " on " + channelID);
} catch (Exception ex) {
Log.e("Error on contact", ex.getMessage());
Logger.logE("Error on contact: " + ex.getMessage());
}
}
@ -374,78 +603,30 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
private void onConnectSuccessIC(Object[] args) {
icIsConnected = true;
try {
String channelID = Constants.SOCKET_PREFIX + Constants.IC_CHANNEL_ID + Constants.KIOSK_CODE;
String eventType = Constants.IC_EVENT_TYPE;
String channelID = BuildConfig.SOCKET_PREFIX + BuildConfig.IC_CHANNEL_ID + BuildConfig.KIOSK_CODE;
String eventType = BuildConfig.IC_EVENT_TYPE;
EchoCallback echoCallback = this::receiveMessageIC;
icClient.channel(channelID).listen(eventType, echoCallback);
Logger.logD(TAG + "onConnectSuccessIC()", "Listening to: " + eventType + " on " + channelID);
Logger.logD("Listening to: " + eventType + " on " + channelID);
} catch (Exception ex) {
Log.e("Error on contact", ex.getMessage());
Logger.logE("Error on contact: " + ex.getMessage());
}
}
private void onConnectFailureIC(Object[] args) {
icIsConnected = false;
}
//endregion Echo Client Stuff
@Override
public void callBack(String source) {
Logger.logD(TAG + "callBack()", source);
public void startWork() {
MainApplication.working = true;
}
@Override
public void callBack(String source, Object object) {
Logger.logD(TAG + "callBack()", source);
if (source.equalsIgnoreCase(IDVerificationService.CALLBACK_SUCCESS_GET_EVENT_LOG)) {
this.eventLogDetailed = (EventLogDetailed) object;
Intent i = new Intent(MainActivity.this, ICCActivity.class);
icVerificationLauncher.launch(i);
}
public void stopWork() {
MainApplication.working = false;
}
private boolean verifyIC(String name, String cardNo) {
boolean match = true;
String savedNo = this.eventLogDetailed.getDocumentNumber().trim();
String firstName = this.eventLogDetailed.getFirstName().trim().toUpperCase();
Logger.logD(TAG + "verifyIC()", "Comparing: " + name + ":" + cardNo + " to " + savedNo + ":" + firstName);
// Verify Card No.
if (!cardNo.contains(savedNo)) {
match = false;
Toast.makeText(MainActivity.this, "Card Number not correct!", Toast.LENGTH_SHORT).show();
Logger.logD(TAG + "verifyIC()", "Card Number not correct! " + cardNo + " : " + savedNo);
}
// Verify Name...
String[] firstNames = firstName.split(Pattern.quote(" "));
for (String s : firstNames) {
if (!name.contains(s)) {
match = false;
Toast.makeText(MainActivity.this, "First Name not found", Toast.LENGTH_SHORT).show();
Logger.logD(TAG + "verifyIC()", "First Name Not Found! " + s + " : " + name);
break;
}
}
String lastNames = this.eventLogDetailed.getLastName().trim().toUpperCase();
String[] lastName = lastNames.split(Pattern.quote(" "));
for (String s : lastName) {
if (!name.contains(s)) {
match = false;
Toast.makeText(MainActivity.this, "Last Name not found", Toast.LENGTH_SHORT).show();
Logger.logD(TAG + "verifyIC()", "Last Name Not Found! " + s + " : " + name);
break;
}
}
if (match) {
Toast.makeText(MainActivity.this, "NRIC match!", Toast.LENGTH_SHORT).show();
Logger.logD(TAG + "verifyIC()", "NRIC MATCH!");
}
return match;
@Override
public void onBackPressed() {
Logger.logI("Back Button Disabled!");
}
}

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

@ -8,262 +8,258 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.MainApplication;
import com.cst.im30.R;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.common.Constants;
import com.cst.im30.common.Parcel;
import com.cst.im30.entity.Transaction;
public class ResponseActivity extends AppCompatActivity {
//Set value to get temp value-RefNum
private static String vRefNum;
//Set value to get temp value-Status
private static String vStatus;
//Set value to get temp value-Amount
private static String vAmount;
private TextView txtResponseCode, txtRefNum, txtStatus, txtErrorDesc, txtAmount;
private Button buttonOk;
private Transaction transaction;
public static String getRefNum() {
return vRefNum;
}
public static String getStatus() {
return vStatus;
}
public static String getAmount() {
return vAmount;
}
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.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;
public class ResponseActivity extends AppCompatActivity implements CallableInterface {
private String code, status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_response);
setTitle("UDC DONATION KIOSK PAYMENT");
txtResponseCode = findViewById(R.id.title_responses);
txtRefNum = findViewById(R.id.title_reference_number);
txtStatus = findViewById(R.id.title_status);
txtErrorDesc = findViewById(R.id.title_error);
txtAmount = findViewById(R.id.title_amount);
buttonOk = findViewById(R.id.button_ok_ra);
//Get data from StatusActivty - refNum & amount only
String referenceNumber = MainActivity.getValue();
//get and set again
vRefNum = referenceNumber;
//String referenceNumber = getIntent().getStringExtra("keyrefnumber");
//String status = getIntent().getStringExtra("keystatus");
//String amount = getIntent().getStringExtra("keyamountpayment");
String amount = MainActivity.getValues();
vAmount = amount;
/*//Convert back amount into correct decimal/value
int correctAmount = Integer.parseInt(amount) /100;
String convertedAmount = "";
convertedAmount.valueOf(correctAmount);*/
buttonOk.setVisibility(View.GONE);
txtRefNum.setText(referenceNumber);
//txtStatus.setText(status);
txtAmount.setText(amount);
Intent intent = getIntent();
Bundle extra = intent.getExtras();
Parcel parcel = new Parcel(extra.toString());
Bundle args = new Bundle();
args.putSerializable("events", parcel);
String action = intent.getAction();
if (Constants.INTENT_ACTION.equalsIgnoreCase(action)) {
Logger.logD("Received Intent: " + action);
handlePaymentResponse(intent);
}
}
String payRespCode = extra.getString("pay_resp_code");
private void handlePaymentResponse(Intent intent) {
Bundle extra = intent.getExtras();
String payRespErrorDesc = extra.getString("pay_resp_error_desc");
if (extra == null) {
Logger.logWTF("Intent.getExtras() is null!");
return;
}
String payRespIssuerId = extra.getString("pay_resp_issuer_id");
String payFunction = extra.getString("pay_function");
String payRespQrTxnId = extra.getString("pay_resp_qr_txn_id");
String payRespInvoiceNo = extra.getString("pay_resp_invoice_no");
String payRespScheme = extra.getString("pay_resp_scheme");
String payRespBatchNo = extra.getString("pay_resp_batch_no");
String payRespTxnDate = extra.getString("pay_resp_txn_date");
String payRespTxnTime = extra.getString("pay_resp_txn_time");
String payPrintReceiptId = extra.getString("pay_print_receipt_id");
String payRespQrWalletId = extra.getString("pay_resp_qr_wallet_id");
String payRespCardAppCryptogram = extra.getString("pay_resp_card_app_cryptogram");
String payRespAppLabel = extra.getString("pay_resp_app_label");
String payRespCardRefNum = extra.getString("pay_resp_card_ref_num");
String payCameraMode = extra.getString("pay_camera_mode");
String payRespCardAuthCode = extra.getString("pay_resp_card_auth_code");
String payRespCardAid = extra.getString("pay_resp_card_aid");
String payRespHashPan = extra.getString("pay_resp_hash_pan");
String payRespMerchInfo = extra.getString("pay_resp_merch_info");
String payRespMid = extra.getString("pay_resp_mid");
String payRespTid = extra.getString("pay_resp_tid");
String payRespTvr = extra.getString("pay_resp_tvr");
String payRespCustomerId = extra.getString("pay_resp_customer_id");
String payType = extra.getString("pay_type");
String payRespTraceNo = extra.getString("pay_resp_trace_no");
String payRespCvmDesc = extra.getString("pay_resp_cvm_desc");
String payAddAmount = extra.getString("pay_add_amount");
String payRespCardNo = extra.getString("pay_resp_card_no");
String payAmount = extra.getString("pay_amount");
//get all HLB response & convert it to string for inserting API column(params_response)
//String allHLBresponse = {"id":13,"merchant_code":"MER0001","terminal_code":"TER001","reference_number":"PAY0021","response_code":"00","payment_type":"01","amount":"1.00","payment_function":"01","payment_camera_mode":null,"status":"success","created_at":"2021-08-23T03:19:30.000000Z","updated_at":"2021-08-23T06:29:40.000000Z"};
String allHLBresponse =
"{pay_resp_issuer_id=" + payRespIssuerId + "," +
"pay_resp_error_desc=" + payRespErrorDesc + "," +
"pay_function=" + payFunction + "," +
"pay_resp_qr_txn_id=" + payRespQrTxnId + "," +
"pay_resp_invoice_no=" + payRespInvoiceNo + "," +
"pay_resp_scheme=" + payRespScheme + "," +
"pay_resp_batch_no=" + payRespBatchNo + "," +
"pay_resp_txn_date=" + payRespTxnDate + "," +
"pay_resp_txn_time=" + payRespTxnTime + "," +
"pay_print_receipt_id=" + payPrintReceiptId + "," +
"pay_resp_qr_wallet_id=" + payRespQrWalletId + "," +
"pay_resp_code=" + payRespCode + "," +
"pay_resp_card_app_cryptogram=" + payRespCardAppCryptogram + "," +
"pay_resp_app_label=" + payRespAppLabel + "," +
"pay_resp_card_ref_num=" + payRespCardRefNum + "," +
"pay_camera_mode=" + payCameraMode + "," +
"pay_resp_card_auth_code=" + payRespCardAuthCode + "," +
"pay_resp_card_aid=" + payRespCardAid + "," +
"pay_resp_hash_pan=" + payRespHashPan + "," +
"pay_resp_merch_info=" + payRespMerchInfo + "," +
"pay_resp_mid=" + payRespMid + "," +
"pay_resp_tid=" + payRespTid + "," +
"pay_resp_tvr=" + payRespTvr + "," +
"pay_resp_customer_id=" + payRespCustomerId + "," +
"pay_type=" + payType + "," +
"pay_resp_trace_no=" + payRespTraceNo + "," +
"pay_resp_cvm_desc=" + payRespCvmDesc + "," +
"pay_add_amount=" + payAddAmount + "," +
"pay_resp_card_no=" + payRespCardNo + "," +
"pay_amount=" + payAmount + "}";
//Log.d("TAG", payRespCode);
txtResponseCode.setText(payRespCode);
txtErrorDesc.setText(payRespErrorDesc);
//set status from response to human readable language/meaning
String resultPayRespCode = "";
String resultPayRespCodeStatus = "";
if (payRespCode.equals("00") && payRespErrorDesc.toLowerCase().trim().equals("approved")) {
resultPayRespCode = "Transaction Approved";
resultPayRespCodeStatus = "success";
} else if (payRespCode.equals("00") && payRespErrorDesc.toLowerCase().trim().equals("declined")) {
resultPayRespCode = "Transaction Approved but Declined #ErrorDesc";
resultPayRespCodeStatus = "fail"; //or declined
} else if (payRespCode.equals("ND")) {
resultPayRespCode = "User cancel/No Host Response";
resultPayRespCodeStatus = "fail";
} else {
resultPayRespCode = "Transaction Decline";
resultPayRespCodeStatus = "fail";
}
Logger.logV("Pay Function: " + payFunction);
txtStatus.setText(resultPayRespCode);
String finalResultPayRespCode = resultPayRespCode;
String finalResultPayRespCodeStatus = resultPayRespCodeStatus;
vStatus = finalResultPayRespCodeStatus;
if (Constants.PAY_FUNCTION_SALE.equalsIgnoreCase(payFunction)) {
handlePayFunctionSale(extra);
}
else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) {
handlePayFunctionPreAuth(extra);
}
else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) {
handlePayFunctionSaleCompletion(extra);
}
else {
Logger.logWTF("Unsupported Pay Function: " + payFunction);
}
}
//TODO: Send all response to Status Activity, then update/send all the info to API to be inserted in UDC KIOSK
private void handlePayFunctionSale(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;
code = resolveCode(response.getPayRespCode());
status = resolveStatus(response.getPayRespErrorDesc());
UploadTransactionSalePaymentService service = new UploadTransactionSalePaymentService(ResponseActivity.this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentSaleRequest, MainApplication.currentSaleResponse);
}
private void handlePayFunctionPreAuth(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());
code = resolveCode(response.getPayRespCode());
status = resolveStatus(response.getPayRespErrorDesc());
MainApplication.currentPreAuthResponse = response;
UploadTransactionPreAuthPaymentService service = new UploadTransactionPreAuthPaymentService(ResponseActivity.this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentPreAuthRequest, MainApplication.currentPreAuthResponse);
}
String refNum = referenceNumber;
String finalAmount = amount;
private void handlePayFunctionSaleCompletion(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());
code = resolveCode(response.getPayRespCode());
status = resolveStatus(response.getPayRespErrorDesc());
MainApplication.currentSaleCompletionResponse = response;
UploadTransactionSaleCompletionPaymentService service = new UploadTransactionSaleCompletionPaymentService(ResponseActivity.this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentSaleCompletionRequest, MainApplication.currentSaleCompletionResponse);
}
//directly to status screen
//get infos from HLB and send to status activity
showStatusScreen(refNum, finalResultPayRespCodeStatus, finalAmount, payRespCode, payRespErrorDesc, payRespIssuerId,
payFunction, payRespQrTxnId, payRespInvoiceNo, payRespScheme, payRespBatchNo, payRespTxnDate, payRespTxnTime,
payPrintReceiptId, payRespQrWalletId, payRespCardAppCryptogram, payRespAppLabel, payRespCardRefNum,
payCameraMode, payRespCardAuthCode, payRespCardAid, payRespHashPan, payRespMerchInfo, payRespMid, payRespTid,
payRespTvr, payRespCustomerId, payType, payRespTraceNo, payRespCvmDesc, payAddAmount, payRespCardNo, payAmount, allHLBresponse);
@Override
public void callBack(String source, Object object) {
Logger.logD(source);
if (UploadTransactionSalePaymentService.SUCCESS.equalsIgnoreCase(source)) {
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifySuccess(MainApplication.currentCode);
} else {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifyFail(MainApplication.currentCode);
}
} else if (UploadTransactionPreAuthPaymentService.SUCCESS.equalsIgnoreCase(source)) {
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifySuccess(MainApplication.currentCode);
} else {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifyFail(MainApplication.currentCode);
}
} else if (UploadTransactionSaleCompletionPaymentService.SUCCESS.equalsIgnoreCase(source)) {
if (PaymentUtils.validateResponseCodeAndMessage(code, status)) {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifySuccess(MainApplication.currentCode);
} else {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifyFail(MainApplication.currentCode);
}
}
//get infos from HLB and send to status activity
/*sendHLBPaymentResponse(payRespCode, payRespErrorDesc, payRespIssuerId, payFunction, payRespQrTxnId, payRespInvoiceNo,
payRespScheme, payRespBatchNo, payRespTxnDate, payRespTxnTime, payPrintReceiptId, payRespQrWalletId,
payRespCardAppCryptogram, payRespAppLabel, payRespCardRefNum, payCameraMode, payRespCardAuthCode, payRespCardAid,
payRespHashPan, payRespMerchInfo, payRespMid, payRespTid, payRespTvr, payRespCustomerId, payType, payRespTraceNo,
payRespCvmDesc, payAddAmount, payRespCardNo, payAmount);*/
else if (UploadTransactionSalePaymentService.FAIL.equalsIgnoreCase(source)) {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifyFail(MainApplication.currentCode);
} else if (UploadTransactionPreAuthPaymentService.FAIL.equalsIgnoreCase(source)) {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifyFail(MainApplication.currentCode);
} else if (UploadTransactionSaleCompletionPaymentService.FAIL.equalsIgnoreCase(source)) {
PaymentService service = new PaymentService(ResponseActivity.this);
service.verifyFail(MainApplication.currentCode);
}
else if (PaymentService.SUCCESS_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) {
finishActivity();
} else if (PaymentService.FAIL_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) {
finishActivity();
}
}
private void showStatusScreen(String refNumTransaction, String statusTransaction, String amountTransaction,
String payRespCodeTransaction, String payRespErrorDescTransaction,
String payRespIssuerIdTransaction, String payFunctionTransaction,
String payRespQrTxnIdTransaction, String payRespInvoiceNoTransaction,
String payRespSchemeTransaction, String payRespBatchNoTransaction,
String payRespTxnDateTransaction, String payRespTxnTimeTransaction,
String payPrintReceiptIdTransaction, String payRespQrWalletIdTransaction,
String payRespCardAppCryptogramTransaction, String payRespAppLabelTransaction,
String payRespCardRefNumTransaction, String payCameraModeTransaction,
String payRespCardAuthCodeTransaction, String payRespCardAidTransaction,
String payRespHashPanTransaction, String payRespMerchInfoTransaction,
String payRespMidTransaction, String payRespTidTransaction, String payRespTvrTransaction,
String payRespCustomerIdTransaction, String payTypeTransaction,
String payRespTraceNoTransaction, String payRespCvmDescTransaction,
String payAddAmountTransaction, String payRespCardNoTransaction, String payAmountTransaction,
String allHLBresponse) {
Intent intent = new Intent(ResponseActivity.this, StatusActivity.class);
//intent.putExtra("transaction", transaction);
intent.putExtra("referenceNumTransaction", refNumTransaction);
intent.putExtra("statusTransaction", statusTransaction);
intent.putExtra("amountTransaction", amountTransaction); //only this info right now that is important to show (value) at status screen
//response from APP2APP HLB
intent.putExtra("hlbResponse", allHLBresponse);
intent.putExtra("payRespCodeTransaction", payRespCodeTransaction);
intent.putExtra("payRespErrorDescTransaction", payRespErrorDescTransaction);
intent.putExtra("payRespIssuerIdTransaction", payRespIssuerIdTransaction);
intent.putExtra("payFunctionTransaction", payFunctionTransaction);
intent.putExtra("payRespQrTxnIdTransaction", payRespQrTxnIdTransaction);
intent.putExtra("payRespInvoiceNoTransaction", payRespInvoiceNoTransaction);
intent.putExtra("payRespSchemeTransaction", payRespSchemeTransaction);
intent.putExtra("payRespBatchNoTransaction", payRespBatchNoTransaction);
intent.putExtra("payRespTxnDateTransaction", payRespTxnDateTransaction);
intent.putExtra("payRespTxnTimeTransaction", payRespTxnTimeTransaction);
intent.putExtra("payPrintReceiptIdTransaction", payPrintReceiptIdTransaction);
intent.putExtra("payRespQrWalletIdTransaction", payRespQrWalletIdTransaction);
intent.putExtra("payRespCardAppCryptogramTransaction", payRespCardAppCryptogramTransaction);
intent.putExtra("payRespAppLabelTransaction", payRespAppLabelTransaction);
intent.putExtra("payRespCardRefNumTransaction", payRespCardRefNumTransaction);
intent.putExtra("payCameraModeTransaction", payCameraModeTransaction);
intent.putExtra("payRespCardAuthCodeTransaction", payRespCardAuthCodeTransaction);
intent.putExtra("payRespCardAidTransaction", payRespCardAidTransaction);
intent.putExtra("payRespHashPanTransaction", payRespHashPanTransaction);
intent.putExtra("payRespMerchInfoTransaction", payRespMerchInfoTransaction);
intent.putExtra("payRespMidTransaction", payRespMidTransaction);
intent.putExtra("payRespTidTransaction", payRespTidTransaction);
intent.putExtra("payRespTvrTransaction", payRespTvrTransaction);
intent.putExtra("payRespCustomerIdTransaction", payRespCustomerIdTransaction);
intent.putExtra("payTypeTransaction", payTypeTransaction);
intent.putExtra("payRespTraceNoTransaction", payRespTraceNoTransaction);
intent.putExtra("payRespCvmDescTransaction", payRespCvmDescTransaction);
intent.putExtra("payAddAmountTransaction", payAddAmountTransaction);
intent.putExtra("payRespCardNoTransaction", payRespCardNoTransaction);
intent.putExtra("payAmountTransaction", payAmountTransaction);
private void finishActivity() {
Intent intent = new Intent(ResponseActivity.this, MainActivity.class);
intent.setAction(Constants.INTENT_REFRESH);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("code", code);
intent.putExtra("status", status);
startActivity(intent);
setResult(RESULT_OK);
finish();
Logger.logV("Going back to MainActivity");
}
private String resolveStatus(String payRespErrorDesc) {
return payRespErrorDesc;
}
private String resolveCode(String payRespCode) {
return payRespCode;
}
}

8
app/src/main/java/com/cst/im30/activity/SettingActivity.java

@ -14,6 +14,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import com.cst.im30.BuildConfig;
import com.cst.im30.EchoClientSetting;
import com.cst.im30.R;
import com.cst.im30.common.Constants;
@ -22,7 +23,6 @@ import org.json.JSONException;
import org.json.JSONObject;
public class SettingActivity extends AppCompatActivity {
public static final String TAG = "SettingActivity";
private EchoClientSetting echoClient;
@ -88,7 +88,7 @@ public class SettingActivity extends AppCompatActivity {
// Create the client
echoClient = new EchoClientSetting(
this,
Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT
BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT
);
}
@ -172,8 +172,8 @@ public class SettingActivity extends AppCompatActivity {
runOnUiThread(() -> Toast.makeText(SettingActivity.this, "Connected!", Toast.LENGTH_SHORT).show());
echoClient.channel(Constants.PAYMENT_CHANNEL_ID + Constants.KIOSK_CODE)
.listen(Constants.PAYMENT_EVENT_TYPE, this::receiveMessage);
echoClient.channel(BuildConfig.PAYMENT_CHANNEL_ID + BuildConfig.KIOSK_CODE)
.listen(BuildConfig.PAYMENT_EVENT_TYPE, this::receiveMessage);
}

27
app/src/main/java/com/cst/im30/activity/StatusActivity.java

@ -21,8 +21,8 @@ import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.cst.im30.R;
import com.cst.im30.entity.Transaction;
import com.cst.im30.retrofit.RetrofitAPICollection;
import com.cst.im30.retrofit.RetrofitClient;
import com.cst.im30.api.RetrofitAPICollection;
import com.cst.im30.api.RetrofitClient;
import org.json.JSONException;
import org.json.JSONObject;
@ -143,14 +143,14 @@ public class StatusActivity extends AppCompatActivity {
textAmount = findViewById(R.id.text_info_amount_sta);
imageStatus = findViewById(R.id.image_status_sta);
//Get data from StatusActivty - refNum & amount only
/*//Get data from StatusActivty - refNum & amount only
String referenceNumber = ResponseActivity.getRefNum();
//get and set again
vRefNum = referenceNumber;
String statusTemp = ResponseActivity.getStatus();
vStatus = statusTemp;
String amount = ResponseActivity.getAmount();
vAmount = amount;
vAmount = amount;*/
//Get status from Response Screen
@ -238,7 +238,7 @@ public class StatusActivity extends AppCompatActivity {
if (status.toLowerCase().trim().equals("success")) {
textStatus.setText(getResources().getString(R.string.txt_success_status));
textInfo.setText(getResources().getString(R.string.txt_info_status));
textAmount.setText("Donation Amount: " + "RM " + amount);
//textAmount.setText("Donation Amount: " + "RM " + amount);
Glide.with(StatusActivity.this).asBitmap().load(R.drawable.ic_status_success_fancy).into(imageStatus);
/*//direct update the status to server
@ -266,8 +266,8 @@ public class StatusActivity extends AppCompatActivity {
String paramsResponse = "{\"id\":13,\"merchant_code\":\"MER0001\"}";*/
//Signature = merchant_code+secret_key+reference_number+amount+response_code ->23/08/2021-update
String encryptedSigns = merchanCode + secretKey + referenceNum + amount + payRespCodeTransaction;
String encryptedSignValueUpdate = encrytThisString(encryptedSigns);
//String encryptedSigns = merchanCode + secretKey + referenceNum + amount + payRespCodeTransaction;
String encryptedSignValueUpdate = "";//encrytThisString(encryptedSigns);
//hide button so user won't need to interact with it
//buttonDonationSuccess.setVisibility(View.VISIBLE);
@ -312,7 +312,7 @@ public class StatusActivity extends AppCompatActivity {
} else {
textStatus.setText(getResources().getString(R.string.txt_fail_status));
textInfo.setText(getResources().getString(R.string.txt_fail_info_status));
textAmount.setText("Donation Amount: " + "RM " + amount);
//textAmount.setText("Donation Amount: " + "RM " + amount);
Glide.with(StatusActivity.this).asBitmap().load(R.drawable.ic_status_fail_fancy).into(imageStatus);
buttonDonationSuccess.setVisibility(View.GONE);
@ -349,8 +349,8 @@ public class StatusActivity extends AppCompatActivity {
String paymentCameraMode = payCameraModeTransaction;
//Signature = merchant_code+secret_key+reference_number+amount+response_code ->23/08/2021-update
String encryptedSigns = merchanCode + secretKey + referenceNum + amount + payRespCodeTransaction;
String encryptedSignValueUpdate = encrytThisString(encryptedSigns);
//String encryptedSigns = merchanCode + secretKey + referenceNum + amount + payRespCodeTransaction;
String encryptedSignValueUpdate ="";// encrytThisString(encryptedSigns);
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
@ -380,11 +380,11 @@ public class StatusActivity extends AppCompatActivity {
String finalAmount = amountTransaction;
//Signature=merchant_code+secret_key_reference_number+amount+payment_type ->23/08/2021-requery
String encryptedSign = merchanCode + secretKey + referenceNum + amount + payTypeTransaction;
String encryptedSign ="";// merchanCode + secretKey + referenceNum + amount + payTypeTransaction;
String encryptedSignValueRequery = encrytThisString(encryptedSign);
//Signature = merchant_code+secret_key+reference_number+amount+response_code ->23/08/2021-update
String encryptedSigns = merchanCode + secretKey + referenceNum + amount + payRespCodeTransaction;
String encryptedSigns ="";// merchanCode + secretKey + referenceNum + amount + payRespCodeTransaction;
String encryptedSignValueUpdate = encrytThisString(encryptedSigns);
@ -536,9 +536,10 @@ public class StatusActivity extends AppCompatActivity {
//Convert double value of amount from UDC kiosk app to integer 1st
double doubleValue = Double.parseDouble(payAmount);
double centValue = doubleValue * 100;
//Convert amount to time 100 for HLB to process
int correctAmount = (int) Math.round(doubleValue * 100);
int correctAmount = (int) Math.round(centValue);
String pay_amount = "";

29
app/src/main/java/com/cst/im30/retrofit/RetrofitAPICollection.java → app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java

@ -1,4 +1,4 @@
package com.cst.im30.retrofit;
package com.cst.im30.api;
import com.cst.im30.common.Payment;
@ -9,6 +9,7 @@ import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
@ -46,6 +47,32 @@ public interface RetrofitAPICollection {
@Path("eventCode") String referenceNumber
);
@Headers({
"Accept: application/json",
"Content-Type: application/json",
})
@POST("api/v1/kiosk/booking/upload-terminal-revpay-transaction")
Call<String> uploadRevPayTransaction(
@Header("Client-Id") String clientId,
@Header("Client-Secret") String clientSecret,
@Body String body
);
@Headers({
"Accept: application/json"

2
app/src/main/java/com/cst/im30/retrofit/RetrofitClient.java → app/src/main/java/com/cst/im30/api/RetrofitClient.java

@ -1,4 +1,4 @@
package com.cst.im30.retrofit;
package com.cst.im30.api;
import java.util.concurrent.TimeUnit;

2
app/src/main/java/com/cst/im30/common/CallableInterface.java

@ -2,8 +2,6 @@ package com.cst.im30.common;
public interface CallableInterface {
void callBack(String source);
void callBack(String source, Object object);
}

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

@ -2,27 +2,22 @@ package com.cst.im30.common;
public class Constants {
//change to gradle properties
public static final String SERVER_URL = "http://hello-booking-api-build.testpigeon.net";
public static final String CLIENT_ID = "3";
public static final String CLIENT_SECRET = "w5RJ7bMF6NH39aDVyJJV0M1gOg0nZQcO2atVcXyF";
public static final String ECHO_SERVER_URL = "http://hello-booking-api-build.testpigeon.net";
public static final String ECHO_SERVER_PORT = "6001";
public static final String KIOSK_CODE = "KIOSK002";
public static final String SOCKET_PREFIX = "HelloBookingApi_";
public static final String PAYMENT_CHANNEL_ID = "payment#";
public static final String PAYMENT_EVENT_TYPE = ".makepayment";
public static final String IC_CHANNEL_ID = "verification#";
public static final String IC_EVENT_TYPE = ".guestverification";
//trigger
//public static final String LAUNCH_URL = "http://laravel-echo-server.testpigeon.net";
//public static final String LAUNCH_URL = "http://udcsys-api-build.testpigeon.net";
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 PAY_FUNCTION_SALE = "01";
public static final String PAY_FUNCTION_VOID = "02";
public static final String PAY_FUNCTION_INQUIRY = "03";
public static final String PAY_FUNCTION_SALE_CASH = "04";
public static final String PAY_FUNCTION_PING = "05";
public static final String PAY_FUNCTION_STATUS = "06";
public static final String PAY_FUNCTION_CANCEL = "07";
public static final String PAY_FUNCTION_INSTALLMENT = "08";
public static final String PAY_FUNCTION_PRE_AUTH = "09";
public static final String PAY_FUNCTION_SALE_COMPLETION = "10";
public static final String PAY_FUNCTION_SETTLEMENT = "11";
public static final String PAY_FUNCTION_SET_DATE_TIME = "12";
public static final String PAY_FUNCTION_READ_CARD_INFORMATION = "13";
}

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

@ -7,5 +7,18 @@ import lombok.Data;
@Data
public class EventLogDetailed implements Serializable {
String type, status, documentType, documentNumber, firstName, lastName;
private int id;
private String type, status;
private String remark;
// IC Verification
private String documentType, documentNumber, firstName, lastName;
// Payment / Pre Auth / Sale Completion
private String payableAmount, payFunction, confirmationNumber, referenceNumber;
// Sale Completion
private String payAuthCode, payRefNum, token;
}

23
app/src/main/java/com/cst/im30/model/PreAuthRequest.java

@ -0,0 +1,23 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class PreAuthRequest implements Serializable {
/** Mandatory 2 - 09 - Pre Auth **/
private String payFunction = "09";
/** Mandatory 12 - Amount in cents (RM5.00 is "500" **/
private String payAmount; //
/** Optional 50 **/
private String payPosTxnId;
/** Optional 1 - Y or N for Print Receipt or Not **/
private String payPrintReceiptId = "N";
}

37
app/src/main/java/com/cst/im30/model/PreAuthResponse.java

@ -0,0 +1,37 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class PreAuthResponse implements Serializable {
private String payAmount;
private String payFunction;
private String payType;
private String payPrintReceiptId;
private String payRespTxnDate;
private String payRespTxnTime;
private String payRespInvoiceNo;
private String payRespTraceNo;
private String payRespBatchNo;
private String payRespScheme;
private String payRespTid;
private String payRespMid;
private String payRespCardAuthCode;
private String payRespCardRefNum;
private String payRespCardNo;
private String payRespIssuerId;
private String payRespCardAid;
private String payRespCardAppCryptogram;
private String payRespCode;
private String payRespErrorDesc;
private String payRespMerchInfo;
private String payRespTvr;
private String payRespCvmDesc;
private String payRespAppLabel;
private String payRespHashPan;
private String token;
}

31
app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java

@ -0,0 +1,31 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SaleCompletionRequest implements Serializable {
/** Mandatory 2 - 10 - Sale Completion **/
private String payFunction = "10";
/** Mandatory 12 - Amount in cents (RM5.00 is "500" **/
private String payAmount;
/** Mandatory 6 - Pre Auth Transaction Approval Code **/
private String payAuthCode;
/** Optional 12 - Pre Auth Transaction Reference Number **/
private String payRefNum;
/** Optional 50 **/
private String payPosTxnId;
/** Optional 1 - Y or N for Print Receipt or Not **/
private String payPrintReceiptId = "N";
/** Optional 50 - Pre Auth Card Token (Token + AuthCode + RefNum must be sent together) **/
private String token;
}

36
app/src/main/java/com/cst/im30/model/SaleCompletionResponse.java

@ -0,0 +1,36 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SaleCompletionResponse implements Serializable {
private String payAmount;
private String payFunction;
private String payType;
private String payPrintReceiptId;
private String payRespTxnDate;
private String payRespTxnTime;
private String payRespInvoiceNo;
private String payRespTraceNo;
private String payRespBatchNo;
private String payRespScheme;
private String payRespTid;
private String payRespMid;
private String payRespCardAuthCode;
private String payRespCardRefNum;
private String payRespCardNo;
private String payRespIssuerId;
private String payRespCardAid;
private String payRespCardAppCryptogram;
private String payRespCode;
private String payRespErrorDesc;
private String payRespMerchInfo;
private String payRespTvr;
private String payRespCvmDesc;
private String payRespAppLabel;
private String payRespHashPan;
}

28
app/src/main/java/com/cst/im30/model/SaleRequest.java

@ -0,0 +1,28 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SaleRequest implements Serializable {
/** Mandatory 2 - 01 - Sale **/
private String payFunction = "01";
/** Mandatory 12 - Amount in cents (RM5.00 is "500" **/
private String payAmount; //
/** Mandatory 2 - 01 Card / 02 QR / 03 DuitNow QR **/
private String payType = "01";
/** Conditional 2 - 01 Back / 02 Front **/
private String payCameraMode = "01";
/** Optional 50 **/
private String payPosTxnId;
/** Optional 1 - Y or N for Print Receipt or Not **/
private String payPrintReceiptId = "N";
}

40
app/src/main/java/com/cst/im30/model/SaleResponse.java

@ -0,0 +1,40 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SaleResponse implements Serializable {
private String payAmount;
private String payFunction;
private String payType;
private String payCameraMode;
private String payPrintReceiptId;
private String payRespTxnDate;
private String payRespTxnTime;
private String payRespInvoiceNo;
private String payRespTraceNo;
private String payRespBatchNo;
private String payRespScheme;
private String payRespTid;
private String payRespMid;
private String payRespCardAuthCode;
private String payRespCardRefNum;
private String payRespCardNo;
private String payRespIssuerId;
private String payRespCardAid;
private String payRespCardAppCryptogram;
private String payRespQrTxnId;
private String payRespQrWalletId;
private String payRespCustomerId;
private String payRespCode;
private String payRespErrorDesc;
private String payRespMerchInfo;
private String payRespTvr;
private String payRespCvmDesc;
private String payRespAppLabel;
private String payRespHashPan;
}

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

@ -1,14 +1,13 @@
package com.cst.im30.service;
import android.content.Context;
import androidx.annotation.NonNull;
import com.cst.im30.BuildConfig;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.common.Constants;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.retrofit.RetrofitAPICollection;
import com.cst.im30.retrofit.RetrofitClient;
import com.cst.im30.api.RetrofitAPICollection;
import com.cst.im30.api.RetrofitClient;
import com.cst.im30.utility.Logger;
import org.json.JSONException;
import org.json.JSONObject;
@ -18,26 +17,25 @@ import retrofit2.Callback;
import retrofit2.Response;
public class IDVerificationService {
public static final String TAG = "IDVerificationService.";
public static final String CALLBACK_SUCCESS_GET_EVENT_LOG = "callback_success_get_event_log";
public static final String CALLBACK_FAIL_GET_EVENT_LOG = "callback_fail_get_event_log";
public static final String CALLBACK_SUCCESS_UPDATE_EVENT_LOG = "callback_success_update_event_log";
public static final String CALLBACK_FAIL_UPDATE_EVENT_LOG = "callback_fail_update_event_log";
public static final String SUCCESS_GET_EVENT_LOG = TAG + "SUCCESS_GET_EVENT_LOG";
public static final String FAIL_GET_EVENT_LOG = TAG + "FAIL_GET_EVENT_LOG";
public static final String SUCCESS_UPDATE_EVENT_LOG = TAG + "SUCCESS_UPDATE_EVENT_LOG";
public static final String FAIL_UPDATE_EVENT_LOG = TAG + "FAIL_UPDATE_EVENT_LOG";
private final Context context;
private final CallableInterface callback;
private final String hostUrl;
private final String clientId;
private final String clientSecret;
public IDVerificationService(Context context, CallableInterface callback) {
this.context = context;
public IDVerificationService(CallableInterface callback) {
this.callback = callback;
this.hostUrl = Constants.SERVER_URL;
this.clientId = Constants.CLIENT_ID;
this.clientSecret = Constants.CLIENT_SECRET;
this.hostUrl = BuildConfig.SERVER_URL;
this.clientId = BuildConfig.CLIENT_ID;
this.clientSecret = BuildConfig.CLIENT_SECRET;
}
public void getEventLog(String code) {
@ -45,6 +43,8 @@ public class IDVerificationService {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.getBroadcastEventLogDetails(clientId, clientSecret, code);
Logger.logV(code);
call.enqueue(new Callback<String>() {
@Override
@ -62,87 +62,120 @@ public class IDVerificationService {
private void onResponseGetEventLog(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
}
callback.callBack(FAIL_GET_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
EventLogDetailed eventLogDetailed = this.parseGetEventLogResponse(responseJSON);
callback.callBack(CALLBACK_SUCCESS_GET_EVENT_LOG, eventLogDetailed);
callback.callBack(SUCCESS_GET_EVENT_LOG, eventLogDetailed);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureGetEventLog(Throwable t) {
}
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception {
String type = jsonObject.getJSONObject("data").getString("type");
String status = jsonObject.getJSONObject("data").getString("status");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number");
String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name");
String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name");
EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setType(type);
eventLogDetailed.setStatus(status);
eventLogDetailed.setDocumentType(documentType);
eventLogDetailed.setDocumentNumber(documentNumber);
eventLogDetailed.setFirstName(firstName);
eventLogDetailed.setLastName(lastName);
return eventLogDetailed;
}
public void verifySuccess(String code) {
updateBroadcastEventLogDetail(code, "success");
}
public void verifyFail(String code) {
updateBroadcastEventLogDetail(code, "fail");
}
public void verifyCancel(String code) {
updateBroadcastEventLogDetail(code, "cancelled");
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL_GET_EVENT_LOG, t.getMessage());
}
private void updateBroadcastEventLogDetail(String code, String status) {
JSONObject payload = new JSONObject();
try {
payload.put("status", status);
} catch (JSONException e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return;
}
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.updateBroadcastEventLogDetails(clientId, clientSecret, payload.toString(), code);
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.updateBroadcastEventLogDetails(clientId, clientSecret, payload.toString(), code);
call.enqueue(new Callback<String>() {
Logger.logV("Update: " + code + ":" + payload.toString());
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseUpdateBroadcastEventLogDetails(response);
}
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseUpdateBroadcastEventLogDetails(response);
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureUpdateEventLog(t);
}
});
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureGetEventLog(t);//todo
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
private void onResponseUpdateBroadcastEventLogDetails(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
callback.callBack(CALLBACK_SUCCESS_UPDATE_EVENT_LOG);
Logger.logV(responseJSON.toString());
callback.callBack(SUCCESS_UPDATE_EVENT_LOG, responseJSON);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureUpdateEventLog(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, t.getMessage());
}
public void verifySuccess(String code) {
updateBroadcastEventLogDetail(code, "success");
}
public void verifyFail(String code) {
updateBroadcastEventLogDetail(code, "fail");
}
public void verifyCancel(String code) {
updateBroadcastEventLogDetail(code, "cancelled");
}
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception {
String type = jsonObject.getJSONObject("data").getString("type");
String status = jsonObject.getJSONObject("data").getString("status");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number");
String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name");
String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name");
EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setType(type);
eventLogDetailed.setStatus(status);
eventLogDetailed.setDocumentType(documentType);
eventLogDetailed.setDocumentNumber(documentNumber);
eventLogDetailed.setFirstName(firstName);
eventLogDetailed.setLastName(lastName);
return eventLogDetailed;
}
}

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

@ -0,0 +1,188 @@
package com.cst.im30.service;
import androidx.annotation.NonNull;
import com.cst.im30.BuildConfig;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.api.RetrofitAPICollection;
import com.cst.im30.api.RetrofitClient;
import com.cst.im30.utility.JsonUtils;
import com.cst.im30.utility.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class PaymentService {
public static final String TAG = "PaymentSaleService.";
public static final String SUCCESS_GET_EVENT_LOG = TAG + "SUCCESS_GET_EVENT_LOG";
public static final String FAIL_GET_EVENT_LOG = TAG + "FAIL_GET_EVENT_LOG";
public static final String SUCCESS_UPDATE_EVENT_LOG = TAG + "SUCCESS_UPDATE_EVENT_LOG";
public static final String FAIL_UPDATE_EVENT_LOG = TAG + "FAIL_UPDATE_EVENT_LOG";
private final CallableInterface callback;
private final String hostUrl;
private final String clientId;
private final String clientSecret;
public PaymentService(CallableInterface callback) {
this.callback = callback;
this.hostUrl = BuildConfig.SERVER_URL;
this.clientId = BuildConfig.CLIENT_ID;
this.clientSecret = BuildConfig.CLIENT_SECRET;
}
public void getEventLog(String code) {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.getBroadcastEventLogDetails(clientId, clientSecret, code);
Logger.logV(code);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseGetEventLog(response);
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureGetEventLog(t);
}
});
}
private void onResponseGetEventLog(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
}
callback.callBack(FAIL_GET_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
EventLogDetailed eventLogDetailed = this.parseGetEventLogResponse(responseJSON);
callback.callBack(SUCCESS_GET_EVENT_LOG, eventLogDetailed);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureGetEventLog(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL_GET_EVENT_LOG, t.getMessage());
}
private void updateBroadcastEventLogDetail(String code, String status) {
JSONObject payload = new JSONObject();
try {
payload.put("status", status);
} catch (JSONException e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return;
}
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.updateBroadcastEventLogDetails(clientId, clientSecret, payload.toString(), code);
Logger.logV("Update: " + code + ":" + payload.toString());
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseUpdateBroadcastEventLogDetails(response);
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureUpdateEventLog(t);
}
});
}
private void onResponseUpdateBroadcastEventLogDetails(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
Logger.logV(responseJSON.toString());
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logV(responseJSON.toString());
callback.callBack(SUCCESS_UPDATE_EVENT_LOG, responseJSON);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureUpdateEventLog(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, t.getMessage());
}
public void verifySuccess(String code) {
updateBroadcastEventLogDetail(code, "success");
}
public void verifyFail(String code) {
updateBroadcastEventLogDetail(code, "fail");
}
public void verifyCancel(String code) {
updateBroadcastEventLogDetail(code, "cancelled");
}
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) {
if (jsonObject.has("data")) {
try {
JSONObject dataJSON = jsonObject.getJSONObject("data");
JSONObject contentJSON = dataJSON.getJSONObject("content");
EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setId(JsonUtils.extractJsonInteger(dataJSON, "id"));
eventLogDetailed.setType(JsonUtils.extractJsonString(dataJSON, "type"));
eventLogDetailed.setStatus(JsonUtils.extractJsonString(dataJSON, "status"));
eventLogDetailed.setRemark(JsonUtils.extractJsonString(dataJSON, "remark"));
eventLogDetailed.setPayableAmount(JsonUtils.extractJsonString(dataJSON, "payable_amount"));
eventLogDetailed.setPayFunction(JsonUtils.extractJsonString(dataJSON, "pay_function"));
eventLogDetailed.setConfirmationNumber(JsonUtils.extractJsonString(contentJSON, "confirmation_number"));
eventLogDetailed.setReferenceNumber(JsonUtils.extractJsonString(contentJSON, "reference_number"));
eventLogDetailed.setPayAuthCode(JsonUtils.extractJsonString(dataJSON, "pay_auth_code"));
eventLogDetailed.setPayRefNum(JsonUtils.extractJsonString(dataJSON, "pay_ref_num"));
eventLogDetailed.setToken(JsonUtils.extractJsonString(dataJSON, "token"));
return eventLogDetailed;
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return null;
}
}
return null;
}
}

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

@ -0,0 +1,156 @@
package com.cst.im30.service;
import androidx.annotation.NonNull;
import com.cst.im30.BuildConfig;
import com.cst.im30.api.RetrofitAPICollection;
import com.cst.im30.api.RetrofitClient;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.PreAuthResponse;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.utility.Logger;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UploadTransactionPreAuthPaymentService {
public static final String TAG = "UploadTransactionPreAuthPaymentService.";
public static final String SUCCESS = TAG + "SUCCESS";
public static final String FAIL = TAG + "FAIL";
private final CallableInterface callback;
private final String hostUrl;
private final String clientId;
private final String clientSecret;
public UploadTransactionPreAuthPaymentService(CallableInterface callback) {
this.callback = callback;
this.hostUrl = BuildConfig.SERVER_URL;
this.clientId = BuildConfig.CLIENT_ID;
this.clientSecret = BuildConfig.CLIENT_SECRET;
}
public void call(EventLogDetailed eventLogDetailed, PreAuthRequest request, PreAuthResponse response) {
JSONObject payload = new JSONObject();
try {
payload.put("revpay_request", createPreAuthRequestJSONObject(eventLogDetailed, request));
payload.put("revpay_response", createPreAuthResponseJSONObject(eventLogDetailed, response));
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return;
}
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.uploadRevPayTransaction(clientId, clientSecret, payload.toString());
Logger.logD(payload.toString());
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseHandler(response);
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureHandler(t);
}
});
}
private void onResponseHandler(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
}
callback.callBack(FAIL, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
callback.callBack(SUCCESS, responseJSON);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureHandler(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL, t.getMessage());
}
private JSONObject createPreAuthRequestJSONObject(EventLogDetailed eventLogDetailed, PreAuthRequest request) {
JSONObject requestJSON = new JSONObject();
try {
requestJSON.put("confirmation_number", eventLogDetailed.getConfirmationNumber());
requestJSON.put("reference_number", eventLogDetailed.getReferenceNumber());
requestJSON.put("pay_function", request.getPayFunction());
requestJSON.put("pay_amount", request.getPayAmount());
requestJSON.put("pay_pos_txn_id", request.getPayPosTxnId());
requestJSON.put("pay_print_receipt_id", request.getPayPrintReceiptId());
requestJSON.put("remark", eventLogDetailed.getRemark());
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
return requestJSON;
}
private JSONObject createPreAuthResponseJSONObject(EventLogDetailed eventLogDetailed, PreAuthResponse response) {
JSONObject requestJSON = new JSONObject();
try {
requestJSON.put("confirmation_number", eventLogDetailed.getConfirmationNumber());
requestJSON.put("reference_number", eventLogDetailed.getReferenceNumber());
requestJSON.put("pay_amount", response.getPayAmount());
requestJSON.put("pay_function", response.getPayFunction());
requestJSON.put("pay_type", response.getPayType());
requestJSON.put("pay_print_receipt_id", response.getPayPrintReceiptId());
requestJSON.put("pay_resp_txn_date", response.getPayRespTxnDate());
requestJSON.put("pay_resp_txn_time", response.getPayRespTxnTime());
requestJSON.put("pay_resp_invoice_no", response.getPayRespInvoiceNo());
requestJSON.put("pay_resp_trace_no", response.getPayRespTraceNo());
requestJSON.put("pay_resp_batch_no", response.getPayRespBatchNo());
requestJSON.put("pay_resp_scheme", response.getPayRespScheme());
requestJSON.put("pay_resp_tid", response.getPayRespTid());
requestJSON.put("pay_resp_mid", response.getPayRespMid());
requestJSON.put("pay_resp_card_auth_code", response.getPayRespCardAuthCode());
requestJSON.put("pay_resp_card_ref_num", response.getPayRespCardRefNum());
requestJSON.put("pay_resp_card_no", response.getPayRespCardNo());
requestJSON.put("pay_resp_issuer_id", response.getPayRespIssuerId());
requestJSON.put("pay_resp_card_aid", response.getPayRespCardAid());
requestJSON.put("pay_resp_card_app_cryptogram", response.getPayRespCardAppCryptogram());
requestJSON.put("pay_resp_code", response.getPayRespCode());
requestJSON.put("pay_resp_error_desc", response.getPayRespErrorDesc());
requestJSON.put("pay_resp_merch_info", response.getPayRespMerchInfo());
requestJSON.put("pay_resp_tvr", response.getPayRespTvr());
requestJSON.put("pay_resp_cvm_desc", response.getPayRespCvmDesc());
requestJSON.put("pay_resp_app_label", response.getPayRespAppLabel());
requestJSON.put("pay_resp_hash_pan", response.getPayRespHashPan());
requestJSON.put("token", response.getToken());
requestJSON.put("remark", eventLogDetailed.getRemark());
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
return requestJSON;
}
}

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

@ -0,0 +1,158 @@
package com.cst.im30.service;
import androidx.annotation.NonNull;
import com.cst.im30.BuildConfig;
import com.cst.im30.api.RetrofitAPICollection;
import com.cst.im30.api.RetrofitClient;
import com.cst.im30.common.CallableInterface;
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.utility.Logger;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UploadTransactionSaleCompletionPaymentService {
public static final String TAG = "UploadTransactionSaleCompletionPaymentService.";
public static final String SUCCESS = TAG + "SUCCESS";
public static final String FAIL = TAG + "FAIL";
private final CallableInterface callback;
private final String hostUrl;
private final String clientId;
private final String clientSecret;
public UploadTransactionSaleCompletionPaymentService(CallableInterface callback) {
this.callback = callback;
this.hostUrl = BuildConfig.SERVER_URL;
this.clientId = BuildConfig.CLIENT_ID;
this.clientSecret = BuildConfig.CLIENT_SECRET;
}
public void call(EventLogDetailed eventLogDetailed, SaleCompletionRequest request, SaleCompletionResponse response) {
JSONObject payload = new JSONObject();
try {
payload.put("revpay_request", createSaleCompletionRequestJSONObject(eventLogDetailed, request));
payload.put("revpay_response", createSaleCompletionResponseJSONObject(eventLogDetailed, response));
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return;
}
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.uploadRevPayTransaction(clientId, clientSecret, payload.toString());
Logger.logD(payload.toString());
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseHandler(response);
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureHandler(t);
}
});
}
private void onResponseHandler(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
}
callback.callBack(FAIL, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
callback.callBack(SUCCESS, responseJSON);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureHandler(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL, t.getMessage());
}
private JSONObject createSaleCompletionRequestJSONObject(EventLogDetailed eventLogDetailed, SaleCompletionRequest request) {
JSONObject requestJSON = new JSONObject();
try {
requestJSON.put("confirmation_number", eventLogDetailed.getConfirmationNumber());
requestJSON.put("reference_number", eventLogDetailed.getReferenceNumber());
requestJSON.put("pay_function", request.getPayFunction());
requestJSON.put("pay_amount", request.getPayAmount());
requestJSON.put("pay_auth_code", request.getPayAuthCode());
requestJSON.put("pay_ref_num", request.getPayRefNum());
requestJSON.put("pay_pos_txn_id", request.getPayPosTxnId());
requestJSON.put("pay_print_receipt_id", request.getPayPrintReceiptId());
requestJSON.put("token", request.getToken());
requestJSON.put("remark", eventLogDetailed.getRemark());
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
return requestJSON;
}
private JSONObject createSaleCompletionResponseJSONObject(EventLogDetailed eventLogDetailed, SaleCompletionResponse response) {
JSONObject requestJSON = new JSONObject();
try {
requestJSON.put("confirmation_number", eventLogDetailed.getConfirmationNumber());
requestJSON.put("reference_number", eventLogDetailed.getReferenceNumber());
requestJSON.put("pay_amount", response.getPayAmount());
requestJSON.put("pay_function", response.getPayFunction());
requestJSON.put("pay_type", response.getPayType());
requestJSON.put("pay_print_receipt_id", response.getPayPrintReceiptId());
requestJSON.put("pay_resp_txn_date", response.getPayRespTxnDate());
requestJSON.put("pay_resp_txn_time", response.getPayRespTxnTime());
requestJSON.put("pay_resp_invoice_no", response.getPayRespInvoiceNo());
requestJSON.put("pay_resp_trace_no", response.getPayRespTraceNo());
requestJSON.put("pay_resp_batch_no", response.getPayRespBatchNo());
requestJSON.put("pay_resp_scheme", response.getPayRespScheme());
requestJSON.put("pay_resp_tid", response.getPayRespTid());
requestJSON.put("pay_resp_mid", response.getPayRespMid());
requestJSON.put("pay_resp_card_auth_code", response.getPayRespCardAuthCode());
requestJSON.put("pay_resp_card_ref_num", response.getPayRespCardRefNum());
requestJSON.put("pay_resp_card_no", response.getPayRespCardNo());
requestJSON.put("pay_resp_issuer_id", response.getPayRespIssuerId());
requestJSON.put("pay_resp_card_aid", response.getPayRespCardAid());
requestJSON.put("pay_resp_card_app_cryptogram", response.getPayRespCardAppCryptogram());
requestJSON.put("pay_resp_code", response.getPayRespCode());
requestJSON.put("pay_resp_error_desc", response.getPayRespErrorDesc());
requestJSON.put("pay_resp_merch_info", response.getPayRespMerchInfo());
requestJSON.put("pay_resp_tvr", response.getPayRespTvr());
requestJSON.put("pay_resp_cvm_desc", response.getPayRespCvmDesc());
requestJSON.put("pay_resp_app_label", response.getPayRespAppLabel());
requestJSON.put("pay_resp_hash_pan", response.getPayRespHashPan());
requestJSON.put("remark", eventLogDetailed.getRemark());
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
return requestJSON;
}
}

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

@ -0,0 +1,159 @@
package com.cst.im30.service;
import androidx.annotation.NonNull;
import com.cst.im30.BuildConfig;
import com.cst.im30.api.RetrofitAPICollection;
import com.cst.im30.api.RetrofitClient;
import com.cst.im30.common.CallableInterface;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.utility.Logger;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UploadTransactionSalePaymentService {
public static final String TAG = "UploadTransactionSalePaymentService.";
public static final String SUCCESS = TAG + "SUCCESS";
public static final String FAIL = TAG + "FAIL";
private final CallableInterface callback;
private final String hostUrl;
private final String clientId;
private final String clientSecret;
public UploadTransactionSalePaymentService(CallableInterface callback) {
this.callback = callback;
this.hostUrl = BuildConfig.SERVER_URL;
this.clientId = BuildConfig.CLIENT_ID;
this.clientSecret = BuildConfig.CLIENT_SECRET;
}
public void call(EventLogDetailed eventLogDetailed, SaleRequest saleRequest, SaleResponse saleResponse) {
JSONObject payload = new JSONObject();
try {
payload.put("revpay_request", createSaleRequestJSONObject(eventLogDetailed, saleRequest));
payload.put("revpay_response", createSaleResponseJSONObject(eventLogDetailed, saleResponse));
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return;
}
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.uploadRevPayTransaction(clientId, clientSecret, payload.toString());
Logger.logD(payload.toString());
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
onResponseHandler(response);
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
onFailureHandler(t);
}
});
}
private void onResponseHandler(Response<String> response) {
try {
if (!response.isSuccessful()) {
JSONObject responseJSON = null;
if (response.errorBody() != null) {
responseJSON = new JSONObject(response.errorBody().string());
}
callback.callBack(FAIL, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
callback.callBack(SUCCESS, responseJSON);
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureHandler(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
((Exception) t).printStackTrace();
}
callback.callBack(FAIL, t.getMessage());
}
private JSONObject createSaleRequestJSONObject(EventLogDetailed eventLogDetailed, SaleRequest saleRequest) {
JSONObject request = new JSONObject();
try {
request.put("confirmation_number", eventLogDetailed.getConfirmationNumber());
request.put("reference_number", eventLogDetailed.getReferenceNumber());
request.put("pay_function", saleRequest.getPayFunction());
request.put("pay_amount", saleRequest.getPayAmount());
request.put("pay_type", saleRequest.getPayType());
request.put("pay_camera_mode", saleRequest.getPayCameraMode());
request.put("pay_pos_txn_id", saleRequest.getPayPosTxnId());
request.put("pay_print_receipt_id", saleRequest.getPayPrintReceiptId());
request.put("remark", eventLogDetailed.getRemark());
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
return request;
}
private JSONObject createSaleResponseJSONObject(EventLogDetailed eventLogDetailed, SaleResponse saleResponse) {
JSONObject request = new JSONObject();
try {
request.put("confirmation_number", eventLogDetailed.getConfirmationNumber());
request.put("reference_number", eventLogDetailed.getReferenceNumber());
request.put("pay_amount", saleResponse.getPayAmount());
request.put("pay_function", saleResponse.getPayFunction());
request.put("pay_type", saleResponse.getPayType());
request.put("pay_camera_mode", saleResponse.getPayCameraMode());
request.put("pay_print_receipt_id", saleResponse.getPayPrintReceiptId());
request.put("pay_resp_txn_date", saleResponse.getPayRespTxnDate());
request.put("pay_resp_txn_time", saleResponse.getPayRespTxnTime());
request.put("pay_resp_invoice_no", saleResponse.getPayRespInvoiceNo());
request.put("pay_resp_trace_no", saleResponse.getPayRespTraceNo());
request.put("pay_resp_batch_no", saleResponse.getPayRespBatchNo());
request.put("pay_resp_scheme", saleResponse.getPayRespScheme());
request.put("pay_resp_tid", saleResponse.getPayRespTid());
request.put("pay_resp_mid", saleResponse.getPayRespMid());
request.put("pay_resp_card_auth_code", saleResponse.getPayRespCardAuthCode());
request.put("pay_resp_card_ref_num", saleResponse.getPayRespCardRefNum());
request.put("pay_resp_card_no", saleResponse.getPayRespCardNo());
request.put("pay_resp_issuer_id", saleResponse.getPayRespIssuerId());
request.put("pay_resp_card_aid", saleResponse.getPayRespCardAid());
request.put("pay_resp_card_app_cryptogram", saleResponse.getPayRespCardAppCryptogram());
request.put("pay_resp_qr_txn_id", saleResponse.getPayRespQrTxnId());
request.put("pay_resp_qr_wallet_id", saleResponse.getPayRespQrWalletId());
request.put("pay_resp_customer_id", saleResponse.getPayRespCustomerId());
request.put("pay_resp_code", saleResponse.getPayRespCode());
request.put("pay_resp_error_desc", saleResponse.getPayRespErrorDesc());
request.put("pay_resp_merch_info", saleResponse.getPayRespMerchInfo());
request.put("pay_resp_tvr", saleResponse.getPayRespTvr());
request.put("pay_resp_cvm_desc", saleResponse.getPayRespCvmDesc());
request.put("pay_resp_app_label", saleResponse.getPayRespAppLabel());
request.put("pay_resp_hash_pan", saleResponse.getPayRespHashPan());
request.put("remark", eventLogDetailed.getRemark());
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
return request;
}
}

42
app/src/main/java/com/cst/im30/utility/JsonUtils.java

@ -0,0 +1,42 @@
package com.cst.im30.utility;
import android.text.TextUtils;
import org.json.JSONObject;
public class JsonUtils {
public static String extractJsonString(JSONObject responseJSON, String name) {
try {
if (responseJSON.has(name)) {
return responseJSON.getString(name);
} else {
return ""; // null json will return "";
}
} catch (Exception ignored) {
return "";
}
}
public static int extractJsonInteger(JSONObject responseJSON, String name) {
return extractJsonInteger(responseJSON, name, -1);
}
public static int extractJsonInteger(JSONObject responseJSON, String name, int defaultValue) {
try {
String rv = responseJSON.getString(name).trim();
if (rv.isEmpty()) {
return defaultValue;
} else {
if (TextUtils.isDigitsOnly(rv)) {
return Integer.parseInt(rv);
} else {
return defaultValue;
}
}
} catch (Exception ignored) {
return defaultValue;
}
}
}

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

@ -2,18 +2,43 @@ package com.cst.im30.utility;
import android.util.Log;
import java.util.regex.Pattern;
public class Logger {
public static final String TAG = "CST";
public static void logD(String title, String message) {
public static void logD(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();
Log.d(TAG, title + " - " + message);
}
public static void logI(String title, String message) {
public static void logI(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();
Log.i(TAG, title + " - " + message);
}
public static void logV(String title, String message) {
public static void logV(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();
Log.v(TAG, title + " - " + message);
}
public static void logE(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();
Log.e(TAG, title + " - " + message);
}
public static void logWTF(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber();
Log.wtf(TAG, title + " - " + message);
}
private static String getClassSimpleName(String className) {
String[] strs = className.split(Pattern.quote("."));
return strs[strs.length - 1];
}
}

122
app/src/main/java/com/cst/im30/utility/PaymentUtils.java

@ -0,0 +1,122 @@
package com.cst.im30.utility;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleRequest;
import java.text.DecimalFormat;
public class PaymentUtils {
public static SaleRequest createSaleRequest(EventLogDetailed eventLogDetailed) {
SaleRequest request = new SaleRequest();
double doubleValue = Double.parseDouble(eventLogDetailed.getPayableAmount());
double centValueDouble = doubleValue * 100;
DecimalFormat df = new DecimalFormat("#");
request.setPayAmount(String.valueOf(df.format(centValueDouble)));
request.setPayPosTxnId(eventLogDetailed.getReferenceNumber() + eventLogDetailed.getId());
return request;
}
public static PreAuthRequest createPreAuthRequest(EventLogDetailed eventLogDetailed) {
PreAuthRequest request = new PreAuthRequest();
double doubleValue = Double.parseDouble(eventLogDetailed.getPayableAmount());
double centValueDouble = doubleValue * 100;
DecimalFormat df = new DecimalFormat("#");
request.setPayAmount(String.valueOf(df.format(centValueDouble)));
request.setPayPosTxnId(eventLogDetailed.getReferenceNumber() + eventLogDetailed.getId());
return request;
}
public static SaleCompletionRequest createSaleCompletionRequest(EventLogDetailed eventLogDetailed) {
SaleCompletionRequest request = new SaleCompletionRequest();
double doubleValue = Double.parseDouble(eventLogDetailed.getPayableAmount());
double centValueDouble = doubleValue * 100;
DecimalFormat df = new DecimalFormat("#");
request.setPayAmount(String.valueOf(df.format(centValueDouble)));
request.setPayPosTxnId(eventLogDetailed.getReferenceNumber() + eventLogDetailed.getId());
request.setPayAuthCode(eventLogDetailed.getPayAuthCode());
request.setPayRefNum(eventLogDetailed.getPayRefNum());
request.setToken(eventLogDetailed.getToken());
return request;
}
public static boolean validateSaleRequest(SaleRequest request) {
boolean valid = true;
//todo
return valid;
}
public static boolean validatePreAuthRequest(PreAuthRequest request) {
boolean valid = true;
//todo
return valid;
}
public static boolean validateSaleCompletionRequest(SaleCompletionRequest request) {
boolean valid = true;
//todo
return valid;
}
public static boolean validateResponseCodeAndMessage(String code, String status) {
if (code.equalsIgnoreCase("00") && status.equalsIgnoreCase("approved")) {
Logger.logD("Transaction Approved");
return true;
}
if (code.equalsIgnoreCase("00") && status.equalsIgnoreCase("Offline Approval")) {
Logger.logD("Offline Approval");
return true;
}
else if (code.equalsIgnoreCase("00") && status.equalsIgnoreCase("declined")) {
Logger.logD("Transaction Approved but Declined ErrorCode");
return false;
}
else if (code.equalsIgnoreCase("ND")) {
Logger.logD("User Cancel or No Host Response");
return false;
}
else if (code.equalsIgnoreCase("99")) {
Logger.logD("Transaction Declined");
return false;
}
else if (code.equalsIgnoreCase("CE")) {
Logger.logD("Transaction Declined");
return false;
}
else if (code.equalsIgnoreCase("TO") && status.equalsIgnoreCase("timeout")) {
Logger.logD("Payment Timeout");
return false;
}
else {
Logger.logD("FAIL: Unsupported Combination: " + code + ":" + status);
return false;
}
}
}

35
app/src/main/res/layout/activity_main.xml

@ -22,9 +22,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="CST IC TEST"
android:textSize="40dp"
android:textStyle="bold"/>
android:text="Payment Terminal &amp; NRIC Checker"
android:textAlignment="center"
android:textSize="40sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/loading_image_mt"
@ -34,4 +36,31 @@
android:contentDescription="@string/app_name"
android:src="@drawable/loading" />
<Button
android:id="@+id/paymentTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/testText"
android:text="Payment Test"
android:visibility="gone"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/paymentPreAuthTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/paymentTest"
android:text="Pre-Auth Test"
android:visibility="gone"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/paymentCompletionTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/paymentPreAuthTest"
android:text="Completion Test"
android:visibility="gone"
tools:ignore="HardcodedText" />
</RelativeLayout>

252
app/src/main/res/layout/activity_response.xml

@ -7,256 +7,4 @@
android:orientation="vertical"
tools:context=".activity.ResponseActivity">
<TextView
android:id="@+id/title_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="0dp"
android:text="Received Payment Response"
android:textAlignment="center"
android:textColor="@color/teal_700"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/title_responses_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Response code return here..."
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="italic" />
<TextView
android:id="@+id/title_responses"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/teal_700"
android:gravity="center"
android:scrollbars="vertical"
android:text="Response code return here..."
android:textColor="@color/white"
android:textSize="15dp"
app:layout_constraintBottom_toTopOf="@+id/textview_response"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.188" />
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_responses"
android:background="@color/black"
android:layout_marginBottom="10dp"
android:layout_gravity="right"
android:textSize="20dp"
android:textStyle="italic"
android:textColor="@color/green"
android:text="Response code return here..." />-->
<TextView
android:id="@+id/title_status_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Payment Code Status"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="italic" />
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_status"
android:background="@color/black"
android:layout_marginBottom="10dp"
android:layout_gravity="right"
android:textSize="20dp"
android:textStyle="italic"
android:textColor="@color/green"
android:text="Payment Status" />-->
<TextView
android:id="@+id/title_status"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/teal_700"
android:gravity="center"
android:scrollbars="vertical"
android:text="Payment Status..."
android:textColor="@color/white"
android:textSize="15dp"
app:layout_constraintBottom_toTopOf="@+id/textview_response"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.188" />
<TextView
android:id="@+id/title_reference_number_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Payment Reference No"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="italic" />
<TextView
android:id="@+id/title_reference_number"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/teal_700"
android:gravity="center"
android:scrollbars="vertical"
android:text="Payment Reference No..."
android:textColor="@color/white"
android:textSize="15dp"
app:layout_constraintBottom_toTopOf="@+id/textview_response"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.188" />
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_reference_number"
android:background="@color/black"
android:layout_marginBottom="10dp"
android:layout_gravity="right"
android:textSize="20dp"
android:textStyle="italic"
android:textColor="@color/green"
android:text="Payment Reference No" />-->
<TextView
android:id="@+id/title_error_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Payment Error Description"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="italic" />
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_error"
android:background="@color/black"
android:layout_marginBottom="10dp"
android:layout_gravity="right"
android:textSize="20dp"
android:textStyle="italic"
android:textColor="@color/green"
android:text="Payment Error Description" />-->
<TextView
android:id="@+id/title_error"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/teal_700"
android:gravity="center"
android:scrollbars="vertical"
android:text="Payment Error Description..."
android:textColor="@color/white"
android:textSize="15dp"
app:layout_constraintBottom_toTopOf="@+id/textview_response"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.188" />
<TextView
android:id="@+id/title_amount_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Payment Amount"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="italic" />
<TextView
android:id="@+id/title_amount"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/teal_700"
android:gravity="center"
android:scrollbars="vertical"
android:text="Payment Amount..."
android:textColor="@color/white"
android:textSize="15dp"
app:layout_constraintBottom_toTopOf="@+id/textview_response"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.188" />
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_amount"
android:background="@color/black"
android:layout_marginBottom="0dp"
android:layout_gravity="right"
android:textSize="20dp"
android:textStyle="italic"
android:textColor="@color/green"
android:text="Payment Amount" />-->
<TextView
android:id="@+id/title_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="20dp"
android:layout_marginBottom="0dp"
android:text="00 = Transaction approved"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="bold" />
<TextView
android:id="@+id/title_bottoms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:text="ND = User cancel/no host response etc"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="bold" />
<TextView
android:id="@+id/title_bottomss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:text="99 or other code = transaction declined"
android:textColor="@color/black"
android:textSize="10dp"
android:textStyle="bold" />
<Button
android:id="@+id/button_ok_ra"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="20dp"
android:background="@drawable/btn_general_enable_bg"
android:text="@string/btn_back_to_complete"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>

53
app/src/main/res/layout/pop_up_notification.xml

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/pop_up_bg"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/pop_up_round_top_text"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:text="@string/txt_title"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:paddingEnd="20dp"
android:paddingBottom="20dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/image"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:contentDescription="@string/txt_image_description"
android:src="@drawable/ic_status_success_fancy"
android:textAlignment="center" />
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/image"
android:layout_marginTop="16dp"
android:text="@string/txt_message"
android:textAlignment="center"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>

2
app/src/main/res/values/strings.xml

@ -73,5 +73,7 @@
<string name="btn_ok_donation_status">Ok</string>
<string name="btn_pay_again_status">Retry Payment</string>
<string name="btn_no_pay_again_status">Cancel</string>
<string name="success">Success</string>
<string name="fail">Fail</string>
</resources>

22
gradle.properties

@ -15,4 +15,24 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
# Terminal Specific Config
SERVER_URL="http://hello-booking-api-build.testpigeon.net"
CLIENT_ID="3"
CLIENT_SECRET="w5RJ7bMF6NH39aDVyJJV0M1gOg0nZQcO2atVcXyF"
ECHO_SERVER_URL="http://hello-booking-api-build.testpigeon.net"
ECHO_SERVER_PORT="6001"
KIOSK_CODE="KIOSK002"
SOCKET_PREFIX="HelloBookingApi_"
PAYMENT_CHANNEL_ID="payment#"
PAYMENT_EVENT_TYPE=".makepayment"
IC_CHANNEL_ID="verification#"
IC_EVENT_TYPE=".guestverification"
Loading…
Cancel
Save