Browse Source

Merge pull request #1 from coresystemtech/payment_test

Payment test
hbw_build
Wong Joon Hui 2 years ago committed by GitHub
parent
commit
820fc71f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitignore
  2. 30
      .idea/misc.xml
  3. 44
      app/build.gradle
  4. 2
      app/src/androidTest/java/com/cst/im30/ExampleInstrumentedTest.java
  5. 20
      app/src/main/AndroidManifest.xml
  6. 12
      app/src/main/java/com/cst/im30/EchoClient.java
  7. 12
      app/src/main/java/com/cst/im30/EchoClientSetting.java
  8. 12
      app/src/main/java/com/cst/im30/ICEchoClient.java
  9. 164
      app/src/main/java/com/cst/im30/MainApplication.java
  10. 522
      app/src/main/java/com/cst/im30/PaymentHandler.java
  11. 127
      app/src/main/java/com/cst/im30/activity/ICCActivity.java
  12. 893
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  13. 510
      app/src/main/java/com/cst/im30/activity/ResponseActivity.java
  14. 28
      app/src/main/java/com/cst/im30/activity/SettingActivity.java
  15. 624
      app/src/main/java/com/cst/im30/activity/StatusActivity.java
  16. 49
      app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java
  17. 2
      app/src/main/java/com/cst/im30/api/RetrofitClient.java
  18. 2
      app/src/main/java/com/cst/im30/common/CallableInterface.java
  19. 50
      app/src/main/java/com/cst/im30/common/Constants.java
  20. 21
      app/src/main/java/com/cst/im30/common/Parcel.java
  21. 107
      app/src/main/java/com/cst/im30/common/Payment.java
  22. 400
      app/src/main/java/com/cst/im30/entity/Transaction.java
  23. 15
      app/src/main/java/com/cst/im30/model/CancelRequest.java
  24. 13
      app/src/main/java/com/cst/im30/model/CancelResponse.java
  25. 23
      app/src/main/java/com/cst/im30/model/EventLogDetailed.java
  26. 35
      app/src/main/java/com/cst/im30/model/InquiryRequest.java
  27. 29
      app/src/main/java/com/cst/im30/model/InquiryResponse.java
  28. 31
      app/src/main/java/com/cst/im30/model/PreAuthRequest.java
  29. 37
      app/src/main/java/com/cst/im30/model/PreAuthResponse.java
  30. 45
      app/src/main/java/com/cst/im30/model/SaleCompletionRequest.java
  31. 36
      app/src/main/java/com/cst/im30/model/SaleCompletionResponse.java
  32. 40
      app/src/main/java/com/cst/im30/model/SaleRequest.java
  33. 40
      app/src/main/java/com/cst/im30/model/SaleResponse.java
  34. 25
      app/src/main/java/com/cst/im30/model/SetDateTimeRequest.java
  35. 16
      app/src/main/java/com/cst/im30/model/SetDateTimeResponse.java
  36. 25
      app/src/main/java/com/cst/im30/model/SettlementRequest.java
  37. 21
      app/src/main/java/com/cst/im30/model/SettlementResponse.java
  38. 40
      app/src/main/java/com/cst/im30/model/VoidRequest.java
  39. 37
      app/src/main/java/com/cst/im30/model/VoidResponse.java
  40. 86
      app/src/main/java/com/cst/im30/retrofit/RetrofitAPICollection.java
  41. 190
      app/src/main/java/com/cst/im30/service/IDVerificationService.java
  42. 208
      app/src/main/java/com/cst/im30/service/PaymentService.java
  43. 154
      app/src/main/java/com/cst/im30/service/UploadTransactionPreAuthPaymentService.java
  44. 156
      app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.java
  45. 159
      app/src/main/java/com/cst/im30/service/UploadTransactionSalePaymentService.java
  46. 143
      app/src/main/java/com/cst/im30/utility/CloudWatchLogger.java
  47. 11
      app/src/main/java/com/cst/im30/utility/IccTester.java
  48. 42
      app/src/main/java/com/cst/im30/utility/JsonUtils.java
  49. 108
      app/src/main/java/com/cst/im30/utility/Logger.java
  50. 89
      app/src/main/java/com/cst/im30/utility/NRICApduUtils.java
  51. 206
      app/src/main/java/com/cst/im30/utility/PaymentUtils.java
  52. 170
      app/src/main/res/drawable-v24/ic_udc_launcher_background.xml
  53. 10
      app/src/main/res/drawable/echo_ic_offline.xml
  54. 10
      app/src/main/res/drawable/echo_ic_online.xml
  55. 10
      app/src/main/res/drawable/echo_payment_offline.xml
  56. 10
      app/src/main/res/drawable/echo_payment_online.xml
  57. 4
      app/src/main/res/drawable/ic_status_fail.xml
  58. 4
      app/src/main/res/drawable/ic_status_success.xml
  59. 13
      app/src/main/res/drawable/layout_border.xml
  60. 104
      app/src/main/res/layout/activity_main.xml
  61. 31
      app/src/main/res/layout/activity_pay.xml
  62. 253
      app/src/main/res/layout/activity_response.xml
  63. 189
      app/src/main/res/layout/activity_status.xml
  64. 6
      app/src/main/res/layout/pop_up_message_option.xml
  65. 53
      app/src/main/res/layout/pop_up_notification.xml
  66. 3
      app/src/main/res/layout/toolbar.xml
  67. 3
      app/src/main/res/layout/toolbar_setting.xml
  68. 5
      app/src/main/res/mipmap-anydpi-v26/ic_udc_launcher.xml
  69. 5
      app/src/main/res/mipmap-anydpi-v26/ic_udc_launcher_round.xml
  70. BIN
      app/src/main/res/mipmap-hdpi/ic_udc_launcher.png
  71. BIN
      app/src/main/res/mipmap-hdpi/ic_udc_launcher_foreground.png
  72. BIN
      app/src/main/res/mipmap-hdpi/ic_udc_launcher_round.png
  73. BIN
      app/src/main/res/mipmap-mdpi/ic_udc_launcher.png
  74. BIN
      app/src/main/res/mipmap-mdpi/ic_udc_launcher_foreground.png
  75. BIN
      app/src/main/res/mipmap-mdpi/ic_udc_launcher_round.png
  76. BIN
      app/src/main/res/mipmap-xhdpi/ic_udc_launcher.png
  77. BIN
      app/src/main/res/mipmap-xhdpi/ic_udc_launcher_foreground.png
  78. BIN
      app/src/main/res/mipmap-xhdpi/ic_udc_launcher_round.png
  79. BIN
      app/src/main/res/mipmap-xxhdpi/ic_udc_launcher.png
  80. BIN
      app/src/main/res/mipmap-xxhdpi/ic_udc_launcher_foreground.png
  81. BIN
      app/src/main/res/mipmap-xxhdpi/ic_udc_launcher_round.png
  82. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_udc_launcher.png
  83. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_udc_launcher_foreground.png
  84. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_udc_launcher_round.png
  85. 2
      app/src/main/res/values-night/themes.xml
  86. 3
      app/src/main/res/values/colors.xml
  87. 12
      app/src/main/res/values/strings.xml
  88. 2
      app/src/main/res/values/themes.xml
  89. 28
      gradle.properties
  90. BIN
      kiosk-im30-hello-kiosk.jks

3
.gitignore vendored

@ -13,3 +13,6 @@
.externalNativeBuild
.cxx
local.properties
/app/live/release/app.aab
/app/live/release/app-live-release.apk
/app/live/release/output.json

30
.idea/misc.xml

@ -3,7 +3,37 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable-v24/ic_udc_launcher_background.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/btn_general_disable_bg.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/btn_general_enable_bg.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/echo_ic_offline.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/echo_ic_online.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/echo_payment_offline.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/echo_payment_online.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_account_box_24_green.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_account_box_24_on.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_account_box_24_red.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_keyboard_return_24.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_payment_24.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_payment_24_on.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_baseline_settings_24.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_launcher_background.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_status_fail.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/ic_status_success.xml" value="0.21354166666666666" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/layout_border.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/pop_up_bg.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/drawable/pop_up_round_top_text.xml" value="0.37083333333333335" />
<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_pay.xml" value="0.19739583333333333" />
<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/confirm.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" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.37083333333333335" />
</map>
</option>
</component>

44
app/build.gradle

@ -14,6 +14,27 @@ android {
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// Echo Socket
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)
// Bugfender
buildConfigField("String", "BUGFENDER_TOKEN", BUGFENDER_TOKEN)
// AWS
buildConfigField("String", "AWS_ACCESS_KEY", AWS_ACCESS_KEY)
buildConfigField("String", "AWS_SECRET_KEY", AWS_SECRET_KEY)
buildConfigField("String", "LOG_GROUP_NAME", LOG_GROUP_NAME)
}
buildTypes {
@ -22,6 +43,20 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "deployment"
productFlavors {
build {
dimension "deployment"
}
staging {
dimension "deployment"
}
live {
dimension "deployment"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@ -77,6 +112,15 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'me.grantland:autofittextview:0.2.+'
implementation 'com.jakewharton:process-phoenix:2.1.2'
// AWS
implementation "com.amazonaws:aws-android-sdk-logs:2.44.0"
// Bugfender
//noinspection GradleDynamicVersion
implementation 'com.bugfender.sdk:android:3.+'
debugImplementation 'com.github.amitshekhariitbhu.Android-Debug-Database:debug-db:v1.0.6'
}

2
app/src/androidTest/java/com/cst/im30/ExampleInstrumentedTest.java

@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.cst.udc_payment_terminal_im30", appContext.getPackageName());
assertEquals("com.cst.im30", appContext.getPackageName());
}
}

20
app/src/main/AndroidManifest.xml

@ -4,14 +4,17 @@
package="com.cst.im30">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_udc_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_udc_launcher_round"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
@ -21,10 +24,6 @@
android:name="com.cst.im30.activity.SettingActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name="com.cst.im30.activity.StatusActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name="com.cst.im30.activity.ICCActivity"
android:screenOrientation="portrait"
@ -33,12 +32,17 @@
<activity
android:name="com.cst.im30.activity.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="com.posapp.payactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
@ -48,11 +52,7 @@
android:launchMode="singleTask"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="com.posapp.payactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver

