diff --git a/app/src/main/java/com/cst/im30/EchoClient.java b/app/src/main/java/com/cst/im30/EchoClient.java index 4312347..ce62478 100644 --- a/app/src/main/java/com/cst/im30/EchoClient.java +++ b/app/src/main/java/com/cst/im30/EchoClient.java @@ -1,7 +1,5 @@ package com.cst.im30; -import com.cst.im30.activity.MainActivity; - import net.mrbin99.laravelechoandroid.Echo; import net.mrbin99.laravelechoandroid.EchoCallback; import net.mrbin99.laravelechoandroid.EchoOptions; @@ -9,8 +7,8 @@ import net.mrbin99.laravelechoandroid.channel.SocketIOChannel; public class EchoClient { - private Echo echo; private final EchoOptions options; + private Echo echo; public EchoClient(String host) { diff --git a/app/src/main/java/com/cst/im30/EchoClientSetting.java b/app/src/main/java/com/cst/im30/EchoClientSetting.java index 00ec8f3..6a91d37 100644 --- a/app/src/main/java/com/cst/im30/EchoClientSetting.java +++ b/app/src/main/java/com/cst/im30/EchoClientSetting.java @@ -1,7 +1,5 @@ package com.cst.im30; -import com.cst.im30.activity.SettingActivity; - import net.mrbin99.laravelechoandroid.Echo; import net.mrbin99.laravelechoandroid.EchoCallback; import net.mrbin99.laravelechoandroid.EchoOptions; @@ -9,8 +7,8 @@ import net.mrbin99.laravelechoandroid.channel.SocketIOChannel; public class EchoClientSetting { - private Echo echo; private final EchoOptions options; + private Echo echo; public EchoClientSetting(String host) { diff --git a/app/src/main/java/com/cst/im30/MainApplication.java b/app/src/main/java/com/cst/im30/MainApplication.java index f9edc31..86778f3 100644 --- a/app/src/main/java/com/cst/im30/MainApplication.java +++ b/app/src/main/java/com/cst/im30/MainApplication.java @@ -29,50 +29,34 @@ import com.cst.im30.model.VoidResponse; import com.cst.im30.utility.CloudWatchLogger; import com.cst.im30.utility.Logger; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; - public class MainApplication extends Application { + public static final int MAX_RETRY = 10; public static MainApplication instance; - public static AppCompatActivity currentActivity; - - private CloudWatchLogger cloudWatchLogger; - public static EchoClient paymentClient; public static EchoClient icClient; public static boolean paymentIsConnected = false; public static boolean icIsConnected = false; - - public static final int MAX_RETRY = 10; public static int failCountIC = 0; public static int failCountPayment = 0; - public static boolean working = false; - public static String incomingCode = null; public static String currentCode = null; public static EventLogDetailed currentEventLogDetailed = null; - public static SaleRequest currentSaleRequest = null; public static SaleResponse currentSaleResponse = null; - public static VoidRequest currentVoidRequest = null; public static VoidResponse currentVoidResponse = null; - public static CancelRequest currentCancelRequest = null; public static CancelResponse currentCancelResponse = null; - public static PreAuthRequest currentPreAuthRequest = null; public static PreAuthResponse currentPreAuthResponse = null; - public static SaleCompletionRequest currentSaleCompletionRequest = null; public static SaleCompletionResponse currentSaleCompletionResponse = null; - public static String code; public static String status; + private CloudWatchLogger cloudWatchLogger; public static MainApplication getInstance() { return instance; diff --git a/app/src/main/java/com/cst/im30/PaymentHandler.java b/app/src/main/java/com/cst/im30/PaymentHandler.java index bfefb1a..2c8ec4e 100644 --- a/app/src/main/java/com/cst/im30/PaymentHandler.java +++ b/app/src/main/java/com/cst/im30/PaymentHandler.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.os.Bundle; import android.widget.Toast; -import com.cst.im30.activity.ResponseActivity; import com.cst.im30.common.Constants; import com.cst.im30.model.CancelRequest; import com.cst.im30.model.CancelResponse; @@ -18,9 +17,6 @@ import com.cst.im30.model.SaleRequest; import com.cst.im30.model.SaleResponse; import com.cst.im30.model.VoidRequest; import com.cst.im30.model.VoidResponse; -import com.cst.im30.service.UploadTransactionPreAuthPaymentService; -import com.cst.im30.service.UploadTransactionSaleCompletionPaymentService; -import com.cst.im30.service.UploadTransactionSalePaymentService; import com.cst.im30.utility.Logger; import com.cst.im30.utility.PaymentUtils; diff --git a/app/src/main/java/com/cst/im30/activity/ICCActivity.java b/app/src/main/java/com/cst/im30/activity/ICCActivity.java index 7cfd48b..3c4003a 100644 --- a/app/src/main/java/com/cst/im30/activity/ICCActivity.java +++ b/app/src/main/java/com/cst/im30/activity/ICCActivity.java @@ -362,6 +362,13 @@ public class ICCActivity extends AppCompatActivity { return sb.toString(); } + @Override + protected void onResume() { + super.onResume(); + + MainApplication.currentActivity = this; + } + public class IccDetectedThread extends Thread { @Override public void run() { @@ -468,8 +475,6 @@ public class ICCActivity extends AppCompatActivity { } } - - public class CardDetectedThread extends Thread { @Override public void run() { @@ -527,11 +532,4 @@ public class ICCActivity extends AppCompatActivity { IccTester.getInstance(ICCActivity.this).light(false); } } - - @Override - protected void onResume() { - super.onResume(); - - MainApplication.currentActivity = this; - } } diff --git a/app/src/main/java/com/cst/im30/activity/MainActivity.java b/app/src/main/java/com/cst/im30/activity/MainActivity.java index 8262226..0836ff0 100644 --- a/app/src/main/java/com/cst/im30/activity/MainActivity.java +++ b/app/src/main/java/com/cst/im30/activity/MainActivity.java @@ -60,21 +60,6 @@ import java.util.regex.Pattern; public class MainActivity extends AppCompatActivity implements CallableInterface { public static final String TAG = "MainActivity."; - - private ImageView load; - private AnimationDrawable animationDrawable; - - // Echo Server Connection - private LinearLayout echoStatusLayout; - private ImageView paymentEchoStatusImageView, icEchoStatusImageView; - private TextView paymentEchoStatusTextView, icEchoStatusTextView; - - private TextView testTitle; //todo until new screen - - private SliderLayout sliderLayout; - - private PaymentHandler paymentHandler; - ActivityResultLauncher icVerificationLauncher = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), result -> { @@ -105,6 +90,15 @@ public class MainActivity extends AppCompatActivity implements CallableInterface service.verifyFail(MainApplication.currentCode); } }); + private ImageView load; + private AnimationDrawable animationDrawable; + // Echo Server Connection + private LinearLayout echoStatusLayout; + private ImageView paymentEchoStatusImageView, icEchoStatusImageView; + private TextView paymentEchoStatusTextView, icEchoStatusTextView; + private TextView testTitle; //todo until new screen + private SliderLayout sliderLayout; + private PaymentHandler paymentHandler; @RequiresApi(api = Build.VERSION_CODES.M) @Override @@ -238,7 +232,6 @@ public class MainActivity extends AppCompatActivity implements CallableInterface } - private void setupTextSlider() { TextSliderView textSliderView = new TextSliderView(this); //textSliderView.description("Welcome to XXX."); @@ -334,7 +327,6 @@ public class MainActivity extends AppCompatActivity implements CallableInterface } - private void receiveMessagePayment(Object... args) { Logger.logD("Received Payment Message"); @@ -408,9 +400,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface } } else if (source.equalsIgnoreCase(IDVerificationService.FAIL_GET_EVENT_LOG)) { resetView(); //todo try again? fail? - } - - else if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_UPDATE_EVENT_LOG)) { + } else if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_UPDATE_EVENT_LOG)) { resetView(); } else if (source.equalsIgnoreCase(IDVerificationService.FAIL_UPDATE_EVENT_LOG)) { resetView(); //todo try again? fail? (avoid infinite loop) @@ -441,15 +431,11 @@ public class MainActivity extends AppCompatActivity implements CallableInterface } } else if (source.equalsIgnoreCase(PaymentService.FAIL_GET_EVENT_LOG)) { resetView(); //todo try again? ^ - } - - else if (source.equalsIgnoreCase(PaymentService.SUCCESS_UPDATE_EVENT_LOG)) { + } else if (source.equalsIgnoreCase(PaymentService.SUCCESS_UPDATE_EVENT_LOG)) { resetView(); } else if (source.equalsIgnoreCase(PaymentService.FAIL_UPDATE_EVENT_LOG)) { resetView(); //todo try again? ^ - } - - else if (source.equalsIgnoreCase(IDVerificationService.REJECT_EVENT_LOG)) { + } else if (source.equalsIgnoreCase(IDVerificationService.REJECT_EVENT_LOG)) { String codeReject = (String) object; Logger.logI("Rejected Broadcast: " + codeReject); MainApplication.incomingCode = null; @@ -458,7 +444,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface Logger.logI("Rejected Broadcast: " + codeReject); MainApplication.incomingCode = null; } - + // Payment Response else if (UploadTransactionSalePaymentService.SUCCESS.equalsIgnoreCase(source)) { @@ -485,9 +471,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface PaymentService service = new PaymentService(this); service.verifyFail(MainApplication.currentCode); } - } - - else if (UploadTransactionSalePaymentService.FAIL.equalsIgnoreCase(source)) { + } else if (UploadTransactionSalePaymentService.FAIL.equalsIgnoreCase(source)) { PaymentService service = new PaymentService(this); service.verifyFail(MainApplication.currentCode); } else if (UploadTransactionPreAuthPaymentService.FAIL.equalsIgnoreCase(source)) { @@ -496,9 +480,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface } else if (UploadTransactionSaleCompletionPaymentService.FAIL.equalsIgnoreCase(source)) { PaymentService service = new PaymentService(this); service.verifyFail(MainApplication.currentCode); - } - - else if (PaymentService.SUCCESS_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) { + } else if (PaymentService.SUCCESS_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) { processPaymentResponse(); resetView(); } else if (PaymentService.FAIL_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) { @@ -555,9 +537,6 @@ public class MainActivity extends AppCompatActivity implements CallableInterface // --- PAYMENT --------------------------------------------------------------------------------- - - - // --- MISC ------------------------------------------------------------------------------------ @Override @@ -579,12 +558,16 @@ public class MainActivity extends AppCompatActivity implements CallableInterface } private void connectEchoClientIC() { - if (MainApplication.icIsConnected) { return; } + if (MainApplication.icIsConnected) { + return; + } MainApplication.icClient.connect(this::onConnectSuccessIC, this::onConnectFailureIC); } private void connectEchoClientPayment() { - if (MainApplication.paymentIsConnected) { return; } + if (MainApplication.paymentIsConnected) { + return; + } MainApplication.paymentClient.connect(this::onConnectSuccessPayment, this::onConnectFailurePayment); } @@ -778,7 +761,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface dlg.dismiss(); } }; - mHandler.postDelayed(mRunnable,3000); + mHandler.postDelayed(mRunnable, 3000); } /*private void setupCloudWatch() { diff --git a/app/src/main/java/com/cst/im30/activity/ResponseActivity.java b/app/src/main/java/com/cst/im30/activity/ResponseActivity.java index 6f0865e..efc9d07 100644 --- a/app/src/main/java/com/cst/im30/activity/ResponseActivity.java +++ b/app/src/main/java/com/cst/im30/activity/ResponseActivity.java @@ -2,9 +2,6 @@ package com.cst.im30.activity; import android.content.Intent; import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; @@ -12,13 +9,9 @@ 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; import com.cst.im30.model.CancelResponse; import com.cst.im30.model.PreAuthResponse; -import com.cst.im30.model.SaleCompletionRequest; import com.cst.im30.model.SaleCompletionResponse; -import com.cst.im30.model.SaleRequest; import com.cst.im30.model.SaleResponse; import com.cst.im30.model.VoidResponse; import com.cst.im30.service.PaymentService; @@ -60,23 +53,17 @@ public class ResponseActivity extends AppCompatActivity implements CallableInter if (Constants.PAY_FUNCTION_SALE.equalsIgnoreCase(payFunction)) { handlePayFunctionSale(extra); - } - else if (Constants.PAY_FUNCTION_VOID.equalsIgnoreCase(payFunction)) { + } else if (Constants.PAY_FUNCTION_VOID.equalsIgnoreCase(payFunction)) { handlePayFunctionVoid(extra); - } - else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) { + } else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) { handlePayFunctionCancel(extra); - } - else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) { + } else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) { handlePayFunctionPreAuth(extra); - } - else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) { + } else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) { handlePayFunctionSaleCompletion(extra); - } - else if (payFunction == null || payFunction.isEmpty()) { + } else if (payFunction == null || payFunction.isEmpty()) { finishActivity(false); - } - else { + } else { Logger.logW("Unsupported Pay Function: " + payFunction); } } @@ -289,9 +276,7 @@ public class ResponseActivity extends AppCompatActivity implements CallableInter PaymentService service = new PaymentService(ResponseActivity.this); service.verifyFail(MainApplication.currentCode); } - } - - else if (UploadTransactionSalePaymentService.FAIL.equalsIgnoreCase(source)) { + } else if (UploadTransactionSalePaymentService.FAIL.equalsIgnoreCase(source)) { PaymentService service = new PaymentService(ResponseActivity.this); service.verifyFail(MainApplication.currentCode); } else if (UploadTransactionPreAuthPaymentService.FAIL.equalsIgnoreCase(source)) { @@ -300,9 +285,7 @@ public class ResponseActivity extends AppCompatActivity implements CallableInter } 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)) { + } else if (PaymentService.SUCCESS_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) { finishActivity(true); } else if (PaymentService.FAIL_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) { finishActivity(true); diff --git a/app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java b/app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java index 7c98fc0..af23c42 100644 --- a/app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java +++ b/app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java @@ -59,21 +59,6 @@ public interface RetrofitAPICollection { ); - - - - - - - - - - - - - - - @Headers({ "Accept: application/json" }) diff --git a/app/src/main/java/com/cst/im30/api/RetrofitClient.java b/app/src/main/java/com/cst/im30/api/RetrofitClient.java index c617e33..405d342 100644 --- a/app/src/main/java/com/cst/im30/api/RetrofitClient.java +++ b/app/src/main/java/com/cst/im30/api/RetrofitClient.java @@ -1,18 +1,8 @@ package com.cst.im30.api; -import android.util.Log; - -import androidx.annotation.NonNull; - -import com.cst.im30.utility.Logger; - -import java.io.IOException; import java.util.concurrent.TimeUnit; -import okhttp3.Interceptor; import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.scalars.ScalarsConverterFactory; diff --git a/app/src/main/java/com/cst/im30/model/CancelRequest.java b/app/src/main/java/com/cst/im30/model/CancelRequest.java index 4aaf729..ea3e39d 100644 --- a/app/src/main/java/com/cst/im30/model/CancelRequest.java +++ b/app/src/main/java/com/cst/im30/model/CancelRequest.java @@ -7,7 +7,9 @@ import lombok.Data; @Data public class CancelRequest implements Serializable { - /** Mandatory 2 - 07 - Cancel **/ + /** + * Mandatory 2 - 07 - Cancel + **/ private String payFunction = "07"; } diff --git a/app/src/main/java/com/cst/im30/model/InquiryRequest.java b/app/src/main/java/com/cst/im30/model/InquiryRequest.java index 37c8359..beb752f 100644 --- a/app/src/main/java/com/cst/im30/model/InquiryRequest.java +++ b/app/src/main/java/com/cst/im30/model/InquiryRequest.java @@ -7,19 +7,29 @@ import lombok.Data; @Data public class InquiryRequest implements Serializable { - /** Mandatory 2 - 03 - Inquiry **/ + /** + * Mandatory 2 - 03 - Inquiry + **/ private String payFunction = "03"; - /** Optional 12 - Original amount in cents (RM5.00 is "500") **/ + /** + * Optional 12 - Original amount in cents (RM5.00 is "500") + **/ private String payAmount; - /** Optional 1 - Y or N for Print Receipt or Not **/ + /** + * Optional 1 - Y or N for Print Receipt or Not + **/ private String payPrintReceiptId = "N"; - /** Conditional 6 - Original Trace Number **/ + /** + * Conditional 6 - Original Trace Number + **/ private String payTraceNo; - /** Conditional 6 - Original Invoice Number **/ + /** + * Conditional 6 - Original Invoice Number + **/ private String payInvoiceNo; } diff --git a/app/src/main/java/com/cst/im30/model/PreAuthRequest.java b/app/src/main/java/com/cst/im30/model/PreAuthRequest.java index dd8380f..d06d8ba 100644 --- a/app/src/main/java/com/cst/im30/model/PreAuthRequest.java +++ b/app/src/main/java/com/cst/im30/model/PreAuthRequest.java @@ -7,16 +7,24 @@ import lombok.Data; @Data public class PreAuthRequest implements Serializable { - /** Mandatory 2 - 09 - Pre Auth **/ + /** + * Mandatory 2 - 09 - Pre Auth + **/ private String payFunction = "09"; - /** Mandatory 12 - Amount in cents (RM5.00 is "500" **/ + /** + * Mandatory 12 - Amount in cents (RM5.00 is "500" + **/ private String payAmount; // - /** Optional 50 **/ + /** + * Optional 50 + **/ private String payPosTxnId; - /** Optional 1 - Y or N for Print Receipt or Not **/ + /** + * Optional 1 - Y or N for Print Receipt or Not + **/ private String payPrintReceiptId = "N"; diff --git a/app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java b/app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java index 93eb2eb..6faeb80 100644 --- a/app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java +++ b/app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java @@ -7,25 +7,39 @@ import lombok.Data; @Data public class SaleCompletionRequest implements Serializable { - /** Mandatory 2 - 10 - Sale Completion **/ + /** + * Mandatory 2 - 10 - Sale Completion + **/ private String payFunction = "10"; - /** Mandatory 12 - Amount in cents (RM5.00 is "500" **/ + /** + * Mandatory 12 - Amount in cents (RM5.00 is "500" + **/ private String payAmount; - /** Mandatory 6 - Pre Auth Transaction Approval Code **/ + /** + * Mandatory 6 - Pre Auth Transaction Approval Code + **/ private String payAuthCode; - /** Optional 12 - Pre Auth Transaction Reference Number **/ + /** + * Optional 12 - Pre Auth Transaction Reference Number + **/ private String payRefNum; - /** Optional 50 **/ + /** + * Optional 50 + **/ private String payPosTxnId; - /** Optional 1 - Y or N for Print Receipt or Not **/ + /** + * 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) **/ + /** + * Optional 50 - Pre Auth Card Token (Token + AuthCode + RefNum must be sent together) + **/ private String token; } diff --git a/app/src/main/java/com/cst/im30/model/SaleRequest.java b/app/src/main/java/com/cst/im30/model/SaleRequest.java index 850b814..e0ec72f 100644 --- a/app/src/main/java/com/cst/im30/model/SaleRequest.java +++ b/app/src/main/java/com/cst/im30/model/SaleRequest.java @@ -7,22 +7,34 @@ import lombok.Data; @Data public class SaleRequest implements Serializable { - /** Mandatory 2 - 01 - Sale **/ + /** + * Mandatory 2 - 01 - Sale + **/ private String payFunction = "01"; - /** Mandatory 12 - Amount in cents (RM5.00 is "500") **/ + /** + * Mandatory 12 - Amount in cents (RM5.00 is "500") + **/ private String payAmount; // - /** Mandatory 2 - 01 Card / 02 QR / 03 DuitNow QR **/ + /** + * Mandatory 2 - 01 Card / 02 QR / 03 DuitNow QR + **/ private String payType = "01"; - /** Conditional 2 - 01 Back / 02 Front **/ + /** + * Conditional 2 - 01 Back / 02 Front + **/ private String payCameraMode = "01"; - /** Optional 50 **/ + /** + * Optional 50 + **/ private String payPosTxnId; - /** Optional 1 - Y or N for Print Receipt or Not **/ + /** + * Optional 1 - Y or N for Print Receipt or Not + **/ private String payPrintReceiptId = "N"; } diff --git a/app/src/main/java/com/cst/im30/model/SetDateTimeRequest.java b/app/src/main/java/com/cst/im30/model/SetDateTimeRequest.java index 7b697c8..54c7a17 100644 --- a/app/src/main/java/com/cst/im30/model/SetDateTimeRequest.java +++ b/app/src/main/java/com/cst/im30/model/SetDateTimeRequest.java @@ -7,13 +7,19 @@ import lombok.Data; @Data public class SetDateTimeRequest implements Serializable { - /** Mandatory 2 - 12 - Set Date Time **/ + /** + * Mandatory 2 - 12 - Set Date Time + **/ private String payFunction = "12"; - /** Mandatory 8 - YYYYMMDD **/ + /** + * Mandatory 8 - YYYYMMDD + **/ private String payPosTxnDate; - /** Mandatory 6 - HHMMSS **/ + /** + * Mandatory 6 - HHMMSS + **/ private String payPosTxnTime; } diff --git a/app/src/main/java/com/cst/im30/model/SettlementRequest.java b/app/src/main/java/com/cst/im30/model/SettlementRequest.java index d7ed900..6e06271 100644 --- a/app/src/main/java/com/cst/im30/model/SettlementRequest.java +++ b/app/src/main/java/com/cst/im30/model/SettlementRequest.java @@ -7,13 +7,19 @@ import lombok.Data; @Data public class SettlementRequest implements Serializable { - /** Mandatory 2 - 11 - Settlement **/ + /** + * Mandatory 2 - 11 - Settlement + **/ private String payFunction = "11"; - /** Optional 1 - Y or N for Print Receipt or Not **/ + /** + * Optional 1 - Y or N for Print Receipt or Not + **/ private String payPrintReceiptId = "N"; - /** Optional 50 **/ + /** + * Optional 50 + **/ private String payPosTxnId; } diff --git a/app/src/main/java/com/cst/im30/model/VoidRequest.java b/app/src/main/java/com/cst/im30/model/VoidRequest.java index e62efac..83f2715 100644 --- a/app/src/main/java/com/cst/im30/model/VoidRequest.java +++ b/app/src/main/java/com/cst/im30/model/VoidRequest.java @@ -7,22 +7,34 @@ import lombok.Data; @Data public class VoidRequest implements Serializable { - /** Mandatory 2 - 02 - Void **/ + /** + * Mandatory 2 - 02 - Void + **/ private String payFunction = "02"; - /** Optional 12 - Original amount in cents (RM5.00 is "500") **/ + /** + * Optional 12 - Original amount in cents (RM5.00 is "500") + **/ private String payAmount; // - /** Optional 1 - Y or N for Print Receipt or Not **/ + /** + * Optional 1 - Y or N for Print Receipt or Not + **/ private String payPrintReceiptId = "N"; - /** Conditional 6 - Original Trace Number **/ + /** + * Conditional 6 - Original Trace Number + **/ private String payTraceNo; - /** Conditional 6 - Original Invoice Number **/ + /** + * Conditional 6 - Original Invoice Number + **/ private String payInvoiceNo; - /** Conditional 50 **/ + /** + * Conditional 50 + **/ private String payPosTxnId; } diff --git a/app/src/main/java/com/cst/im30/service/IDVerificationService.java b/app/src/main/java/com/cst/im30/service/IDVerificationService.java index f60c453..42a5176 100644 --- a/app/src/main/java/com/cst/im30/service/IDVerificationService.java +++ b/app/src/main/java/com/cst/im30/service/IDVerificationService.java @@ -3,11 +3,11 @@ 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.common.Constants; import com.cst.im30.model.EventLogDetailed; -import com.cst.im30.api.RetrofitAPICollection; -import com.cst.im30.api.RetrofitClient; import com.cst.im30.utility.Logger; import org.json.JSONException; diff --git a/app/src/main/java/com/cst/im30/service/PaymentService.java b/app/src/main/java/com/cst/im30/service/PaymentService.java index ef07554..abe3e7c 100644 --- a/app/src/main/java/com/cst/im30/service/PaymentService.java +++ b/app/src/main/java/com/cst/im30/service/PaymentService.java @@ -3,11 +3,11 @@ 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.common.Constants; 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; diff --git a/app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java b/app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java index bfb40f8..f46a41d 100644 --- a/app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java +++ b/app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java @@ -9,8 +9,6 @@ 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; diff --git a/app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java b/app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java index 7a48421..8fe9eb9 100644 --- a/app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java +++ b/app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java @@ -7,8 +7,6 @@ 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; diff --git a/app/src/main/java/com/cst/im30/utility/CloudWatchLogger.java b/app/src/main/java/com/cst/im30/utility/CloudWatchLogger.java index d8b624c..d57615d 100644 --- a/app/src/main/java/com/cst/im30/utility/CloudWatchLogger.java +++ b/app/src/main/java/com/cst/im30/utility/CloudWatchLogger.java @@ -1,7 +1,5 @@ package com.cst.im30.utility; -import android.os.Build; - import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.regions.Region; import com.amazonaws.regions.Regions; diff --git a/app/src/main/java/com/cst/im30/utility/Logger.java b/app/src/main/java/com/cst/im30/utility/Logger.java index 58a4a7a..e90cc8f 100644 --- a/app/src/main/java/com/cst/im30/utility/Logger.java +++ b/app/src/main/java/com/cst/im30/utility/Logger.java @@ -21,49 +21,49 @@ public class Logger { public static void logD(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.d(TAG, title + " - " + message); Bugfender.d("DEBUG", title + " - " + message); } public static void logI(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.i(TAG, title + " - " + message); Bugfender.i("INFO", title + " - " + message); } public static void logV(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.v(TAG, title + " - " + message); Bugfender.t("VERBOSE", title + " - " + message); } public static void logAPI(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.v(TAG, title + " - " + message); Bugfender.t("API", title + " - " + message); } public static void logE(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.e(TAG, title + " - " + message); Bugfender.e("ERROR", title + " - " + message); } public static void logW(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.w(TAG, title + " - " + message); Bugfender.w("DEBUG", title + " - " + message); } public static void logWTF(String message) { StackTraceElement l = new Exception().getStackTrace()[1]; - String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():"+l.getLineNumber(); + String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber(); Log.wtf(TAG, title + " - " + message); Bugfender.f("WTF", title + " - " + message); } @@ -111,8 +111,7 @@ public class Logger { Bugfender.i("IC SCAN", dataToWrite); MainApplication.getInstance().logICScan(dataToWrite); - } - catch (IOException e) { + } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } } diff --git a/app/src/main/java/com/cst/im30/utility/NRICApduUtils.java b/app/src/main/java/com/cst/im30/utility/NRICApduUtils.java index 9508f72..53bc2e8 100644 --- a/app/src/main/java/com/cst/im30/utility/NRICApduUtils.java +++ b/app/src/main/java/com/cst/im30/utility/NRICApduUtils.java @@ -1,6 +1,5 @@ package com.cst.im30.utility; -import android.annotation.SuppressLint; import android.content.Context; import java.util.Arrays; diff --git a/app/src/main/java/com/cst/im30/utility/PaymentUtils.java b/app/src/main/java/com/cst/im30/utility/PaymentUtils.java index d73e7e7..1336ed5 100644 --- a/app/src/main/java/com/cst/im30/utility/PaymentUtils.java +++ b/app/src/main/java/com/cst/im30/utility/PaymentUtils.java @@ -123,34 +123,22 @@ public class PaymentUtils { if (code.equalsIgnoreCase("00") && status.equalsIgnoreCase("Offline Approval")) { Logger.logD("Offline Approval"); return true; - } - - else if (code.equalsIgnoreCase("00") && status.equalsIgnoreCase("declined")) { + } else if (code.equalsIgnoreCase("00") && status.equalsIgnoreCase("declined")) { Logger.logD("Transaction Approved but Declined ErrorCode"); return false; - } - - else if (code.equalsIgnoreCase("ND")) { + } else if (code.equalsIgnoreCase("ND")) { Logger.logD("User Cancel or No Host Response"); return false; - } - - else if (code.equalsIgnoreCase("99")) { + } else if (code.equalsIgnoreCase("99")) { Logger.logD("Transaction Declined"); return false; - } - - else if (code.equalsIgnoreCase("CE")) { + } else if (code.equalsIgnoreCase("CE")) { Logger.logD("Transaction Declined"); return false; - } - - else if (code.equalsIgnoreCase("TO") && status.equalsIgnoreCase("timeout")) { + } else if (code.equalsIgnoreCase("TO") && status.equalsIgnoreCase("timeout")) { Logger.logD("Payment Timeout"); return false; - } - - else { + } else { Logger.logD("FAIL: Unsupported Combination: " + code + ":" + status); return false; } diff --git a/app/src/main/res/drawable/echo_ic_offline.xml b/app/src/main/res/drawable/echo_ic_offline.xml index e6b20c1..a92943c 100644 --- a/app/src/main/res/drawable/echo_ic_offline.xml +++ b/app/src/main/res/drawable/echo_ic_offline.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/echo_ic_online.xml b/app/src/main/res/drawable/echo_ic_online.xml index c45ee7c..8b0eb79 100644 --- a/app/src/main/res/drawable/echo_ic_online.xml +++ b/app/src/main/res/drawable/echo_ic_online.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/echo_payment_offline.xml b/app/src/main/res/drawable/echo_payment_offline.xml index 858ea60..a4dbc99 100644 --- a/app/src/main/res/drawable/echo_payment_offline.xml +++ b/app/src/main/res/drawable/echo_payment_offline.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/echo_payment_online.xml b/app/src/main/res/drawable/echo_payment_online.xml index b93e627..72f5955 100644 --- a/app/src/main/res/drawable/echo_payment_online.xml +++ b/app/src/main/res/drawable/echo_payment_online.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/layout_border.xml b/app/src/main/res/drawable/layout_border.xml index c308b73..7a40f2b 100644 --- a/app/src/main/res/drawable/layout_border.xml +++ b/app/src/main/res/drawable/layout_border.xml @@ -1,7 +1,13 @@ - - - - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 598daa0..da99acc 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".activity.MainActivity"> - + + android:layout_margin="16dp" + android:layout_weight="1" + android:background="@drawable/layout_border"> + + + android:textSize="16sp" + android:textStyle="bold" /> + + android:layout_margin="16dp" + android:layout_weight="1" + android:background="@drawable/layout_border"> + + + android:textSize="16sp" + android:textStyle="bold" /> diff --git a/app/src/main/res/layout/activity_response.xml b/app/src/main/res/layout/activity_response.xml index 59ee9a0..2c11e18 100644 --- a/app/src/main/res/layout/activity_response.xml +++ b/app/src/main/res/layout/activity_response.xml @@ -1,6 +1,5 @@