Compare commits

...

2 Commits

Author SHA1 Message Date
MooN
58118a2fb5 production ready 2026-01-13 23:34:12 +06:30
c9dd1b93f7 optimized refund 2026-01-13 14:57:32 +06:30
17 changed files with 156 additions and 81 deletions

View File

@ -13,12 +13,6 @@
</DropdownSelection>
<DialogSelection />
</SelectionState>
<SelectionState runConfigName="testSalePacket()">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="testResponseSalePacket()">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View File

@ -47,34 +47,6 @@ android {
}
}
// defaultConfig {
// applicationId "com.utsmm.kbz.sit"
// minSdk 24
// targetSdk 33
// versionCode 1
// versionName "1.0"
//
//// applicationId "com.utsmm.kbz"
//// versionName "1.10"
//
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//
//// // Add CMake configuration
//// externalNativeBuild {
//// cmake {
//// cppFlags "-std=c++14"
//// }
//// }
// }
// Configure CMake
// externalNativeBuild {
// cmake {
// path "src/main/cpp/CMakeLists.txt"
// version "3.22.1"
// }
// }
buildTypes {
release {
minifyEnabled true
@ -82,7 +54,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
debuggable false
}
}
compileOptions {

View File

@ -16,6 +16,8 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.WindowManager;
@ -28,6 +30,8 @@ import com.nexgo.downloadkey.downloadflow.DownloadFlow;
import com.nexgo.downloadkey.downloadflow.DownloadFlowProcessListener;
import com.nexgo.downloadkey.downloadflow.DownloadFlowResultEntity;
import com.nexgo.downloadkey.downloadflow.DownloadResult;
import com.nexgo.oaf.apiv3.device.pinpad.PinPad;
import com.nexgo.oaf.apiv3.device.pinpad.WorkKeyTypeEnum;
import com.utsmyanmar.baselib.BaseApplication;
import com.utsmyanmar.baselib.repo.Repository;
import com.utsmyanmar.baselib.ui.AnimationDialog;
@ -38,6 +42,7 @@ import com.utsmyanmar.paylibs.model.PayDetail;
import com.utsmyanmar.paylibs.print.printx.PrintXReceipt;
import com.utsmyanmar.paylibs.utils.POSUtil;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsSettings;
import com.utsmyanmar.paylibs.utils.enums.TransMenu;
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType;
import com.utsmm.kbz.databinding.ActivityMainNewBinding;
@ -105,6 +110,8 @@ public class MainActivity extends AppCompatActivity implements
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BaseApplication.getInstance().deviceEngine.getPlatform().hideNavigationBar();
// Keep screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -134,8 +141,32 @@ public class MainActivity extends AppCompatActivity implements
// Initialize special back handling fragments
initSpecialBackHandlingFragments();
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
initKey();
}
}, 500);
}
private void initKey(){
// SystemParamsOperation.getInstance().setTmsAddress("https://api-tms-uat.kbzbank.com:8443/sirius");
// SystemParamsOperation.getInstance().setTmsAddress("http://sirius-nest.utsmyanmar.com");
// SystemParamsOperation.getInstance().setEReceiptAddress("https://api-tms-uat.kbzbank.com:8443/receipt");
// SystemParamsOperation.getInstance().setEReceiptAddress("http://receipt-nest.utsmyanmar.com");
PinPad pinPad = MyApplication.getInstance().deviceEngine.getPinPad();
byte[] encryptedPIK = SystemParamsOperation.getInstance().getPIK();
if (encryptedPIK != null && encryptedPIK.length != 0) {
int result = pinPad.writeWKey(9, WorkKeyTypeEnum.PINKEY, encryptedPIK, encryptedPIK.length);
LogUtil.d(TAG, "save PIK key result: "+result);
} else {
LogUtil.d(TAG, "There's no PIK key!");
}
}
private void initViewModels() {
@ -396,15 +427,15 @@ public class MainActivity extends AppCompatActivity implements
SystemParamsOperation.getInstance().setDownloadedParams(false);
handleAutoSettlementIntent(getIntent());
BaseApplication.getInstance().deviceEngine.getPlatform().hideNavigationBar();
}
@Override
public void onStop(){
super.onStop();
BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
BaseApplication.getInstance().deviceEngine.getPlatform().enableHomeButton();
BaseApplication.getInstance().deviceEngine.getPlatform().enableTaskButton();
// BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
// BaseApplication.getInstance().deviceEngine.getPlatform().enableHomeButton();
// BaseApplication.getInstance().deviceEngine.getPlatform().enableTaskButton();
}
@Override
@ -472,14 +503,15 @@ public class MainActivity extends AppCompatActivity implements
@Override
public void onDestroy() {
super.onDestroy();
BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
BaseApplication.getInstance().deviceEngine.getPlatform().enableHomeButton();
BaseApplication.getInstance().deviceEngine.getPlatform().enableTaskButton();
// BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
// BaseApplication.getInstance().deviceEngine.getPlatform().enableHomeButton();
// BaseApplication.getInstance().deviceEngine.getPlatform().enableTaskButton();
// Clean up RxJava disposables
compositeDisposable.clear();
// Reset screen mode
// Disconnect ECR
ECRHelper.INSTANCE.disconnect();
BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
}
// Navigation drawer interaction listeners
@ -490,6 +522,12 @@ public class MainActivity extends AppCompatActivity implements
navController.navigate(R.id.inputPasswordFragment);
}
@Override
public void onPause(){
super.onPause();
BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
}
@Override
public void onClickFunction() {
closeDrawer();

View File

@ -146,10 +146,10 @@ public class MainFragment extends DataBindingFragment {
delayFunctionCall(() -> {
NexGoSDK.getInstance().cancelCheckCard();
NexGoSDK.getInstance().closeReader();
enableHomeButton();
disableTaskButton();
// enableHomeButton();
// disableTaskButton();
// BaseApplication.getInstance().deviceEngine.getPlatform().hideNavigationBar();
BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
// BaseApplication.getInstance().deviceEngine.getPlatform().showNavigationBar();
});
}

View File

@ -176,7 +176,7 @@ public class InputPasswordFragment extends DataBindingFragment implements DataBi
break;
case REFUND:
inputPasswordViewModel.passwordType.setValue(InputPasswordType.SYSTEM);
routeId = R.id.action_inputPasswordFragment_to_selectRefundFragment;
routeId = R.id.action_inputPasswordFragment_to_inputAmountFragment;
break;
case PRE_AUTH_COMPLETE:
inputPasswordViewModel.passwordType.setValue(InputPasswordType.SYSTEM);

View File

@ -526,7 +526,7 @@ public class InputRRNFragment extends DataBindingFragment {
String date = payDetail.getTransDate();
String time = payDetail.getTransTime();
if(checkRefund(configTime,date,time)) {
// if(checkRefund(configTime,date,time)) {
PayDetail newPay = transProcessViewModel.getPayDetail();
newPay.setReferNo(rrnNo);
@ -537,9 +537,9 @@ public class InputRRNFragment extends DataBindingFragment {
callNextScreen();
} else {
terminatedTransRefund(isECR);
}
// } else {
// terminatedTransRefund(isECR);
// }
} else {

View File

@ -179,10 +179,10 @@ public class ProcessingFragment extends DataBindingFragment {
}
if(sharedViewModel.payDetail.getValue() != null) {
EReceiptRequest request = EReceiptUtil.getInstance().generateMPUReceipt(sharedViewModel.payDetail.getValue());
sharedViewModel.pushReceipt(request);
}
// if(sharedViewModel.payDetail.getValue() != null) {
// EReceiptRequest request = EReceiptUtil.getInstance().generateMPUReceipt(sharedViewModel.payDetail.getValue());
// sharedViewModel.pushReceipt(request);
// }
// transProcessViewModel.payDetailResult.observe(getViewLifecycleOwner(), payDetail -> sharedViewModel.payDetail.postValue(payDetail));
}

View File

@ -223,6 +223,35 @@
</LinearLayout>
<!-- MMQR Ref Row -->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal"-->
<!-- android:gravity="center_vertical"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:visibility="@{(sharedViewModel.payDetail != null &amp;&amp; sharedViewModel.payDetail.qrReferNo != null &amp;&amp; !sharedViewModel.payDetail.qrReferNo.empty) ? android.view.View.VISIBLE : android.view.View.GONE}">-->
<!-- <TextView-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:text="MMQR Ref"-->
<!-- android:textColor="@color/colorTextContent"-->
<!-- android:textSize="14sp"-->
<!-- android:fontFamily="@font/rubik_regular" />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@{sharedViewModel.payDetail.qrReferNo}"-->
<!-- android:textColor="@color/colorTextTitle"-->
<!-- android:textSize="14sp"-->
<!-- android:fontFamily="@font/rubik_medium"-->
<!-- tools:text="REF123456789"-->
<!-- android:maxLines="1"-->
<!-- android:ellipsize="end"/>-->
<!-- </LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -231,27 +260,37 @@
android:layout_marginTop="8dp"
android:visibility="@{(sharedViewModel.payDetail != null &amp;&amp; sharedViewModel.payDetail.qrReferNo != null &amp;&amp; !sharedViewModel.payDetail.qrReferNo.empty) ? android.view.View.VISIBLE : android.view.View.GONE}">
<!-- Label : 30% -->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="MMQR Ref"
android:textColor="@color/colorTextContent"
android:textSize="14sp"
android:fontFamily="@font/rubik_regular" />
<!-- Value : 70% -->
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:gravity="end"
android:text="@{sharedViewModel.payDetail.qrReferNo}"
android:textColor="@color/colorTextTitle"
android:textSize="14sp"
android:fontFamily="@font/rubik_medium"
tools:text="REF123456789" />
android:maxLines="1"
android:ellipsize="end"
tools:text="REF123456789123456789123456789012345" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -51,11 +51,11 @@ public final class TerminalKeyUtil {
LogUtil.d(TAG, "save tmk key result: "+result);
byte[] encryptedPIK = SystemParamsOperation.getInstance().getKeyPIK().get(0);
result = pinPad.writeWKey(9, WorkKeyTypeEnum.PINKEY,encryptedPIK,encryptedPIK.length);
LogUtil.d(TAG, "save PIK key result: "+result);
// byte[] encryptedPIK = SystemParamsOperation.getInstance().getKeyPIK().get(0);
//
// result = pinPad.writeWKey(9, WorkKeyTypeEnum.PINKEY,encryptedPIK,encryptedPIK.length);
//
// LogUtil.d(TAG, "save PIK key result: "+result);
// LogUtil.d(TAG, "save pin key result: "+resultPINKEY);
// LogUtil.d(TAG, "save tdk key result: "+resultTDKEY);
// LogUtil.d(TAG, "save tek key result: "+resultTEK);

View File

@ -82,9 +82,6 @@ public class NetworkModule {
public static native String getTMSUrlFromNative();
public static String Refund_Base_Url = "https://api.kbzpay.com:18008/payment/gateway/uat/";
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
@ -395,6 +392,21 @@ public Retrofit provideKPayRefundRetrofit(@ApplicationContext Context context) {
// char[] password = "test123".toCharArray();
// public static String Refund_Base_Url = "https://api.kbzpay.com:18008/payment/gateway/uat/";
String refundBaseUrl = "";
String IpAddress = SystemParamsOperation.getInstance().getSecHostIpAddress();
if (IpAddress != null && !IpAddress.isEmpty()) {
refundBaseUrl = IpAddress;
}
if (refundBaseUrl.isEmpty()) {
refundBaseUrl = "https://api.kbzpay.com/payment/gateway/";
}
String pass = SystemParamsOperation.getInstance().getCertificatePassword();
if (TextUtils.isEmpty(pass)) {
pass = "test123";
@ -456,7 +468,7 @@ public Retrofit provideKPayRefundRetrofit(@ApplicationContext Context context) {
.build();
return new Retrofit.Builder()
.baseUrl(Refund_Base_Url)
.baseUrl(refundBaseUrl)
.client(okHttp)
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
@ -468,7 +480,7 @@ public Retrofit provideKPayRefundRetrofit(@ApplicationContext Context context) {
// Provide fallback Retrofit to avoid crash, but no SSL
return new Retrofit.Builder()
.baseUrl(Refund_Base_Url)
.baseUrl(refundBaseUrl)
.client(new OkHttpClient())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())

View File

@ -24,8 +24,8 @@ public interface KPayApiService {
//this accept "url" bez this api start with https and other are http in uat
@POST
Observable<KPayQRRequest.CloseOrderResponse> closeOrder(@Url String url, @Body KPayQRRequest.CloseOrderRequest closeOrderRequest);
@POST("closeorder")
Observable<KPayQRRequest.CloseOrderResponse> closeOrder(@Body KPayQRRequest.CloseOrderRequest closeOrderRequest);
//this 2 is for production

View File

@ -40,7 +40,7 @@ public class SiriusInterceptor implements Interceptor {
// hashed = TerminalUtil.getInstance().generateHashedString(nonce); // old tms
hashed = TerminalUtil.getInstance().generateHashedString(nonce).toLowerCase(); // new tms
LogUtil.d(TAG,"hashed :"+ hashed);
// LogUtil.d(TAG,"hashed :"+ hashed);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}

View File

@ -86,8 +86,8 @@ public class Repository {
}
public Observable<KPayQRRequest.CloseOrderResponse> qrCloseOrder(KPayQRRequest.CloseOrderRequest request){
String url = "https://api.kbzpay.com/payment/gateway/uat/closeorder"; //close this in prod
return kPayApiService.closeOrder(url, request);
// String url = "https://api.kbzpay.com/payment/gateway/uat/closeorder"; //close this in prod
return kPayApiService.closeOrder(request);
// return kPayApiService.closeOrder(request); //this is for prod
}

View File

@ -895,7 +895,7 @@ public abstract class BaseXPrint {
dashBreak();
print2ColumnsString("Sale Total :MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount));
dashBreak();
print2ColumnsString("Sale Total :MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount - refundTotal));
print2ColumnsString("Grand Total :MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount - refundTotal));
dashBreakEnding();
// emptyLine(2);

View File

@ -117,7 +117,7 @@ public class SignOnProcess {
}
LogUtil.d(TAG, "TMK Index:" + tmkIndex);
SystemParamsOperation.getInstance().saveKeyPIK(encryptedPIK, kcv);
SystemParamsOperation.getInstance().savePIK(encryptedPIK);
int res = PayLibNex.getInstance().deviceEngine.getPinPad().writeWKey(tmkIndex, WorkKeyTypeEnum.PINKEY,encryptedPIK,encryptedPIK.length);
// int res = PayLibsUtils.getInstance().securityOptV2.saveCiphertextKey(AidlConstantsV2.Security.KEY_TYPE_PIK, encryptedPIK, null, tmkIndex, AidlConstantsV2.Security.KEY_ALG_TYPE_3DES, 11);
@ -165,6 +165,7 @@ public class SignOnProcess {
tmkIndex = Integer.parseInt(SystemParamsOperation.getInstance().getTMKIndex());
}
SystemParamsOperation.getInstance().savePIK(encryptedPIK);
LogUtil.d(TAG, "TMK Index:" + tmkIndex);
int res = PayLibNex.getInstance().deviceEngine.getPinPad().writeWKey(tmkIndex, WorkKeyTypeEnum.PINKEY,encryptedPIK,encryptedPIK.length);
// int res = PayLibsUtils.getInstance().securityOptV2.saveCiphertextKey(AidlConstantsV2.Security.KEY_TYPE_PIK, encryptedPIK, null, tmkIndex, AidlConstantsV2.Security.KEY_ALG_TYPE_3DES, 11);

View File

@ -1,6 +1,7 @@
package com.utsmyanmar.paylibs.utils.core_utils;
import android.text.TextUtils;
import android.util.Base64;
import java.util.ArrayList;
import java.util.Locale;
@ -1046,22 +1047,34 @@ public class SystemParamsOperation {
saveSystemParamsSettings(params);
}
public void saveKeyPIK(byte[] pikValue,byte[] pikKcv){
public void savePIK(byte[] pikValue){
SystemParamsSettings params = getSystemParamsSettings();
params.setPik_value(pikValue);
params.setPik_kcv(pikKcv);
String pikString = Base64.encodeToString(pikValue, Base64.DEFAULT);
params.setPik_value(pikString);
saveSystemParamsSettings(params);
}
public ArrayList<byte[]> getKeyPIK(){
SystemParamsSettings params = getSystemParamsSettings();
ArrayList<byte[]> arrayList = new ArrayList<>();
arrayList.add(params.getPik_value());
// arrayList.add(params.getPik_value());
arrayList.add(params.getPik_kcv());
return arrayList;
}
public byte[] getPIK(){
SystemParamsSettings params = getSystemParamsSettings();
// return params.getPik_value();
if(params.getPik_value() != null)
return Base64.decode(params.getPik_value(), Base64.DEFAULT);
else
return null;
}
public void setConnectStatus(boolean status){
SystemParamsSettings params = getSystemParamsSettings();
params.setConnect_status(status);
@ -1656,6 +1669,11 @@ public class SystemParamsOperation {
return params.getCertificatePassword();
}
public void setEReceiptAddress(String url) {
SystemParamsSettings params = getSystemParamsSettings();
params.setEreceiptAddress(url);
saveSystemParamsSettings(params);
}
public String getEreceiptAddress() {
SystemParamsSettings params = getSystemParamsSettings();
return params.getEreceiptAddress();

View File

@ -243,7 +243,8 @@ public class SystemParamsSettings implements Serializable {
private boolean nfcEnabled = false;
private byte[] pik_value;
private String pik_value;
private byte[] pik_kcv;
@ -819,7 +820,7 @@ public class SystemParamsSettings implements Serializable {
this.batchNumStart = batchNumStart;
}
protected byte[] getPik_value() {
protected String getPik_value() {
return pik_value;
}
@ -827,7 +828,7 @@ public class SystemParamsSettings implements Serializable {
return pik_kcv;
}
protected void setPik_value(byte[] pik_value) {
protected void setPik_value(String pik_value) {
this.pik_value = pik_value;
}