12
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,16 +7,10 @@ import net.mrbin99.laravelechoandroid.channel.SocketIOChannel;
public class EchoClient {
private final EchoOptions options;
private Echo echo;
private EchoOptions options;
private String host;
private MainActivity context;
public EchoClient(MainActivity context, String host) {
this.context = context;
this.host = host;
public EchoClient(String host) {
this.options = new EchoOptions();
this.options.host = host;

12
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,16 +7,10 @@ import net.mrbin99.laravelechoandroid.channel.SocketIOChannel;
public class EchoClientSetting {
private final EchoOptions options;
private Echo echo;
private EchoOptions options;
private String host;
private SettingActivity context;
public EchoClientSetting(SettingActivity context, String host) {
this.context = context;
this.host = host;
public EchoClientSetting(String host) {
this.options = new EchoOptions();
this.options.host = host;

12
app/src/main/java/com/cst/im30/ICEchoClient.java

@ -1,12 +0,0 @@
package com.cst.im30;
import com.cst.im30.activity.MainActivity;
public class ICEchoClient extends EchoClient {
public ICEchoClient(MainActivity context, String host) {
super(context, host);
}
}

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

@ -1,25 +1,185 @@
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.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.bugfender.sdk.Bugfender;
import com.cst.im30.activity.MainActivity;
import com.cst.im30.model.CancelRequest;
import com.cst.im30.model.CancelResponse;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.InquiryRequest;
import com.cst.im30.model.InquiryResponse;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.PreAuthResponse;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleCompletionResponse;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.model.SetDateTimeRequest;
import com.cst.im30.model.SetDateTimeResponse;
import com.cst.im30.model.SettlementRequest;
import com.cst.im30.model.SettlementResponse;
import com.cst.im30.model.VoidRequest;
import com.cst.im30.model.VoidResponse;
import com.cst.im30.utility.CloudWatchLogger;
import com.cst.im30.utility.Logger;
public class MainApplication extends Application {
public static final int MAX_RETRY = 10;
public static MainApplication instance;
public static AppCompatActivity currentActivity;
public static EchoClient paymentClient;
public static EchoClient icClient;
public static boolean paymentIsConnected = false;
public static boolean icIsConnected = false;
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 InquiryRequest currentInquiryRequest = null;
public static InquiryResponse currentInquiryResponse = 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 SettlementRequest currentSettlementRequest = null;
public static SettlementResponse currentSettlementResponse = null;
public static SetDateTimeRequest currentSetDateTimeRequest = null;
public static SetDateTimeResponse currentSetDateTimeResponse = null;
public static String code;
public static String status;
private CloudWatchLogger cloudWatchLogger;
public static MainApplication getInstance() {
return instance;
}
public static void reset() {
working = false;
incomingCode = null;
currentCode = null;
currentEventLogDetailed = null;
currentSaleRequest = null;
currentSaleResponse = null;
currentVoidRequest = null;
currentVoidResponse = null;
currentInquiryRequest = null;
currentInquiryResponse = null;
currentCancelRequest = null;
currentCancelResponse = null;
currentPreAuthRequest = null;
currentPreAuthResponse = null;
currentSaleCompletionRequest = null;
currentSaleCompletionResponse = null;
currentSettlementRequest = null;
currentSettlementResponse = null;
currentSetDateTimeRequest = null;
currentSetDateTimeResponse = null;
code = null;
status = null;
//Logger.logD("RESET");
}
@Override
public void onCreate() {
super.onCreate();
instance = this;
this.cloudWatchLogger = new CloudWatchLogger();
initializeBugfender();
initializeCrashHandler();
}
public void log(String logStreamName, String message) {
this.cloudWatchLogger.log(BuildConfig.LOG_GROUP_NAME, logStreamName, message);
}
public void logICScan(String message) {
this.cloudWatchLogger.log(BuildConfig.LOG_GROUP_NAME, "IcScanLog", message);
}
public void logPayment(String message) {
this.cloudWatchLogger.log(BuildConfig.LOG_GROUP_NAME, "Payment", message);
}
public void logError(String message) {
this.cloudWatchLogger.log(BuildConfig.LOG_GROUP_NAME, "Error", message);
}
@SuppressLint("MissingPermission")
private void initializeBugfender() {
Bugfender.init(this, BuildConfig.BUGFENDER_TOKEN, BuildConfig.DEBUG);
String serialNumber;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
serialNumber = android.os.Build.getSerial();
} else {
serialNumber = android.os.Build.SERIAL;
}
Bugfender.setDeviceString("Stage", BuildConfig.FLAVOR);
Bugfender.setDeviceString("S/N", serialNumber);
Bugfender.setDeviceString("Kiosk Code", BuildConfig.KIOSK_CODE);
Bugfender.setDeviceString("Echo Server", BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
Bugfender.enableCrashReporting();
//Bugfender.enableLogcatLogging();
}
private void initializeCrashHandler() {
Thread.setDefaultUncaughtExceptionHandler(this::handleUncaughtException);
//Logger.logV("Crash Handler Attached");
}
public void handleUncaughtException(Thread thread, Throwable e) {
if (e instanceof Exception) {
Log.e("CST-DBG", "Exception: " + Log.getStackTraceString(e));
System.out.println();
Log.e(Logger.TAG, "Exception: " + Log.getStackTraceString(e));
logError("Exception: " + Log.getStackTraceString(e));
Bugfender.sendIssue(e.getMessage(), 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);
}
}

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

@ -0,0 +1,522 @@
package com.cst.im30;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.cst.im30.common.Constants;
import com.cst.im30.model.CancelRequest;
import com.cst.im30.model.CancelResponse;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.InquiryRequest;
import com.cst.im30.model.InquiryResponse;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.PreAuthResponse;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleCompletionResponse;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.model.SetDateTimeRequest;
import com.cst.im30.model.SetDateTimeResponse;
import com.cst.im30.model.SettlementRequest;
import com.cst.im30.model.SettlementResponse;
import com.cst.im30.model.VoidRequest;
import com.cst.im30.model.VoidResponse;
import com.cst.im30.utility.Logger;
import com.cst.im30.utility.PaymentUtils;
public class PaymentHandler {
private final Context context;
public PaymentHandler(Context context) {
this.context = context;
}
public void handlePayFunctionSale(EventLogDetailed eventLogDetailed) {
SaleRequest request = PaymentUtils.createSaleRequest(eventLogDetailed);
if (PaymentUtils.validateSaleRequest(request)) {
MainApplication.getInstance().logPayment("[SALE]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initSalePayment(request);
} else {
Toast.makeText(context, "Invalid Sale Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Sale Request: " + request.toString());
}
}
public void handlePayFunctionVoid(EventLogDetailed eventLogDetailed) {
VoidRequest request = PaymentUtils.createVoidRequest(eventLogDetailed);
if (PaymentUtils.validateVoidRequest(request)) {
MainApplication.getInstance().logPayment("[VOID]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initVoid(request);
} else {
Toast.makeText(context, "Invalid Void Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Void Request: " + request.toString());
}
}
public void handlePayFunctionInquiry(EventLogDetailed eventLogDetailed) {
InquiryRequest request = PaymentUtils.createInquiryRequest(eventLogDetailed);
if (PaymentUtils.validateInquiryRequest(request)) {
MainApplication.getInstance().logPayment("[INQUIRY]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initInquiry(request);
} else {
Toast.makeText(context, "Invalid Inquiry Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Inquiry Request: " + request.toString());
}
}
public void handlePayFunctionCancel() {
CancelRequest request = new CancelRequest();
initCancel(request);
}
public void handlePayFunctionPreAuth(EventLogDetailed eventLogDetailed) {
PreAuthRequest request = PaymentUtils.createPreAuthRequest(eventLogDetailed);
if (PaymentUtils.validatePreAuthRequest(request)) {
MainApplication.getInstance().logPayment("[PRE-AUTH]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initPreAuth(request);
} else {
Toast.makeText(context, "Invalid Pre Auth Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Pre Auth Request: " + request.toString());
}
}
public void handlePayFunctionSaleCompletion(EventLogDetailed eventLogDetailed) {
SaleCompletionRequest request = PaymentUtils.createSaleCompletionRequest(eventLogDetailed);
if (PaymentUtils.validateSaleCompletionRequest(request)) {
MainApplication.getInstance().logPayment("[SALE_COMPLETION]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initSaleCompletion(request);
} else {
Toast.makeText(context, "Invalid Sale Completion Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Sale Completion Request: " + request.toString());
}
}
public void handlePayFunctionSettlement(EventLogDetailed eventLogDetailed) {
SettlementRequest request = PaymentUtils.createSettlementRequest(eventLogDetailed);
if (PaymentUtils.validateSettlementRequest(request)) {
MainApplication.getInstance().logPayment("[SETTLEMENT]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initSettlement(request);
} else {
Toast.makeText(context, "Invalid Settlement Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Settlement Request: " + request.toString());
}
}
public void handlePayFunctionSetDateTime(EventLogDetailed eventLogDetailed) {
SetDateTimeRequest request = PaymentUtils.createSetDateTimeRequest(eventLogDetailed);
if (PaymentUtils.validateSetDateTimeRequest(request)) {
MainApplication.getInstance().logPayment("[SET DATE TIME]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark());
initSetDateTime(request);
} else {
Toast.makeText(context, "Invalid Set Date Time Request", Toast.LENGTH_SHORT).show();
Logger.logW("Invalid Set Date Time Request: " + request.toString());
}
}
public void initSalePayment(SaleRequest request) {
Logger.logD("Direct Payment: " + request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_type", request.getPayType());
String payCameraMode = request.getPayCameraMode();
if (payCameraMode != null && !payCameraMode.isEmpty()) {
extra.putString("pay_camera_mode", payCameraMode);
}
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
MainApplication.currentSaleRequest = request;
app2app(extra);
}
public void initVoid(VoidRequest request) {
Logger.logD("Void Payment: " + request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
extra.putString("pay_trace_no", request.getPayTraceNo());
extra.putString("pay_invoice_no", request.getPayInvoiceNo());
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
MainApplication.currentVoidRequest = request;
app2app(extra);
}
public void initCancel(CancelRequest request) {
Logger.logD(request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
MainApplication.currentCancelRequest = request;
app2app(extra);
}
public void initInquiry(InquiryRequest request) {
Logger.logD(request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", request.getPayAmount());
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
extra.putString("pay_trace_no", request.getPayTraceNo());
extra.putString("pay_invoice_no", request.getPayInvoiceNo());
MainApplication.currentInquiryRequest = request;
app2app(extra);
}
public void initPreAuth(PreAuthRequest request) {
Logger.logD(request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_amount", String.valueOf(request.getPayAmount()));
String payPosTxnId = request.getPayPosTxnId();
if (payPosTxnId != null && !payPosTxnId.isEmpty()) {
extra.putString("pay_pos_txn_id", payPosTxnId);
}
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId());
MainApplication.currentPreAuthRequest = request;
app2app(extra);
}
public void initSaleCompletion(SaleCompletionRequest request) {
Logger.logD(request.toString());
MainApplication.getInstance().logPayment(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 initSettlement(SettlementRequest request) {
Logger.logD(request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
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.currentSettlementRequest = request;
app2app(extra);
}
private void initSetDateTime(SetDateTimeRequest request) {
Logger.logD(request.toString());
MainApplication.getInstance().logPayment(request.toString());
Bundle extra = new Bundle();
extra.putString("pay_function", request.getPayFunction());
extra.putString("pay_pos_txn_date", request.getPayPosTxnDate());
extra.putString("pay_pos_txn_time", request.getPayPosTxnTime());
MainApplication.currentSetDateTimeRequest = 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);
MainApplication.getInstance().logPayment("App2App Call to: " + Constants.APP_2_APP);
context.startActivity(intent);
}
public void handlePayFunctionSaleResponse(Bundle extra) {
SaleResponse response = new SaleResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayCameraMode(extra.getString("pay_camera_mode"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCardAid(extra.getString("pay_resp_card_aid"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespQrTxnId(extra.getString("pay_resp_qr_txn_id"));
response.setPayRespQrWalletId(extra.getString("pay_resp_qr_wallet_id"));
response.setPayRespCustomerId(extra.getString("pay_resp_customer_id"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
response.setPayRespHashPan(extra.getString("pay_resp_hash_pan"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.currentSaleResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
public void handlePayFunctionVoidResponse(Bundle extra) {
VoidResponse response = new VoidResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespQrTxnId(extra.getString("pay_resp_qr_txn_id"));
response.setPayRespQrWalletId(extra.getString("pay_resp_qr_wallet_id"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCustomerId(extra.getString("pay_resp_customer_id"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.currentVoidResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
public void handlePayFunctionInquiryResponse(Bundle extra) {
InquiryResponse response = new InquiryResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
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.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.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.currentInquiryResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
public void handlePayFunctionCancelResponse(Bundle extra) {
CancelResponse response = new CancelResponse();
response.setPayFunction(extra.getString("pay_function"));
response.setPayRespCode(extra.getString("pay_resp_code"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.currentCancelResponse = response;
}
public void handlePayFunctionPreAuthResponse(Bundle extra) {
PreAuthResponse response = new PreAuthResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCardAid(extra.getString("pay_resp_card_aid"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
response.setPayRespHashPan(extra.getString("pay_resp_hash_pan"));
response.setToken(extra.getString("token"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
MainApplication.currentPreAuthResponse = response;
}
public void handlePayFunctionSaleCompletionResponse(Bundle extra) {
SaleCompletionResponse response = new SaleCompletionResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCardAid(extra.getString("pay_resp_card_aid"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
response.setPayRespHashPan(extra.getString("pay_resp_hash_pan"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
MainApplication.currentSaleCompletionResponse = response;
}
public void handlePayFunctionSettlementResponse(Bundle extra) {
SettlementResponse response = new SettlementResponse();
response.setPayFunction(extra.getString("pay_function"));
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.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.currentSettlementResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
public void handlePayFunctionSetDateTimeResponse(Bundle extra) {
SetDateTimeResponse response = new SetDateTimeResponse();
response.setPayFunction(extra.getString("pay_function"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
Logger.logD(response.toString());
MainApplication.getInstance().logPayment(response.toString());
MainApplication.currentSetDateTimeResponse = response;
MainApplication.code = response.getPayRespCode();
MainApplication.status = response.getPayRespErrorDesc();
}
}

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

@ -13,14 +13,18 @@ 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;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.MainApplication;
import com.cst.im30.R;
import com.cst.im30.utility.IccTester;
import com.cst.im30.utility.Logger;
import com.cst.im30.utility.NRICApduUtils;
import java.io.BufferedWriter;
import java.io.File;
@ -44,8 +48,9 @@ public class ICCActivity extends AppCompatActivity {
private String name;
private String cardNo;
private AlertDialog alertDialogPromptCard;
@SuppressLint("HandlerLeak")
private Handler handler = new Handler() {
private final Handler handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0: //got card
@ -153,7 +158,7 @@ public class ICCActivity extends AppCompatActivity {
}
};
@SuppressLint("HandlerLeak")
private Handler handlerCard = new Handler() {
private final Handler handlerCard = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
@ -172,7 +177,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();
@ -185,7 +190,7 @@ public class ICCActivity extends AppCompatActivity {
}
};
@SuppressLint("HandlerLeak")
private Handler handlerInsertCard = new Handler() {
private final Handler handlerInsertCard = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0: //got card
@ -264,6 +269,9 @@ public class ICCActivity extends AppCompatActivity {
setContentView(R.layout.activity_icc);
setTitle("Read Card");
Button buttonCancel = findViewById(R.id.button_cancel);
buttonCancel.setOnClickListener(v -> cancel());
name = "";
cardNo = "";
@ -272,6 +280,11 @@ public class ICCActivity extends AppCompatActivity {
insertCard();
}
public void cancel() {
setResult(RESULT_CANCELED);
finish();
}
@Override
public void finish() {
stopChecking = true;
@ -316,23 +329,13 @@ public class ICCActivity extends AppCompatActivity {
}
private void appIsReady() {
if (iccDetectedThread == null) {
iccDetectedThread = new IccDetectedThread();
iccDetectedThread.start();
} else {
iccDetectedThread = new IccDetectedThread();
iccDetectedThread.start();
}
iccDetectedThread = new IccDetectedThread();
iccDetectedThread.start();
}
private void checkCard() {
if (cardDetectedThread == null) {
cardDetectedThread = new CardDetectedThread();
cardDetectedThread.start();
} else {
cardDetectedThread = new CardDetectedThread();
cardDetectedThread.start();
}
cardDetectedThread = new CardDetectedThread();
cardDetectedThread.start();
}
private void insertCard() {
@ -348,6 +351,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() {
@ -375,52 +385,29 @@ public class ICCActivity extends AppCompatActivity {
IccTester.getInstance(getApplicationContext()).autoResp((byte) 0, true);// 设置iccIsoCommand函数是否自动发送GET RESPONSE指令。
byte[] selectJpn = new byte[]{(byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x0A, (byte) 0xA0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x74, (byte) 0x4A, (byte) 0x50, (byte) 0x4E, (byte) 0x00, (byte) 0x10};
byte[] readIc = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x0D, (byte) 0x00};
byte[] readIc1 = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x11, (byte) 0x01, (byte) 0x0D, (byte) 0x00};
byte[] readIc2 = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x0D};
byte[] readName = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x28, (byte) 0x00};
byte[] readName1 = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xE9, (byte) 0x00, (byte) 0x28, (byte) 0x00};
byte[] readName2 = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x28};
byte[] readCard = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00};
byte[] readCard1 = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x8F, (byte) 0x01, (byte) 0x01, (byte) 0x00};
byte[] readCard2 = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x01};
byte[] isoRes = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, selectJpn);
byte[] isoRes = NRICApduUtils.selectAppJPN(getApplicationContext());
if (isoRes != null) {
String isoStr = null;
try {
byte[] isoResx = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readIc);
byte[] isoRes1 = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readIc1);
Log.d("ZZZ1", getHexValue(isoRes1));
byte[] isoRes2 = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readIc2);
Log.d("ZZZ2", getHexValue(isoRes2));
nric = NRICApduUtils.getIDNum(getApplicationContext());
byte[] icBytes = Arrays.copyOfRange(isoRes2, 0, isoRes2.length - 3);
Log.d("ZZZ3", new String(icBytes));
String orgName = NRICApduUtils.getOriginalName(getApplicationContext());
String gmpcName = NRICApduUtils.getGMPCName(getApplicationContext());
String kptName = NRICApduUtils.getKPTName(getApplicationContext());
nric = new String(icBytes);
byte[] isoResN = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readName);
Log.d("ZZZ4", getHexValue(isoResN));
byte[] isoResN1 = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readName1);
Log.d("ZZZ5", getHexValue(isoResN1));
byte[] isoResN2 = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readName2);
Log.d("ZZZ6", getHexValue(isoResN2));
byte[] nameBytes = Arrays.copyOfRange(isoResN2, 0, isoResN2.length - 2);
Log.d("ZZZ7", new String(nameBytes));
name = new String(nameBytes);
String selectedName = orgName;
if (selectedName.length() < gmpcName.length()) {
selectedName = gmpcName;
}
if (selectedName.length() < kptName.length()) {
selectedName = kptName;
}
name = selectedName;
byte[] isoResC = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readCard);
Log.d("ZZZ8", getHexValue(isoResC));
@ -438,7 +425,6 @@ public class ICCActivity extends AppCompatActivity {
cardVer = new String(cardBytes);
nric += getHexValue(cardBytes);
//readData();
} catch (Exception e) {
ICCActivity.appendLog(e);
@ -463,8 +449,6 @@ public class ICCActivity extends AppCompatActivity {
handler.sendMessage(message);
}
SystemClock.sleep(500);
break;
} else {
//resString = getResources().getString(R.string.icc_detect_nocard);
Message message = Message.obtain();
@ -472,9 +456,9 @@ public class ICCActivity extends AppCompatActivity {
message.obj = "No card.";
handler.sendMessage(message);
SystemClock.sleep(500);
break;
}
SystemClock.sleep(500);
break;
}
IccTester.getInstance(ICCActivity.this).light(false);
}
@ -490,23 +474,19 @@ public class ICCActivity extends AppCompatActivity {
while (!Thread.interrupted()) {
boolean detect = IccTester.getInstance(ICCActivity.this).detect((byte) 0);
Message message = Message.obtain();
if (detect) {
Message message = Message.obtain();
message.what = 0;
message.obj = "Remove card";
handlerCard.sendMessage(message);
SystemClock.sleep(500);
break;
} else {
Message message = Message.obtain();
message.what = 1;
message.obj = "No card";
handlerCard.sendMessage(message);
SystemClock.sleep(500);
break;
}
handlerCard.sendMessage(message);
SystemClock.sleep(500);
break;
}
IccTester.getInstance(ICCActivity.this).light(false);
@ -523,27 +503,22 @@ public class ICCActivity extends AppCompatActivity {
while (!Thread.interrupted()) {
boolean detect = IccTester.getInstance(ICCActivity.this).detect((byte) 0);
Message message = Message.obtain();
if (detect) {
Message message = Message.obtain();
message.what = 0;
message.obj = "Detect card";
handlerInsertCard.sendMessage(message);
SystemClock.sleep(500);
break;
} else {
Message message = Message.obtain();
message.what = 1;
message.obj = "No card";
handlerInsertCard.sendMessage(message);
SystemClock.sleep(500);
break;
}
handlerInsertCard.sendMessage(message);
SystemClock.sleep(500);
break;
}
IccTester.getInstance(ICCActivity.this).light(false);
}
}
}

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

File diff suppressed because it is too large Load Diff

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

@ -2,268 +2,324 @@ 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;
import com.cst.im30.MainApplication;
import com.cst.im30.R;
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.common.CallableInterface;
import com.cst.im30.common.Constants;
import com.cst.im30.model.CancelResponse;
import com.cst.im30.model.PreAuthResponse;
import com.cst.im30.model.SaleCompletionResponse;
import com.cst.im30.model.SaleResponse;
import com.cst.im30.model.VoidResponse;
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.logW("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";
Logger.logV("Pay Function: " + payFunction);
if (Constants.PAY_FUNCTION_SALE.equalsIgnoreCase(payFunction)) {
handlePayFunctionSale(extra);
} else if (Constants.PAY_FUNCTION_VOID.equalsIgnoreCase(payFunction)) {
handlePayFunctionVoid(extra);
} else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) {
handlePayFunctionCancel(extra);
} else if (Constants.PAY_FUNCTION_PRE_AUTH.equalsIgnoreCase(payFunction)) {
handlePayFunctionPreAuth(extra);
} else if (Constants.PAY_FUNCTION_SALE_COMPLETION.equalsIgnoreCase(payFunction)) {
handlePayFunctionSaleCompletion(extra);
} else if (payFunction == null || payFunction.isEmpty()) {
finishActivity(false);
} else {
resultPayRespCode = "Transaction Decline";
resultPayRespCodeStatus = "fail";
Logger.logW("Unsupported Pay Function: " + payFunction);
}
}
txtStatus.setText(resultPayRespCode);
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);
}
String finalResultPayRespCode = resultPayRespCode;
String finalResultPayRespCodeStatus = resultPayRespCodeStatus;
vStatus = finalResultPayRespCodeStatus;
private void handlePayFunctionVoid(Bundle extra) {
VoidResponse response = new VoidResponse();
response.setPayAmount(extra.getString("pay_amount"));
response.setPayFunction(extra.getString("pay_function"));
response.setPayType(extra.getString("pay_type"));
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id"));
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date"));
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time"));
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no"));
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no"));
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no"));
response.setPayRespScheme(extra.getString("pay_resp_scheme"));
response.setPayRespTid(extra.getString("pay_resp_tid"));
response.setPayRespMid(extra.getString("pay_resp_mid"));
response.setPayRespCardAuthCode(extra.getString("pay_resp_card_auth_code"));
response.setPayRespCardRefNum(extra.getString("pay_resp_card_ref_num"));
response.setPayRespQrTxnId(extra.getString("pay_resp_qr_txn_id"));
response.setPayRespQrWalletId(extra.getString("pay_resp_qr_wallet_id"));
response.setPayRespCardNo(extra.getString("pay_resp_card_no"));
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id"));
response.setPayRespCustomerId(extra.getString("pay_resp_customer_id"));
response.setPayRespCardAppCryptogram(extra.getString("pay_resp_card_app_cryptogram"));
response.setPayRespCode(extra.getString("pay_resp_code"));
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc"));
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info"));
response.setPayRespTvr(extra.getString("pay_resp_tvr"));
response.setPayRespCvmDesc(extra.getString("pay_resp_cvm_desc"));
response.setPayRespAppLabel(extra.getString("pay_resp_app_label"));
Logger.logD(response.toString());
MainApplication.currentVoidResponse = response;
code = resolveCode(response.getPayRespCode());
status = resolveStatus(response.getPayRespErrorDesc());
//todo upload void payment?
/*UploadTransactionSalePaymentService service = new UploadTransactionSalePaymentService(ResponseActivity.this);
service.call(MainApplication.currentEventLogDetailed, MainApplication.currentVoidRequest, MainApplication.currentSaleResponse);*/
}
//TODO: Send all response to Status Activity, then update/send all the info to API to be inserted in UDC KIOSK
private void handlePayFunctionCancel(Bundle extra) {
CancelResponse response = new CancelResponse();
response.setPayFunction(extra.getString("pay_function"));
response.setPayRespCode(extra.getString("pay_resp_code"));
String refNum = referenceNumber;
String finalAmount = amount;
Logger.logD(response.toString());
//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);
MainApplication.currentCancelResponse = response;
finishActivity(false);
}
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);
}
//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);*/
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);
}
@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);
}
} 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(true);
} else if (PaymentService.FAIL_UPDATE_EVENT_LOG.equalsIgnoreCase(source)) {
finishActivity(true);
}
}
private void finishActivity(boolean showResult) {
MainApplication.reset();
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);
Intent intent = new Intent(ResponseActivity.this, MainActivity.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
if (showResult) {
intent.setAction(Constants.INTENT_REFRESH);
intent.putExtra("code", code);
intent.putExtra("status", status);
} else {
intent.setAction(Constants.INTENT_RESET);
}
startActivity(intent);
setResult(RESULT_OK);
finish();
Logger.logV("Going back to MainActivity");
finishAffinity();
}
private String resolveStatus(String payRespErrorDesc) {
return payRespErrorDesc;
}
private String resolveCode(String payRespCode) {
return payRespCode;
}
}

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

@ -14,15 +14,14 @@ 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;
import org.json.JSONException;
import org.json.JSONObject;
public class SettingActivity extends AppCompatActivity {
public static final String TAG = "SettingActivity";
private EchoClientSetting echoClient;
@ -30,20 +29,17 @@ public class SettingActivity extends AppCompatActivity {
private TextView textViewResponse,
textViewConnectionStatus;
private Button buttonConnect,
buttonCheckConnectionStatus;
private Button buttonConnect;
private boolean isConnected;
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TextView titleMain = findViewById(R.id.title_main_st);
@ -73,7 +69,7 @@ public class SettingActivity extends AppCompatActivity {
buttonConnect = findViewById(R.id.button_connect_st);
buttonCheckConnectionStatus = findViewById(R.id.button_check_connection_status_st);
Button buttonCheckConnectionStatus = findViewById(R.id.button_check_connection_status_st);
buttonCheckConnectionStatus.setOnClickListener(v -> buttonCheckConnectionStatusClicked());
//buttonTriggerCheckPreviousPayment = findViewById(R.id.button_previous_payment);
@ -87,8 +83,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 +167,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);
}
@ -203,12 +198,9 @@ public class SettingActivity extends AppCompatActivity {
runOnUiThread(() -> textViewResponse.setText(finalData));
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 5000ms = 5 seconds
//clearInfo();
}
handler.postDelayed(() -> {
//Do something after 5000ms = 5 seconds
//clearInfo();
}, 5000);
//buttonTriggerPayment(finalData);

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

@ -1,624 +0,0 @@
package com.cst.im30.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
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 org.json.JSONException;
import org.json.JSONObject;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class StatusActivity 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 Transaction transaction;
private Button buttonDonationSuccess, buttonRetry, buttonNoRetry;
//private Transaction transaction;
private TextView textStatus, textInfo, textAmount;
private ImageView imageStatus;
private String status, responseCode, responseDesc, referenceNum, amountTransaction;
public static String getRefNum() {
return vRefNum;
}
public static String getStatus() {
return vStatus;
}
public static String getAmount() {
return vAmount;
}
public static void showFinishMessage(final Context context, String title, String message) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.pop_up_message_no_option, null);
TextView textTitle = dialogView.findViewById(R.id.text_title_pop_up_message_no_option);
TextView textMessage = dialogView.findViewById(R.id.text_message_pop_up_message_no_option);
Button buttonOk = dialogView.findViewById(R.id.button_ok_pop_up_message_no_option);
textTitle.setText(title);
textMessage.setText(message);
dialogBuilder.setCancelable(false);
dialogBuilder.setView(dialogView);
final AlertDialog alertDialogFinishMessage = dialogBuilder.create();
alertDialogFinishMessage.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alertDialogFinishMessage.show();
buttonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialogFinishMessage.dismiss();
((Activity) context).finish();
}
});
}
private static String encrytThisString(String input) {
try {
// getInstance() method is called with algorithm SHA-512
MessageDigest md = MessageDigest.getInstance("SHA-512");
// digest() method is called
// to calculate message digest of the input string
// returned as array of byte
byte[] messageDigest = md.digest(input.getBytes());
// Convert byte array into signum representation
BigInteger no = new BigInteger(1, messageDigest);
// Convert message digest into hex value
String hashtext = no.toString(16);
// Add preceding 0s to make it 32 bit
while (hashtext.length() < 32) {
hashtext = "0" + hashtext;
}
// return the HashText
return hashtext;
} // For specifying wrong message digest algorithms
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_status);
/*try {
transaction = (Transaction) getIntent().getSerializableExtra("transaction");
} catch (Exception e) {
//Bugsnag.notify(e);
}*/
buttonDonationSuccess = findViewById(R.id.button_ok_donation_sta);
buttonRetry = findViewById(R.id.button_pay_again_sta);
buttonNoRetry = findViewById(R.id.button_no_pay_again_sta);
textStatus = findViewById(R.id.text_status_sta);
textInfo = findViewById(R.id.text_info_sta);
textAmount = findViewById(R.id.text_info_amount_sta);
imageStatus = findViewById(R.id.image_status_sta);
//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;
//Get status from Response Screen
Intent intentRefNum = getIntent();
Bundle refNumGet = intentRefNum.getExtras();
if (refNumGet != null) {
String refNumSet = (String) refNumGet.get("referenceNumTransaction");
referenceNum = refNumSet;
}
/*Intent intentSign = getIntent();
Bundle signGet = intentSign.getExtras();
String */
Intent intentStatus = getIntent();
Bundle statusGet = intentStatus.getExtras();
if (statusGet != null) {
String statusSet = (String) statusGet.get("statusTransaction");
status = statusSet;
}
Intent intentAmount = getIntent();
Bundle amountGet = intentAmount.getExtras();
if (amountGet != null) {
String amountSet = (String) amountGet.get("amountTransaction");
amountTransaction = amountSet;
}
//Get HLB response from Response Activity
Intent intentResponse = getIntent();
Bundle extra = intentResponse.getExtras();
String payRespCodeTransaction = extra.getString("payRespCodeTransaction");
//transaction.setResponseCode(payRespCodeTransaction);
//all HLB response
String getAllHLBresponse = extra.getString("hlbResponse");
//String payResponseCode = transaction.getResponseCode();
String payRespErrorDescTransaction = extra.getString("payRespErrorDescTransaction");
String payRespIssuerIdTransaction = extra.getString("payRespIssuerIdTransaction");
String payFunctionTransaction = extra.getString("payFunctionTransaction");
//String payFunction = transaction.setFunction(payFunctionTransaction);
String payRespQrTxnIdTransaction = extra.getString("payRespQrTxnIdTransaction");
String payRespInvoiceNoTransaction = extra.getString("payRespInvoiceNoTransaction");
String payRespSchemeTransaction = extra.getString("payRespSchemeTransaction");
String payRespBatchNoTransaction = extra.getString("payRespBatchNoTransaction");
String payRespTxnDateTransaction = extra.getString("payRespTxnDateTransaction");
String payRespTxnTimeTransaction = extra.getString("payRespTxnTimeTransaction");
String payPrintReceiptIdTransaction = extra.getString("payPrintReceiptIdTransaction");
String payRespQrWalletIdTransaction = extra.getString("payRespQrWalletIdTransaction");
String payRespCardAppCryptogramTransaction = extra.getString("payRespCardAppCryptogramTransaction");
String payRespAppLabelTransaction = extra.getString("payRespAppLabelTransaction");
String payRespCardRefNumTransaction = extra.getString("payRespCardRefNumTransaction");
String payCameraModeTransaction = extra.getString("payCameraModeTransaction");
//String payCameraMode = transaction.setCameraMode(payCameraModeTransaction);
String payRespCardAuthCodeTransaction = extra.getString("payRespCardAuthCodeTransaction");
String payRespCardAidTransaction = extra.getString("payRespCardAidTransaction");
String payRespHashPanTransaction = extra.getString("payRespHashPanTransaction");
String payRespMerchInfoTransaction = extra.getString("payRespMerchInfoTransaction");
String payRespMidTransaction = extra.getString("payRespMidTransaction");
String payRespTidTransaction = extra.getString("payRespTidTransaction");
String payRespTvrTransaction = extra.getString("payRespTvrTransaction");
String payRespCustomerIdTransaction = extra.getString("payRespCustomerIdTransaction");
String payTypeTransaction = extra.getString("payTypeTransaction");
//String payType = transaction.setType(payTypeTransaction);
String payRespTraceNoTransaction = extra.getString("payRespTraceNoTransaction");
String payRespCvmDescTransaction = extra.getString("payRespCvmDescTransaction");
String payAddAmountTransaction = extra.getString("payAddAmountTransaction");
String payRespCardNoTransaction = extra.getString("payRespCardNoTransaction");
String payAmountTransaction = extra.getString("payAmountTransaction");
String merchanCode = "MER0001";
//String terminalCode = transaction.getTid();
String secretKey = "Uthos^eY5pfO";
//Signature=merchant_code+secret_key_reference_number+amount+payment_type ->23/08/2021-requery
//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 encryptedSignValueUpdate = encrytThisString(encryptedSigns);
//String paramsResponse = "{\"id\":13,\"merchant_code\":\"MER0001\"}";
//String paramsResponse = {"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 paramsResponse = getAllHLBresponse;
//if (status.toLowerCase().trim().equals("success") && transaction.getType().toLowerCase().contains("sale")) {
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);
Glide.with(StatusActivity.this).asBitmap().load(R.drawable.ic_status_success_fancy).into(imageStatus);
/*//direct update the status to server
String refNum = referenceNum;
String finalResultPayRespCodeStatus = status;
String finalAmount = amountTransaction;
//String paymentTypeTransaction = payTypeTransaction;
//String paymentFunctionTransaction = payFunctionTransaction;
//String paymentCameraMode = payCameraModeTransaction;
//TODO: change this hardcoded value later
//String signValue = "testSignature";
//String paramResponse = "HLB params here..";
//JSONObject obj = ((Parcel) ((Bundle) getArguments()).getSerializable("events")).getObj();
//String paramResponse = obj.toString();
String merchanCode = "MER0001";
//String terminalCode = transaction.getTid();
String secretKey = "Uthos^eY5pfO";
//String finalStatus = "fail";
//String amount = realAmount;
//String responseCode = transaction.getResponseCode();
//Signature = merchant_code+secret_key+reference_number+amount+response_code ->23/08/2021-update
String encryptedSign = merchanCode + secretKey + refNum + amount + payRespCodeTransaction;
String encryptedSignValueUpdate = encrytThisString(encryptedSign);
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);
//hide button so user won't need to interact with it
//buttonDonationSuccess.setVisibility(View.VISIBLE);
buttonDonationSuccess.setVisibility(View.GONE);
buttonRetry.setVisibility(View.GONE);
buttonNoRetry.setVisibility(View.GONE);
//hold the info from UDC kiosk donation received for 5 second then proceed to HLB app
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 5000ms = 5 seconds
//update Status success to server
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
updateResponseFromhlb(referenceNum, status, merchanCode, amountTransaction, payRespCodeTransaction,
encryptedSignValueUpdate, paramsResponse);
//updateResponseFromhlb(payment);
/*{ //current jSON at API side -UPDATE
"id": 11,
"reference_number": "PAY001",
"payment_type": null,
"payment_function": null,
"payment_camera_mode": null,
"signature": null,
"amount": "1.00",
"status": "success",
"params_response": null,
"created_at": "2021-06-20T13:32:40.000000Z",
"updated_at": "2021-08-19T00:32:17.000000Z"
}*/
Intent i = new Intent(StatusActivity.this, MainActivity.class);
i.putExtra("statusCurrent", status);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
}, 5000);
} 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);
Glide.with(StatusActivity.this).asBitmap().load(R.drawable.ic_status_fail_fancy).into(imageStatus);
buttonDonationSuccess.setVisibility(View.GONE);
buttonRetry.setVisibility(View.VISIBLE);
buttonNoRetry.setVisibility(View.VISIBLE);
}
//button ok ->hide because useless/ no need user to press
/*buttonDonationSuccess.setOnClickListener(view -> {
String refNum = referenceNum;
String finalResultPayRespCodeStatus = status;
String finalAmount = amountTransaction;
//update Status to server
updateResponseFromhlb(refNum, finalResultPayRespCodeStatus, finalAmount);
Intent i = new Intent(StatusActivity.this, MainActivity.class);
i.putExtra("statusCurrent", finalResultPayRespCodeStatus);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
});*/
//button no retry pay again
buttonNoRetry.setOnClickListener(view -> {
String refNum = referenceNum;
String finalResultPayRespCodeStatus = status;
String finalAmount = amountTransaction;
String paymentTypeTransaction = payTypeTransaction;
String paymentFunctionTransaction = payFunctionTransaction;
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);
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
//update Status = FAIL to server
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
updateResponseFromhlb(referenceNum, finalResultPayRespCodeStatus, merchanCode, finalAmount, payRespCodeTransaction,
encryptedSignValueUpdate, paramsResponse);
/*updateResponseFromhlb(refNum, paymentTypeTransaction, paymentFunctionTransaction,
paymentCameraMode, signValue, finalAmount, finalResultPayRespCodeStatus, paramResponse);*/
Intent intent = new Intent(StatusActivity.this, MainActivity.class);
intent.putExtra("statusCurrent", finalResultPayRespCodeStatus);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
//button retry
//buttonRetry.setOnClickListener(view -> buttonRetryPayment(status));
buttonRetry.setOnClickListener(view -> {
String refNum = referenceNum;
String finalResultPayRespCodeStatus = "pending";
vStatus = finalResultPayRespCodeStatus;
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 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 encryptedSignValueUpdate = encrytThisString(encryptedSigns);
//update Status to server ->no need to update 1st, just retry the payment
//updateResponseFromhlb(refNum, finalResultPayRespCodeStatus, finalAmount);
//check the status from server 1st, if pending proceed, if fail sho success show something
//requery + update API
checkStatusPayment(refNum, merchanCode, payTypeTransaction, finalAmount, encryptedSignValueRequery,
paramsResponse, payRespCodeTransaction, encryptedSignValueUpdate);
/*//String transactionStatus = status; ->pending
String transactionReference = refNum;
String transactionStatus = finalResultPayRespCodeStatus;
String transactionAmount = finalAmount;
retryPayment(finalAmount);*/
/*Intent intents = new Intent(StatusActivity.this, MainActivity.class);
intents.putExtra("referenceCurrent", transactionReference);
intents.putExtra("statusCurrent", transactionStatus);
intents.putExtra("amountCurrent", transactionAmount);
intents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intents);*/
});
}
//refNum, merchanCode, payTypeTransaction, finalAmount, encryptedSignValueRequery
private void checkStatusPayment(String referenceNumber, String merchanCode, String payType, String amount, String encryptedSignValueRequery,
String paramResponse, String payRespCode, String encryptedSignValueUpdate) {
//TODO: Please cleanup and fix afterwards
String tempHostUrl = "http://udcsys-api-build.testpigeon.net";
String buildToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiOTA2ZTNkN2VmNmZkNmNhZjVjYTVkNWEzYjI5ZDRiMWYxZjlmYTc4ZDcxYzYyNGE0N2FmMTYwMGQzZWY3ZGU5OGE5MGY2NzJlNzE4NmVmZGIiLCJpYXQiOjE2MDg1MzYyMTMsIm5iZiI6MTYwODUzNjIxMywiZXhwIjoxNjQwMDcyMjEzLCJzdWIiOiIxMSIsInNjb3BlcyI6W119.i2jDd1Zux2UkoLhzif762ghsJFhQ32Gk6g0Z2pXDRHKWVoK4kHv__Fnxb4XhdJncfzSmMibZGguOEVPNuRotMjhC7a-lgHKItqeamOSxQNONuhea601R3k8QVDA92mnRKBsDiQw6-mcCw-K5t49I1TkkwauQ1EYQU5GI4vttxbdO_irZfQgINfyCmAkqo_IWgc8498pCuI5lMA2vI9X3BETtNt8WS451hU59fy7K_sjiojFG6mvwu7C-z0ZPcqKQ8F7c2JfZq0qphslMrqj0nZh0skGf0Qf6ZmRrftkNONcO9j9jh5eJfEHIEmGqNhDeO9ftQq5BuWfm6FhYVIW1YnBKrNk6lLkk38fuKjk8FevNwH6knVZjb3Q27Kr7K2cbbvlPEp846VrJrwIdJjfpDuAoorjMQAw-yVJQYOrb_v8F1jhnoMC_Qdu5Qc1AjbDrHggrZtkG9f7pw60reoNk01OCVsOD5ecldm05PfJ2NqhdZn1oXXxFOXc8lcBWpYkfhrOzw0fpxH4hFk4j8HSvy4n0EkB5ZfctDYx6JxXfoCsW7zYgm52ZCZISV5Kchkhlk6W2C1pUs8YjtxAU2I8A6wVbJwGVbwsDudgPXMuNH_PVk3YkljWU-zkPbMLWMOc-DNyioE-dAoq1VWPXoNuhaOqMDR4RCiZPhvJg0yxfA68";
//String paymentType = "01"; //01=Card Payment
//Get REQUERY Payment from UDC Laravel Echo Listener Server
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(tempHostUrl).create(RetrofitAPICollection.class);
/*Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://udcsys-api-build.testpigeon.net")
.addConverterFactory(GsonConverterFactory.create())
.build();*/
Call<String> callCardPayStatus = service.requeryCardPayment("Bearer " + buildToken,
referenceNumber,
merchanCode,
payType,
amount,
encryptedSignValueRequery);
callCardPayStatus.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
/*Toast.makeText(StatusActivity.this,"\n" +
"Update data process completed!",Toast.LENGTH_SHORT).show();*/
if (response.isSuccessful()) {
try {
JSONObject responseJSON = new JSONObject(response.body());
String responseStatus = responseJSON.getString("status");
if (responseStatus.toLowerCase().trim().equals("fail")) {
//set the fail info
String refNum = referenceNum;
String finalResultPayRespCodeStatus = status;
String finalAmount = amountTransaction;
String payRespCodeTransaction = payRespCode;
String encryptedSignUpdate = encryptedSignValueUpdate;
//String paymentTypeTransaction = transaction.getType();
//String paymentFunctionTransaction = transaction.getFunction();
//String paymentCameraMode = transaction.getCameraMode();
//TODO: change this hardcoded value later
//String signValue = "testSignature";
//String paramResponse = "HLB params here..";
/*updateResponseFromhlb(refNum, payTypeTransaction, payFunctionTransaction,
payCameraModeTransaction, signValue, finalAmount, finalResultPayRespCodeStatus, paramResponse);*/
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
//update Status = FAIL to server
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
updateResponseFromhlb(referenceNum, finalResultPayRespCodeStatus, merchanCode, finalAmount, payRespCodeTransaction,
encryptedSignUpdate, paramResponse);
/*updateResponseFromhlb(refNum, paymentTypeTransaction, paymentFunctionTransaction, paymentCameraMode,
signValue, finalAmount, finalResultPayRespCodeStatus, paramResponse);*/
//show screen/info about cannot retry
setResult(RESULT_OK);
StatusActivity.showFinishMessage(StatusActivity.this, "Payment Fail!", "Payment status : " + responseStatus);
//hold the info from UDC kiosk donation received for 5 second then proceed to HLB app
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 5000ms = 5 seconds
//direct user to main screen
Intent intent = new Intent(StatusActivity.this, MainActivity.class);
intent.putExtra("statusCurrent", finalResultPayRespCodeStatus);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}, 5000);
} else if (responseStatus.toLowerCase().trim().equals("pending")) {
//if status not fail, proceed the retry payment process
String refNum = referenceNum;
String finalResultPayRespCodeStatus = "pending";
vStatus = finalResultPayRespCodeStatus;
String finalAmount = amountTransaction;
//String transactionStatus = status; ->pending
String transactionReference = refNum;
String transactionStatus = finalResultPayRespCodeStatus;
String transactionAmount = finalAmount;
retryPayment(transactionAmount);
}
} catch (JSONException e) {
e.printStackTrace();
}
} //if response is NoSuccessful
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Toast.makeText(StatusActivity.this, "Unsuccessfully update data!\n", Toast.LENGTH_SHORT).show();
}
});
}
private void retryPayment(String finalAmount) {
String amount = finalAmount;
//Get the amount from current screen
String payAmount = amount;
//Convert double value of amount from UDC kiosk app to integer 1st
double doubleValue = Double.parseDouble(payAmount);
//Convert amount to time 100 for HLB to process
int correctAmount = (int) Math.round(doubleValue * 100);
String pay_amount = "";
Bundle extra = new Bundle();
String pay_function = "01"; //Sale Payment Function
pay_amount = pay_amount.valueOf(correctAmount);
String pay_type = "01"; //Card Payment
String pay_camera_mode = "01"; //Internal Device Back 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);
startActivity(intent);
}
//updateResponseToApi(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
// String encryptedSignValueUpdate, String paramsResponse)
//Signature = merchant_code+secret_key+reference_number+amount+response_code ->23/08/2021-update
private void updateResponseFromhlb(String referenceNumber, String status, String merchantCode, String amount, String responseCode,
String encryptedSignValueUpdate, String paramsResponse) {
String buildToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiOTA2ZTNkN2VmNmZkNmNhZjVjYTVkNWEzYjI5ZDRiMWYxZjlmYTc4ZDcxYzYyNGE0N2FmMTYwMGQzZWY3ZGU5OGE5MGY2NzJlNzE4NmVmZGIiLCJpYXQiOjE2MDg1MzYyMTMsIm5iZiI6MTYwODUzNjIxMywiZXhwIjoxNjQwMDcyMjEzLCJzdWIiOiIxMSIsInNjb3BlcyI6W119.i2jDd1Zux2UkoLhzif762ghsJFhQ32Gk6g0Z2pXDRHKWVoK4kHv__Fnxb4XhdJncfzSmMibZGguOEVPNuRotMjhC7a-lgHKItqeamOSxQNONuhea601R3k8QVDA92mnRKBsDiQw6-mcCw-K5t49I1TkkwauQ1EYQU5GI4vttxbdO_irZfQgINfyCmAkqo_IWgc8498pCuI5lMA2vI9X3BETtNt8WS451hU59fy7K_sjiojFG6mvwu7C-z0ZPcqKQ8F7c2JfZq0qphslMrqj0nZh0skGf0Qf6ZmRrftkNONcO9j9jh5eJfEHIEmGqNhDeO9ftQq5BuWfm6FhYVIW1YnBKrNk6lLkk38fuKjk8FevNwH6knVZjb3Q27Kr7K2cbbvlPEp846VrJrwIdJjfpDuAoorjMQAw-yVJQYOrb_v8F1jhnoMC_Qdu5Qc1AjbDrHggrZtkG9f7pw60reoNk01OCVsOD5ecldm05PfJ2NqhdZn1oXXxFOXc8lcBWpYkfhrOzw0fpxH4hFk4j8HSvy4n0EkB5ZfctDYx6JxXfoCsW7zYgm52ZCZISV5Kchkhlk6W2C1pUs8YjtxAU2I8A6wVbJwGVbwsDudgPXMuNH_PVk3YkljWU-zkPbMLWMOc-DNyioE-dAoq1VWPXoNuhaOqMDR4RCiZPhvJg0yxfA68";
//Get REQUERY Payment from UDC Laravel Echo Listener Server
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://udcsys-api-build.testpigeon.net")
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitAPICollection retrofitAPICollection = retrofit.create(RetrofitAPICollection.class);
Call<String> call = retrofitAPICollection.updateStatusCardPayment("Bearer " + buildToken,
referenceNumber,
status,
merchantCode,
amount,
responseCode,
encryptedSignValueUpdate,
paramsResponse);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
//txtStatus.setText(response.body().getReferenceNumber()+ " ".concat(response.body().getStatus()+ " "));
Toast.makeText(StatusActivity.this, "\n" +
"Update data process completed!", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Toast.makeText(StatusActivity.this, "Unsuccessfully update data!\n", Toast.LENGTH_SHORT).show();
}
});
}
private void buttonRetryPayment(String transactionStatus) {
//Get status from Response Screen , send to MainActivity for retry process
Intent intent = new Intent(StatusActivity.this, MainActivity.class);
//intent.putExtra("transaction", transaction);
intent.putExtra("status", transactionStatus);
startActivity(intent);
//setResult(RESULT_OK);
//finish();
}
}

49
app/src/main/java/com/cst/im30/api/RetrofitAPICollection.java

@ -0,0 +1,49 @@
package com.cst.im30.api;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
@SuppressWarnings({"unused"})
public interface RetrofitAPICollection {
@Headers({
"Accept: application/json",
"Content-Type: application/json"
})
@GET("api/v1/kiosk/broadcast-event-log/{eventCode}")
Call<String> getBroadcastEventLogDetails(
@Header("Client-Id") String clientId,
@Header("Client-Secret") String clientSecret,
@Path("eventCode") String referenceNumber
);
@Headers({
"Accept: application/json",
"Content-Type: application/json"
})
@PUT("api/v1/kiosk/broadcast-event-log/{eventCode}")
Call<String> updateBroadcastEventLogDetails(
@Header("Client-Id") String clientId,
@Header("Client-Secret") String clientSecret,
@Body String body,
@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
);
}

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);
}

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

@ -1,28 +1,34 @@
package com.cst.im30.common;
@SuppressWarnings({"unused"})
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 INTENT_RESET = "reset";
public static final String IC_FUNCTION_VERIFY = "verify";
public static final String IC_FUNCTION_CANCEL = "cancel";
public static final String PAY_FUNCTION_SALE = "01";
public static final String PAY_FUNCTION_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";
public static final String STATUS_SUCCESS = "success";
public static final String STATUS_FAIL = "fail";
public static final String STATUS_CANCELLED = "cancelled";
public static final String STATUS_REJECT = "reject";
}

21
app/src/main/java/com/cst/im30/common/Parcel.java

@ -1,21 +0,0 @@
package com.cst.im30.common;
import org.json.JSONObject;
import java.io.Serializable;
public class Parcel implements Serializable {
private JSONObject obj;
public Parcel(JSONObject obj) {
this.obj = obj;
}
public Parcel(String toString) {
}
public JSONObject getObj() {
return obj;
}
}

107
app/src/main/java/com/cst/im30/common/Payment.java

@ -1,107 +0,0 @@
package com.cst.im30.common;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Payment {
@SerializedName("reference_number")
@Expose
private String referenceNumber;
/*@Field("reference_number") String referenceNumber,
@Field("payment_type") String paymentType,
@Field("payment_function") String paymentFunction,
@Field("payment_camera_mode") String paymentCameraMode,
@Field("signature") String signature,
@Field("amount") String amount,
@Field("status") String status,
@Field("params_response") String paramsResponse);*/
@SerializedName("payment_type")
@Expose
private String paymentType;
@SerializedName("payment_function")
@Expose
private String paymentFunction;
@SerializedName("payment_camera_mode")
@Expose
private String paymentCameraMode;
@SerializedName("signature")
@Expose
private String signature;
@SerializedName("amount")
@Expose
private String amount;
@SerializedName("status")
@Expose
private String status;
@SerializedName("params_response")
@Expose
private String[] params;
public Payment(String referenceNumber, String paymentType, String paymentFunction, String paymentCameraMode, String signature,
String amount, String status, String[] params) {
this.referenceNumber = referenceNumber;
this.paymentType = paymentType;
this.paymentFunction = paymentFunction;
this.paymentCameraMode = paymentCameraMode;
this.signature = signature;
this.amount = amount;
this.status = status;
this.params = params;
}
//GETTER
public String getReferenceNumber() {
return referenceNumber;
}
public void setReferenceNumber(String referenceNumber) {
this.referenceNumber = referenceNumber;
}
public String getPaymentType() {
return paymentType;
}
public String getPaymentFunction() {
return paymentFunction;
}
public String getPaymentCameraMode() {
return paymentCameraMode;
}
public String getSignature() {
return signature;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
//SETTER
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String[] getParams() {
return params;
}
}

400
app/src/main/java/com/cst/im30/entity/Transaction.java

@ -1,400 +0,0 @@
package com.cst.im30.entity;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import java.io.Serializable;
@Entity(tableName = Transaction.TABLE_NAME)
public class Transaction implements Serializable {
public static final String TABLE_NAME = "transactions";
public static final String COLUMN_ID = "id";
public static final String COLUMN_TYPE = "type";
public static final String COLUMN_KEY_INDEX = "key_index";
public static final String COLUMN_SIGNATURE = "signature";
public static final String COLUMN_SIGNATURE_METHOD = "signature_method";
public static final String COLUMN_AMOUNT = "amount";
public static final String COLUMN_CAMERA_MODE = "camera_mode";
public static final String COLUMN_BANK_REF_NUM = "bank_ref_num";
public static final String COLUMN_BATCH_NO = "batch_no";
public static final String COLUMN_RESPONSE_CODE = "response_code";
public static final String COLUMN_RESPONSE_CODE_DESC = "response_code_desc";
public static final String COLUMN_CURRENCY = "currency";
public static final String COLUMN_CUSTOMER_ID = "customer_id";
public static final String COLUMN_DISPLAY_MID = "display_mid";
public static final String COLUMN_DISPLAY_TID = "display_tid";
public static final String COLUMN_ENTRY_MODE = "entry_mode";
public static final String COLUMN_FUNCTION = "function";
public static final String COLUMN_INVOICE_NO = "invoice_no";
public static final String COLUMN_MID = "mid";
public static final String COLUMN_QR_CODE = "qr_code";
public static final String COLUMN_SCHEME = "scheme";
public static final String COLUMN_TID = "tid";
public static final String COLUMN_TRACE_NO = "trace_no";
public static final String COLUMN_TXN_DESC = "txn_desc";
public static final String COLUMN_TXN_DT = "txn_dt";
public static final String COLUMN_TXN_ID = "txn_id";
public static final String COLUMN_STATUS = "status";
public static final String COLUMN_ORI_INVOICE_NO = "ori_invoice_no";
public static final String COLUMN_VOIDED_AT = "voided_at";
public static final String COLUMN_SETTLED_AT = "settled_at";
public static final String COLUMN_CREATED_AT = "created_at";
public static final String COLUMN_UPDATED_AT = "updated_at";
@PrimaryKey(autoGenerate = true)
private int id;
@ColumnInfo(name = COLUMN_TYPE)
private String type;
@ColumnInfo(name = COLUMN_KEY_INDEX)
private String keyIndex;
@ColumnInfo(name = COLUMN_SIGNATURE)
private String signature;
@ColumnInfo(name = COLUMN_SIGNATURE_METHOD)
private String signatureMethod;
@ColumnInfo(name = COLUMN_AMOUNT)
private String amount;
@ColumnInfo(name = COLUMN_CAMERA_MODE)
private String cameraMode;
@ColumnInfo(name = COLUMN_BANK_REF_NUM)
private String bankRefNum;
@ColumnInfo(name = COLUMN_BATCH_NO)
private String batchNo;
@ColumnInfo(name = COLUMN_RESPONSE_CODE)
private String responseCode;
@ColumnInfo(name = COLUMN_RESPONSE_CODE_DESC)
private String responseCodeDesc;
@ColumnInfo(name = COLUMN_CURRENCY)
private String currency;
@ColumnInfo(name = COLUMN_CUSTOMER_ID)
private String customerId;
@ColumnInfo(name = COLUMN_DISPLAY_MID)
private String displayMid;
@ColumnInfo(name = COLUMN_DISPLAY_TID)
private String displayTid;
@ColumnInfo(name = COLUMN_ENTRY_MODE)
private String entryMode;
@ColumnInfo(name = COLUMN_FUNCTION)
private String function;
@ColumnInfo(name = COLUMN_INVOICE_NO)
private String invoiceNo;
@ColumnInfo(name = COLUMN_MID)
private String mid;
@ColumnInfo(name = COLUMN_QR_CODE)
private String qrCode;
@ColumnInfo(name = COLUMN_SCHEME)
private String scheme;
@ColumnInfo(name = COLUMN_TID)
private String tid;
@ColumnInfo(name = COLUMN_TRACE_NO)
private String traceNo;
@ColumnInfo(name = COLUMN_TXN_DESC)
private String transactionDesc;
@ColumnInfo(name = COLUMN_TXN_DT)
private String transactionDt;
@ColumnInfo(name = COLUMN_TXN_ID)
private String transactionId;
@ColumnInfo(name = COLUMN_STATUS)
private String status;
@ColumnInfo(name = COLUMN_ORI_INVOICE_NO)
private String oriInvoiceNo;
@ColumnInfo(name = COLUMN_VOIDED_AT)
private String voidedAt;
@ColumnInfo(name = COLUMN_SETTLED_AT)
private String settledAt;
@ColumnInfo(name = COLUMN_CREATED_AT)
private String createdAt;
@ColumnInfo(name = COLUMN_UPDATED_AT)
private String updatedAt;
public Transaction() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getType() {
return type == null ? "" : type;
}
public void setType(String type) {
this.type = type;
}
public String getKeyIndex() {
return keyIndex == null ? "" : keyIndex;
}
public void setKeyIndex(String keyIndex) {
this.keyIndex = keyIndex;
}
public String getSignature() {
return signature == null ? "" : signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public String getSignatureMethod() {
return signatureMethod == null ? "" : signatureMethod;
}
public void setSignatureMethod(String signatureMethod) {
this.signatureMethod = signatureMethod;
}
public String getAmount() {
return amount == null ? "" : amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getCameraMode() {
return cameraMode == null ? "" : cameraMode;
}
public void setCameraMode(String cameraMode) {
this.cameraMode = cameraMode;
}
public String getBankRefNum() {
return bankRefNum == null ? "" : bankRefNum;
}
public void setBankRefNum(String bankRefNum) {
this.bankRefNum = bankRefNum;
}
public String getBatchNo() {
return batchNo == null ? "" : batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
public String getResponseCode() {
return responseCode == null ? "" : responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getResponseCodeDesc() {
return responseCodeDesc == null ? "" : responseCodeDesc;
}
public void setResponseCodeDesc(String responseCodeDesc) {
this.responseCodeDesc = responseCodeDesc;
}
public String getCurrency() {
return currency == null ? "" : currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getCustomerId() {
return customerId == null ? "" : customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getDisplayMid() {
return displayMid == null ? "" : displayMid;
}
public void setDisplayMid(String displayMid) {
this.displayMid = displayMid;
}
public String getDisplayTid() {
return displayTid == null ? "" : displayTid;
}
public void setDisplayTid(String displayTid) {
this.displayTid = displayTid;
}
public String getEntryMode() {
return entryMode == null ? "" : entryMode;
}
public void setEntryMode(String entryMode) {
this.entryMode = entryMode;
}
public String getFunction() {
return function == null ? "" : function;
}
public void setFunction(String function) {
this.function = function;
}
public String getInvoiceNo() {
return invoiceNo == null ? "" : invoiceNo;
}
public void setInvoiceNo(String invoiceNo) {
this.invoiceNo = invoiceNo;
}
public String getMid() {
return mid == null ? "" : mid;
}
public void setMid(String mid) {
this.mid = mid;
}
public String getQrCode() {
return qrCode == null ? "" : qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getScheme() {
return scheme == null ? "" : scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getTid() {
return tid == null ? "" : tid;
}
public void setTid(String tid) {
this.tid = tid;
}
public String getTraceNo() {
return traceNo == null ? "" : traceNo;
}
public void setTraceNo(String traceNo) {
this.traceNo = traceNo;
}
public String getTransactionDesc() {
return transactionDesc == null ? "" : transactionDesc;
}
public void setTransactionDesc(String transactionDesc) {
this.transactionDesc = transactionDesc;
}
public String getTransactionDt() {
return transactionDt == null ? "" : transactionDt;
}
public void setTransactionDt(String transactionDt) {
this.transactionDt = transactionDt;
}
public String getTransactionId() {
return transactionId == null ? "" : transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getStatus() {
return status == null ? "" : status;
}
public void setStatus(String status) {
this.status = status;
}
public String getOriInvoiceNo() {
return oriInvoiceNo == null ? "" : oriInvoiceNo;
}
public void setOriInvoiceNo(String oriInvoiceNo) {
this.oriInvoiceNo = oriInvoiceNo;
}
public String getVoidedAt() {
return voidedAt == null ? "" : voidedAt;
}
public void setVoidedAt(String voidedAt) {
this.voidedAt = voidedAt;
}
public String getSettledAt() {
return settledAt == null ? "" : settledAt;
}
public void setSettledAt(String settledAt) {
this.settledAt = settledAt;
}
public String getCreatedAt() {
return createdAt == null ? "" : createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public String getUpdatedAt() {
return updatedAt == null ? "" : updatedAt;
}
public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}
}

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

@ -0,0 +1,15 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class CancelRequest implements Serializable {
/**
* Mandatory 2 - 07 - Cancel
**/
private String payFunction = "07";
}

13
app/src/main/java/com/cst/im30/model/CancelResponse.java

@ -0,0 +1,13 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class CancelResponse implements Serializable {
private String payFunction;
private String payRespCode;
}

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

@ -7,5 +7,26 @@ 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;
private String profileIdOpera;
// IC Verification
private String documentType, documentNumber, firstName, lastName, action;
// Payment / Pre Auth / Sale Completion
private String payableAmount, payFunction, confirmationNumber, referenceNumber;
// Sale Completion
private String payAuthCode, payRefNum, token;
// Void
private String payTraceNo, payInvoiceNo, payPosTxnId;
// Set Date Time
private String payPosTxnDate, payPosTxnTime;
}

35
app/src/main/java/com/cst/im30/model/InquiryRequest.java

@ -0,0 +1,35 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class InquiryRequest implements Serializable {
/**
* Mandatory 2 - 03 - Inquiry
**/
private String payFunction = "03";
/**
* Optional 12 - Original amount in cents (RM5.00 is "500")
**/
private String payAmount;
/**
* Optional 1 - Y or N for Print Receipt or Not
**/
private String payPrintReceiptId = "N";
/**
* Conditional 6 - Original Trace Number
**/
private String payTraceNo;
/**
* Conditional 6 - Original Invoice Number
**/
private String payInvoiceNo;
}

29
app/src/main/java/com/cst/im30/model/InquiryResponse.java

@ -0,0 +1,29 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class InquiryResponse implements Serializable {
private String payAmount;
private String payFunction;
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 payRespQrTxnId;
private String payRespQrWalletId;
private String payRespCustomerId;
private String payRespCode;
private String payRespErrorDesc;
private String payRespMerchInfo;
private String payRespIssuerId;
}

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

@ -0,0 +1,31 @@
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;
}

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

@ -0,0 +1,45 @@
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;
}

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

@ -0,0 +1,40 @@
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;
}

25
app/src/main/java/com/cst/im30/model/SetDateTimeRequest.java

@ -0,0 +1,25 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SetDateTimeRequest implements Serializable {
/**
* Mandatory 2 - 12 - Set Date Time
**/
private String payFunction = "12";
/**
* Mandatory 8 - YYYYMMDD
**/
private String payPosTxnDate;
/**
* Mandatory 6 - HHMMSS
**/
private String payPosTxnTime;
}

16
app/src/main/java/com/cst/im30/model/SetDateTimeResponse.java

@ -0,0 +1,16 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SetDateTimeResponse implements Serializable {
private String payFunction;
private String payRespTxnDate;
private String payRespTxnTime;
private String payRespCode;
private String payRespErrorDesc;
}

25
app/src/main/java/com/cst/im30/model/SettlementRequest.java

@ -0,0 +1,25 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SettlementRequest implements Serializable {
/**
* Mandatory 2 - 11 - Settlement
**/
private String payFunction = "11";
/**
* Optional 1 - Y or N for Print Receipt or Not
**/
private String payPrintReceiptId = "N";
/**
* Optional 50
**/
private String payPosTxnId;
}

21
app/src/main/java/com/cst/im30/model/SettlementResponse.java

@ -0,0 +1,21 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class SettlementResponse implements Serializable {
private String payFunction;
private String payPrintReceiptId;
private String payRespTxnDate;
private String payRespTxnTime;
private String payRespBatchNo;
private String payRespTid;
private String payRespMid;
private String payRespCode;
private String payRespErrorDesc;
private String payRespMerchInfo;
}

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

@ -0,0 +1,40 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class VoidRequest implements Serializable {
/**
* Mandatory 2 - 02 - Void
**/
private String payFunction = "02";
/**
* Optional 12 - Original amount in cents (RM5.00 is "500")
**/
private String payAmount; //
/**
* Optional 1 - Y or N for Print Receipt or Not
**/
private String payPrintReceiptId = "N";
/**
* Conditional 6 - Original Trace Number
**/
private String payTraceNo;
/**
* Conditional 6 - Original Invoice Number
**/
private String payInvoiceNo;
/**
* Conditional 50
**/
private String payPosTxnId;
}

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

@ -0,0 +1,37 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class VoidResponse 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 payRespQrTxnId;
private String payRespQrWalletId;
private String payRespCardNo;
private String payRespIssuerId;
private String payRespCustomerId;
private String payRespCardAppCryptogram;
private String payRespCode;
private String payRespErrorDesc;
private String payRespMerchInfo;
private String payRespTvr;
private String payRespCvmDesc;
private String payRespAppLabel;
}

86
app/src/main/java/com/cst/im30/retrofit/RetrofitAPICollection.java

@ -1,86 +0,0 @@
package com.cst.im30.retrofit;
import com.cst.im30.common.Payment;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
public interface RetrofitAPICollection {
@GET("launch")
Call<String> getLaunch();
//Get data from Laravel Echo Server
@GET("/payment-request")
Call<Payment> getData();
@Headers({
"Accept: application/json",
"Content-Type: application/json"
})
@GET("api/v1/kiosk/broadcast-event-log/{eventCode}")
Call<String> getBroadcastEventLogDetails(
@Header("Client-Id") String clientId,
@Header("Client-Secret") String clientSecret,
@Path("eventCode") String referenceNumber
);
@Headers({
"Accept: application/json",
"Content-Type: application/json"
})
@PUT("api/v1/kiosk/broadcast-event-log/{eventCode}")
Call<String> updateBroadcastEventLogDetails(
@Header("Client-Id") String clientId,
@Header("Client-Secret") String clientSecret,
@Body String body,
@Path("eventCode") String referenceNumber
);
@Headers({
"Accept: application/json"
})
@GET("api/intentpayment/requery")
Call<String> requeryCardPayment(@Header("Authorization") String token,
@Query("reference_number") String referenceNumberQuery,
@Query("merchant_code") String merchantCode,
@Query("payment_type") String paymentType,
@Query("amount") String amount,
@Query("signature") String signature);
@Headers({
"Accept: application/json",
"Content-Type: application/x-www-form-urlencoded"
})
@FormUrlEncoded
@PUT("api/intentpayment/update-status")
Call<String> updateStatusCardPayment(@Header("Authorization") String token,
@Field("reference_number") String referenceNumber,
@Field("status") String status,
@Field("merchant_code") String merchantCode,
@Field("amount") String amount,
@Field("response_code") String response_code,
@Field("signature") String signature,
@Field("params_response") String params_response);
/*Call<Payment> updateStatusCardPayment(@Header("Authorization") String token,
@Field("reference_number") String referenceNumber,
@Field("payment_type") String paymentType,
@Field("payment_function") String paymentFunction,
@Field("payment_camera_mode") String paymentCameraMode,
@Field("signature") String signature,
@Field("amount") String amount,
@Field("status") String status,
@Field("params_response") String paramsResponse);*/
}

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

@ -1,14 +1,14 @@
package com.cst.im30.service;
import android.content.Context;
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.retrofit.RetrofitAPICollection;
import com.cst.im30.retrofit.RetrofitClient;
import com.cst.im30.utility.Logger;
import org.json.JSONException;
import org.json.JSONObject;
@ -18,33 +18,38 @@ import retrofit2.Callback;
import retrofit2.Response;
public class IDVerificationService {
public static final String TAG = "IDVerificationService.";
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";
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 REJECT_EVENT_LOG = "REJECT";
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;
private String code;
private String status;
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) {
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class);
Call<String> call = service.getBroadcastEventLogDetails(clientId, clientSecret, code);
Logger.logAPI(code);
call.enqueue(new Callback<String>() {
@Override
@ -62,87 +67,140 @@ 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.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_GET_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logAPI(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());
t.printStackTrace();
}
callback.callBack(FAIL_GET_EVENT_LOG, t.getMessage());
}
private void updateBroadcastEventLogDetail(String code, String status) {
this.code = code;
this.status = 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.logAPI("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) {
onFailureUpdateBroadcastEventLogDetails(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.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
callback.callBack(CALLBACK_SUCCESS_UPDATE_EVENT_LOG);
Logger.logAPI(responseJSON.toString());
if (Constants.STATUS_REJECT.equalsIgnoreCase(status)) {
callback.callBack(REJECT_EVENT_LOG, code);
} else {
callback.callBack(SUCCESS_UPDATE_EVENT_LOG, responseJSON);
}
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureUpdateBroadcastEventLogDetails(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
t.printStackTrace();
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, t.getMessage());
}
public void verifySuccess(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_SUCCESS);
}
public void verifyFail(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_FAIL);
}
public void verifyCancel(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_CANCELLED);
}
public void verifyReject(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_REJECT);
}
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception {
String type = jsonObject.getJSONObject("data").getString("type");
String status = jsonObject.getJSONObject("data").getString("status");
String action = jsonObject.getJSONObject("data").getString("action");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String 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");
String id = jsonObject.getJSONObject("data").getJSONObject("content").getString("id");
String confirmationNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("confirmation_number");
String profileOperaId = jsonObject.getJSONObject("data").getJSONObject("content").getString("profile_id_opera");
EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setAction(action);
eventLogDetailed.setType(type);
eventLogDetailed.setStatus(status);
eventLogDetailed.setDocumentType(documentType);
eventLogDetailed.setDocumentNumber(documentNumber);
eventLogDetailed.setFirstName(firstName);
eventLogDetailed.setLastName(lastName);
eventLogDetailed.setId(Integer.parseInt(id));
eventLogDetailed.setConfirmationNumber(confirmationNumber);
eventLogDetailed.setProfileIdOpera(profileOperaId);
return eventLogDetailed;
}
}

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

@ -0,0 +1,208 @@
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.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;
@SuppressWarnings({"unused"})
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";
public static final String REJECT_EVENT_LOG = "REJECT";
private final CallableInterface callback;
private final String hostUrl;
private final String clientId;
private final String clientSecret;
private String code;
private String status;
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.logAPI(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.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_GET_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logAPI(responseJSON.toString());
EventLogDetailed eventLogDetailed = this.parseGetEventLogResponse(responseJSON);
callback.callBack(SUCCESS_GET_EVENT_LOG, eventLogDetailed);
}
} catch (Exception e) {
e.printStackTrace();
Logger.logE(e.getMessage());
}
}
private void onFailureGetEventLog(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
t.printStackTrace();
}
callback.callBack(FAIL_GET_EVENT_LOG, t.getMessage());
}
private void updateBroadcastEventLogDetail(String code, String status) {
this.code = code;
this.status = 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.logAPI("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) {
onFailureUpdateBroadcastEventLogDetails(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.logAPI(responseJSON.toString());
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON);
} else {
JSONObject responseJSON = new JSONObject(response.body());
Logger.logAPI(responseJSON.toString());
if (Constants.STATUS_REJECT.equalsIgnoreCase(status)) {
callback.callBack(REJECT_EVENT_LOG, code);
} else {
callback.callBack(SUCCESS_UPDATE_EVENT_LOG, responseJSON);
}
}
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
}
}
private void onFailureUpdateBroadcastEventLogDetails(Throwable t) {
if (t instanceof Exception) {
Logger.logE(t.getMessage());
t.printStackTrace();
}
callback.callBack(FAIL_UPDATE_EVENT_LOG, t.getMessage());
}
public void verifySuccess(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_SUCCESS);
}
public void verifyFail(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_FAIL);
}
public void verifyCancel(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_CANCELLED);
}
public void verifyReject(String code) {
updateBroadcastEventLogDetail(code, Constants.STATUS_REJECT);
}
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;
}
}

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

@ -0,0 +1,154 @@
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.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.logAPI(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());
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;
}
}

156
app/src/main/java/com/cst/im30/service/UploadTransactionSaleCompletionPaymentService.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.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.logAPI(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());
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.logAPI(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());
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;
}
}

143
app/src/main/java/com/cst/im30/utility/CloudWatchLogger.java

@ -0,0 +1,143 @@
package com.cst.im30.utility;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.logs.AmazonCloudWatchLogsClient;
import com.amazonaws.services.logs.model.CreateLogGroupRequest;
import com.amazonaws.services.logs.model.CreateLogStreamRequest;
import com.amazonaws.services.logs.model.DescribeLogStreamsRequest;
import com.amazonaws.services.logs.model.InputLogEvent;
import com.amazonaws.services.logs.model.LogStream;
import com.amazonaws.services.logs.model.PutLogEventsRequest;
import com.amazonaws.services.logs.model.PutLogEventsResult;
import com.amazonaws.services.logs.model.ResourceAlreadyExistsException;
import com.cst.im30.BuildConfig;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@SuppressWarnings({"unused"})
public class CloudWatchLogger {
private AmazonCloudWatchLogsClient client;
private PutLogEventsResult putLogEventsResult; // if you want to view the results of the put I guess
public CloudWatchLogger() {
// Can connect right away if you bundle the credentials in the Application.
// If you use another method, just call connect() AFTER you have your credentials.
connect();
}
private void connect() {
String accessKey = BuildConfig.AWS_ACCESS_KEY;
String secretKey = BuildConfig.AWS_SECRET_KEY;
BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonCloudWatchLogsClient client = new AmazonCloudWatchLogsClient(basicAWSCredentials);
Regions regions = Regions.AP_SOUTHEAST_1; // Singapore
client.setRegion(Region.getRegion(regions));
this.client = client;
}
/**
* As you can see, the code is put into a Thread to run in background.
* The actual calls to CloudWatch have to be run in a background thread unless we turn off the checking.
*/
public void log(String logGroupName, String logStreamName, String message) {
String fullLogStreamName = getPrefix() + logStreamName;
try {
Thread t = new Thread(() -> {
// Create LogGroup / LogStream (Will ignore if already created)
createCloudWatchGroups(logGroupName, fullLogStreamName);
// Prepare the LogMessage that you will send
List<InputLogEvent> logEvents = new ArrayList<>();
InputLogEvent log = new InputLogEvent();
Calendar calendar = Calendar.getInstance();
log.setTimestamp(calendar.getTimeInMillis());
log.setMessage(message);
logEvents.add(log);
// Check Cloudwatch for logStream if exist, to get the uploadSequenceToken.
// Without this token you can still push events, but cannot push additional events to the an existing logGroup/logStream.
// With the token, you can "append" the logStream (which we want).
// https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogStreams.html
DescribeLogStreamsRequest logStreamsRequest = new DescribeLogStreamsRequest(logGroupName);
logStreamsRequest.withLimit(10); // Up to 50. Increase/Decrease depending on how many different streamNames you maintain
logStreamsRequest.setLogStreamNamePrefix(getPrefix());
List<LogStream> logStreamList = client.describeLogStreams(logStreamsRequest).getLogStreams();
String token = null;
for (LogStream logStream : logStreamList) {
if (logStream.getLogStreamName().equalsIgnoreCase(fullLogStreamName)) {
token = logStream.getUploadSequenceToken();
}
}
PutLogEventsRequest putLogEventsRequest = new PutLogEventsRequest();
putLogEventsRequest.setLogGroupName(logGroupName);
putLogEventsRequest.setLogStreamName(fullLogStreamName);
putLogEventsRequest.setLogEvents(logEvents);
if (token != null) {
putLogEventsRequest.setSequenceToken(token);
}
putLogEventsResult = client.putLogEvents(putLogEventsRequest);
//Logger.logD("Pushed log to AWS Cloudwatch");
});
t.start();
t.join();
} catch (InterruptedException ignored) {
}
}
private void createCloudWatchGroups(String logGroupName, String logStreamName) {
try {
Thread t = new Thread(() -> {
CreateLogGroupRequest createLogGroupRequest = new CreateLogGroupRequest(logGroupName);
try {
client.createLogGroup(createLogGroupRequest);
} catch (Exception e) {
if (e instanceof ResourceAlreadyExistsException) {
assert true; // do nothing
} else {
e.printStackTrace();
}
}
CreateLogStreamRequest createLogStreamRequest = new CreateLogStreamRequest(logGroupName, logStreamName);
try {
client.createLogStream(createLogStreamRequest);
} catch (Exception e) {
if (e instanceof ResourceAlreadyExistsException) {
assert true; // do nothing
} else {
e.printStackTrace();
}
}
});
t.start();
t.join();
} catch (InterruptedException ignored) {
}
}
private String getPrefix() {
String dateString = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH).format(new Date());
String kioskCode = BuildConfig.KIOSK_CODE;
return dateString + "_IM30_" + kioskCode + "_" + BuildConfig.FLAVOR + "_";
}
}

11
app/src/main/java/com/cst/im30/utility/IccTester.java

@ -11,7 +11,7 @@ public class IccTester {
public static IDAL idal = null;
private static IccTester iccTester;
private IIcc icc;
private final IIcc icc;
private IccTester(Context context) {
try {
@ -32,7 +32,7 @@ public class IccTester {
}
public byte[] init(byte slot) {
byte[] initRes = null;
byte[] initRes;
try {
initRes = icc.init(slot);
@ -44,14 +44,14 @@ public class IccTester {
}
public boolean detect(byte slot) {
boolean res = false;
boolean res;
try {
res = icc.detect(slot);
return res;
} catch (IccDevException e) {
e.printStackTrace();
return res;
return false;
}
}
@ -73,8 +73,7 @@ public class IccTester {
public byte[] isoCommand(byte slot, byte[] send) {
try {
byte[] resp = icc.isoCommand(slot, send);
return resp;
return icc.isoCommand(slot, send);
} catch (IccDevException e) {
e.printStackTrace();
return null;

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;
}
}
}

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

@ -1,19 +1,121 @@
package com.cst.im30.utility;
import android.os.Environment;
import android.util.Log;
import com.bugfender.sdk.Bugfender;
import com.cst.im30.MainApplication;
import com.cst.im30.model.EventLogDetailed;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
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);
Bugfender.d("DEBUG", 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);
Bugfender.i("INFO", 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);
Bugfender.t("VERBOSE", title + " - " + message);
}
public static void logAPI(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber();
Log.v(TAG, title + " - " + message);
Bugfender.t("API", title + " - " + message);
}
public static void logE(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
String title = getClassSimpleName(l.getClassName()) + "/" + l.getMethodName() + "():" + l.getLineNumber();
Log.e(TAG, title + " - " + message);
Bugfender.e("ERROR", title + " - " + message);
MainApplication.getInstance().logError(title + " - " + message);
Bugfender.sendIssue(title, message);
}
public static void logW(String message) {
StackTraceElement l = new Exception().getStackTrace()[1];
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();
Log.wtf(TAG, title + " - " + message);
Bugfender.f("WTF", title + " - " + message);
}
private static String getClassSimpleName(String className) {
String[] strs = className.split(Pattern.quote("."));
return strs[strs.length - 1];
}
public static String getTimeStamp() {
return new SimpleDateFormat("yyyyMMdd HH:mm:ss", Locale.ENGLISH).format(new Date());
}
// ---------------------------------------------------------------------------------------------
public static void recordICScan(String data) {
try {
String filename = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH).format(new Date());
File appDirectory = new File(Environment.getExternalStorageDirectory() + "/CST");
File logDirectory = new File(appDirectory + "/icLogs");
File logFile = new File(logDirectory, filename + ".txt");
// create app folder
if (!appDirectory.exists()) {
appDirectory.mkdir();
}
// create log folder
if (!logDirectory.exists()) {
logDirectory.mkdir();
}
EventLogDetailed eventLogDetailed = MainApplication.currentEventLogDetailed;
String extra = "ID:" + eventLogDetailed.getId() + ", C/N:" + eventLogDetailed.getConfirmationNumber() + ", OperaID:" + eventLogDetailed.getProfileIdOpera();
String dataToWrite = "[" + getTimeStamp() + "] - " + data + " - " + extra + "\n";
FileOutputStream out = new FileOutputStream(logFile, true);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(out);
outputStreamWriter.write(dataToWrite);
outputStreamWriter.close();
//Logger.logD("Recorded to " + logFile.getName());
Bugfender.i("IC SCAN", dataToWrite);
MainApplication.getInstance().logICScan(data + " - " + extra);
} catch (IOException e) {
Log.e("Exception", "File write failed: " + e.toString());
}
}
}

89
app/src/main/java/com/cst/im30/utility/NRICApduUtils.java

@ -0,0 +1,89 @@
package com.cst.im30.utility;
import android.content.Context;
import java.util.Arrays;
@SuppressWarnings({"unused"})
public class NRICApduUtils {
public static byte[] selectAppJPN(Context applicationContext) {
byte[] selectJpn = new byte[]{(byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x0A, (byte) 0xA0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x74, (byte) 0x4A, (byte) 0x50, (byte) 0x4E, (byte) 0x00, (byte) 0x10};
Logger.logD("Select APP JPN");
return IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectJpn);
}
public static String getOriginalName(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x96, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x96, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x96};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_OrgName:" + str);
return str;
}
public static String getGMPCName(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x50, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x99, (byte) 0x00, (byte) 0x50, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x50};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_GMPCName:" + str);
return str;
}
public static String getKPTName(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x28, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xE9, (byte) 0x00, (byte) 0x28, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x28};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_KPTName:" + str);
return str;
}
public static String getIDNum(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x0D, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x11, (byte) 0x01, (byte) 0x0D, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x0D};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_IDNum:" + str);
return str;
}
}

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

@ -0,0 +1,206 @@
package com.cst.im30.utility;
import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.model.InquiryRequest;
import com.cst.im30.model.PreAuthRequest;
import com.cst.im30.model.SaleCompletionRequest;
import com.cst.im30.model.SaleRequest;
import com.cst.im30.model.SetDateTimeRequest;
import com.cst.im30.model.SettlementRequest;
import com.cst.im30.model.VoidRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
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 VoidRequest createVoidRequest(EventLogDetailed eventLogDetailed) {
VoidRequest request = new VoidRequest();
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.setPayTraceNo(eventLogDetailed.getPayTraceNo());
request.setPayInvoiceNo(eventLogDetailed.getPayInvoiceNo());
return request;
}
public static InquiryRequest createInquiryRequest(EventLogDetailed eventLogDetailed) {
InquiryRequest request = new InquiryRequest();
double doubleValue = Double.parseDouble(eventLogDetailed.getPayableAmount());
double centValueDouble = doubleValue * 100;
DecimalFormat df = new DecimalFormat("#");
request.setPayAmount(String.valueOf(df.format(centValueDouble)));
request.setPayTraceNo(eventLogDetailed.getPayTraceNo());
request.setPayInvoiceNo(eventLogDetailed.getPayInvoiceNo());
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());
String token = eventLogDetailed.getToken();
try {
token = URLDecoder.decode(token, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Logger.logV("Token: " + token);
request.setToken(token);
return request;
}
public static SettlementRequest createSettlementRequest(EventLogDetailed eventLogDetailed) {
SettlementRequest request = new SettlementRequest();
request.setPayPosTxnId(eventLogDetailed.getReferenceNumber() + eventLogDetailed.getId());
return request;
}
public static SetDateTimeRequest createSetDateTimeRequest(EventLogDetailed eventLogDetailed) {
SetDateTimeRequest request = new SetDateTimeRequest();
request.setPayPosTxnDate(eventLogDetailed.getPayPosTxnDate());
request.setPayPosTxnTime(eventLogDetailed.getPayPosTxnTime());
return request;
}
public static boolean validateSaleRequest(SaleRequest request) {
boolean valid = true;
//todo
return valid;
}
public static boolean validateVoidRequest(VoidRequest request) {
boolean valid = true;
//todo
return valid;
}
public static boolean validateInquiryRequest(InquiryRequest 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 validateSettlementRequest(SettlementRequest request) {
boolean valid = true;
//todo
return valid;
}
public static boolean validateSetDateTimeRequest(SetDateTimeRequest 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;
}
}
}

170
app/src/main/res/drawable-v24/ic_udc_launcher_background.xml

@ -1,170 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

10
app/src/main/res/drawable/echo_ic_offline.xml

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#C60E0E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M3,5v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2L5,3c-1.11,0 -2,0.9 -2,2zM15,9c0,1.66 -1.34,3 -3,3s-3,-1.34 -3,-3 1.34,-3 3,-3 3,1.34 3,3zM6,17c0,-2 4,-3.1 6,-3.1s6,1.1 6,3.1v1L6,18v-1z" />
</vector>

10
app/src/main/res/drawable/echo_ic_online.xml

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#4DAE37"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M3,5v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2L5,3c-1.11,0 -2,0.9 -2,2zM15,9c0,1.66 -1.34,3 -3,3s-3,-1.34 -3,-3 1.34,-3 3,-3 3,1.34 3,3zM6,17c0,-2 4,-3.1 6,-3.1s6,1.1 6,3.1v1L6,18v-1z" />
</vector>

10
app/src/main/res/drawable/echo_payment_offline.xml

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#C60E0E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
</vector>

10
app/src/main/res/drawable/echo_payment_online.xml

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#4DAE37"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z" />
</vector>

4
app/src/main/res/drawable/ic_status_fail.xml

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="400dp"
android:height="400dp"
android:width="200dp"
android:height="200dp"
android:tint="#FF0000"
android:viewportWidth="24.0"
android:viewportHeight="24.0">

4
app/src/main/res/drawable/ic_status_success.xml

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="400dp"
android:height="400dp"
android:width="200dp"
android:height="200dp"
android:tint="#00FF00"
android:viewportWidth="24.0"
android:viewportHeight="24.0">

13
app/src/main/res/drawable/layout_border.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke
android:width="3dip"
android:color="#B1BCBE" />
<corners android:radius="10dip" />
<padding
android:bottom="0dip"
android:left="0dip"
android:right="0dip"
android:top="0dip" />
</shape>

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

@ -5,6 +5,75 @@
android:layout_height="match_parent"
tools:context=".activity.MainActivity">
<LinearLayout
android:id="@+id/echoStatusLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:weightSum="2">
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_weight="1"
android:background="@drawable/layout_border">
<ImageView
android:id="@+id/paymentEchoStatusImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:adjustViewBounds="true"
android:contentDescription="Payment Connection Status"
android:scaleType="fitXY"
android:src="@drawable/echo_payment_offline"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/paymentEchoStatusTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:gravity="bottom|center_horizontal"
android:text="@string/offline_caps"
android:textColor="@color/offline"
android:textSize="16sp"
android:textStyle="bold" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_weight="1"
android:background="@drawable/layout_border">
<ImageView
android:id="@+id/icEchoStatusImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:adjustViewBounds="true"
android:contentDescription="NRIC Connection Status"
android:scaleType="fitXY"
android:src="@drawable/echo_ic_offline"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/icEchoStatusTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:gravity="bottom|center_horizontal"
android:text="@string/offline_caps"
android:textColor="@color/offline"
android:textSize="16sp"
android:textStyle="bold" />
</FrameLayout>
</LinearLayout>
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider_layout_ma"
android:layout_width="match_parent"
@ -22,9 +91,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 +105,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>

31
app/src/main/res/layout/activity_pay.xml

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/title_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="300dp"
android:layout_marginBottom="10dp"
android:text="Revenue Payment API Spec"
android:textColor="@color/teal_700"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/title_response"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="0dp"
android:layout_marginBottom="10dp"
android:text="Response code return here..."
android:textColor="@color/green"
android:textSize="20dp"
android:textStyle="italic" />
</LinearLayout>

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

@ -1,262 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
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>

189
app/src/main/res/layout/activity_status.xml

@ -1,189 +0,0 @@
<?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="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/white"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.StatusActivity">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_status_sta"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:contentDescription="@string/txt_image_description"
android:src="@drawable/ic_status_success" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_status_sta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/txt_success_status"
android:textColor="#1d504a"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="@+id/text_info_sta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/text_status_sta"
android:layout_centerHorizontal="true"
android:paddingLeft="30dp"
android:paddingTop="30dp"
android:paddingRight="30dp"
android:paddingBottom="20dp"
android:text="@string/txt_info_status"
android:textAlignment="center"
android:textColor="@color/grey_8e98a6"
android:textSize="20sp" />
<TextView
android:id="@+id/text_info_amount_sta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/text_info_sta"
android:layout_centerHorizontal="true"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text="@string/txt_info_amount_status"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_ok_donation_sta"
android:layout_width="200dp"
android:layout_height="70dp"
android:layout_marginStart="40dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:background="@drawable/btn_general_enable_bg"
android:gravity="center"
android:padding="20dp"
android:text="@string/btn_ok_donation_status"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="@+id/button_pay_again_sta"
android:layout_width="200dp"
android:layout_height="70dp"
android:layout_below="@id/button_ok_donation_sta"
android:layout_marginStart="40dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:background="@drawable/btn_general_enable_bg"
android:gravity="center"
android:padding="20dp"
android:text="@string/btn_pay_again_status"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible" />
<Button
android:id="@+id/button_no_pay_again_sta"
android:layout_width="200dp"
android:layout_height="70dp"
android:layout_below="@id/button_pay_again_sta"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:background="@drawable/btn_general_disable_bg"
android:gravity="center"
android:padding="20dp"
android:text="@string/btn_no_pay_again_status"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible" />
</RelativeLayout>
<!--<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button_ok_donation_sta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="80dp"
android:layout_marginBottom="80dp"
android:layout_weight="1"
android:background="@drawable/btn_general_enable_bg"
android:padding="20dp"
android:text="@string/btn_ok_donation_status"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="@+id/button_pay_again_sta"
android:layout_width="200dp"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:background="@drawable/btn_general_enable_bg"
android:padding="20dp"
android:text="@string/btn_pay_again_status"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible" />
<Button
android:id="@+id/button_no_pay_again_sta"
android:layout_width="200dp"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:background="@drawable/btn_general_enable_bg"
android:padding="20dp"
android:text="@string/btn_no_pay_again_status"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible" />
</LinearLayout>-->
</LinearLayout>

6
app/src/main/res/layout/pop_up_message_option.xml

@ -56,7 +56,8 @@
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold" />
android:textStyle="bold"
style="?android:attr/buttonBarButtonStyle" />
<Button
android:id="@+id/button_yes_pop_up_message_option"
@ -71,7 +72,8 @@
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold" />
android:textStyle="bold"
style="?android:attr/buttonBarButtonStyle" />
</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>

3
app/src/main/res/layout/toolbar.xml

@ -26,7 +26,8 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:src="@drawable/ic_baseline_settings_24" />
android:src="@drawable/ic_baseline_settings_24"
android:contentDescription="TODO" />
</RelativeLayout>

3
app/src/main/res/layout/toolbar_setting.xml

@ -27,7 +27,8 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:src="@drawable/ic_baseline_keyboard_return_24" />
android:src="@drawable/ic_baseline_keyboard_return_24"
android:contentDescription="TODO" />
</RelativeLayout>

5
app/src/main/res/mipmap-anydpi-v26/ic_udc_launcher.xml

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_udc_launcher_background" />
<foreground android:drawable="@mipmap/ic_udc_launcher_foreground" />
</adaptive-icon>

5
app/src/main/res/mipmap-anydpi-v26/ic_udc_launcher_round.xml

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_udc_launcher_background" />
<foreground android:drawable="@mipmap/ic_udc_launcher_foreground" />
</adaptive-icon>

BIN
app/src/main/res/mipmap-hdpi/ic_udc_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

BIN
app/src/main/res/mipmap-hdpi/ic_udc_launcher_foreground.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

BIN
app/src/main/res/mipmap-hdpi/ic_udc_launcher_round.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

BIN
app/src/main/res/mipmap-mdpi/ic_udc_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

BIN
app/src/main/res/mipmap-mdpi/ic_udc_launcher_foreground.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

BIN
app/src/main/res/mipmap-mdpi/ic_udc_launcher_round.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

BIN
app/src/main/res/mipmap-xhdpi/ic_udc_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

BIN
app/src/main/res/mipmap-xhdpi/ic_udc_launcher_foreground.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

BIN
app/src/main/res/mipmap-xhdpi/ic_udc_launcher_round.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

BIN
app/src/main/res/mipmap-xxhdpi/ic_udc_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

BIN
app/src/main/res/mipmap-xxhdpi/ic_udc_launcher_foreground.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

BIN
app/src/main/res/mipmap-xxhdpi/ic_udc_launcher_round.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

BIN
app/src/main/res/mipmap-xxxhdpi/ic_udc_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

BIN
app/src/main/res/mipmap-xxxhdpi/ic_udc_launcher_foreground.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

BIN
app/src/main/res/mipmap-xxxhdpi/ic_udc_launcher_round.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

2
app/src/main/res/values-night/themes.xml

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Udcpaymentterminalim30" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.IM30" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>

3
app/src/main/res/values/colors.xml

@ -20,4 +20,7 @@
<color name="green_2dcc70">#2DCC70</color>
<color name="grey_8e98a6">#8e98a6</color>
<color name="offline">#C60E0E</color>
<color name="online">#4DAE37</color>
</resources>

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

@ -5,8 +5,8 @@
<!--for General usage-->
<string name="txt_title">Title</string>
<string name="txt_message">Message</string>
<string name="txt_wait">Please wait...</string>
<string name="txt_ok">Ok</string>
<string name="txt_wait">Please wait</string>
<string name="txt_ok">OK</string>
<string name="txt_cancel">Cancel</string>
<string name="txt_yes">Yes</string>
<string name="txt_no">No</string>
@ -18,7 +18,7 @@
<string name="status_connected">Online</string>
<!--<string name="status_not_connected">Not Connected</string>-->
<string name="status_not_connected">Offline</string>
<string name="txt_title_main">Processing...</string>
<string name="txt_title_main">Processing</string>
<!--<string name="txt_title_main">Receiving Payment Information...</string>-->
<string name="button_connect">Connect</string>
<string name="button_disconnect">Disconnect</string>
@ -70,8 +70,12 @@
<string name="txt_info_amount_status">RM..</string>
<string name="txt_fail_status">Payment Failed</string>
<string name="txt_fail_info_status">Oops, your payment has failed!</string>
<string name="btn_ok_donation_status">Ok</string>
<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>
<string name="offline_caps">OFFLINE</string>
<string name="online_caps">ONLINE</string>
</resources>

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

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Udcpaymentterminalim30" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.IM30" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>

28
gradle.properties

@ -15,4 +15,30 @@ 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
# Echo Socket
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"
# Bugfender
BUGFENDER_TOKEN="rocgWcZ0aLZH7s1XqK6PpV3WeyBVb0w0"
# AWS
AWS_ACCESS_KEY="AKIAXHWEPPPSPOMSLL5R"
AWS_SECRET_KEY="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"
LOG_GROUP_NAME="hotel-kiosk"

BIN
kiosk-im30-hello-kiosk.jks

Binary file not shown.
Loading…
Cancel
Save