Compare commits
6 Commits
1e29fd9fab
...
22d6066933
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22d6066933 | ||
|
|
affbe79d94 | ||
|
|
240172214d | ||
|
|
35973963e6 | ||
|
|
716030128a | ||
|
|
afd3d925e1 |
@ -13,6 +13,39 @@
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="unitTest">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-01-20T10:19:44.274945Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=0123456789ABCDEF" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="androidTest">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-01-20T10:19:44.274945Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=0123456789ABCDEF" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="main">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-01-20T10:19:44.274945Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=0123456789ABCDEF" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
@ -128,8 +128,8 @@ public class MainViewModel extends ViewModel {
|
||||
|
||||
|
||||
|
||||
public LiveData<List<PayDetail>> getDeleteTrans(String batchNo) {
|
||||
return repository.getDeleteTrans(batchNo);
|
||||
public LiveData<List<PayDetail>> getDeleteTrans() {
|
||||
return repository.getDeleteTrans();
|
||||
}
|
||||
|
||||
private LiveData<List<PayDetail>> getPreAuthTrans() {
|
||||
@ -171,7 +171,7 @@ public class MainViewModel extends ViewModel {
|
||||
settlementPOS.postValue(payDetails);
|
||||
}
|
||||
});
|
||||
getDeleteTrans(SystemParamsOperation.getInstance().getCurrentBatchNum()).observeForever(new Observer<List<PayDetail>>() {
|
||||
getDeleteTrans().observeForever(new Observer<List<PayDetail>>() {
|
||||
@Override
|
||||
public void onChanged(List<PayDetail> payDetails) {
|
||||
deleteTrans.postValue(payDetails);
|
||||
|
||||
@ -116,7 +116,14 @@ public class InputTraceNoFragment extends DataBindingFragment {
|
||||
|
||||
clearInputView();
|
||||
|
||||
TransactionsType currentTransType = sharedViewModel.transactionsType.getValue();
|
||||
if (currentTransType == TransactionsType.VOID
|
||||
|| currentTransType == TransactionsType.TIP_ADJUSTMENT
|
||||
|| currentTransType == TransactionsType.PRE_AUTH_COMPLETE_VOID) {
|
||||
setToolBarTitleWithBackIcon(getResourceString(R.string.title_invoice_number));
|
||||
} else {
|
||||
setToolBarTitleWithBackIcon(getResourceString(R.string.title_trace_number));
|
||||
}
|
||||
|
||||
if (sharedViewModel.isEcr.getValue() != null) {
|
||||
if (sharedViewModel.isEcr.getValue()) {
|
||||
@ -151,10 +158,9 @@ public class InputTraceNoFragment extends DataBindingFragment {
|
||||
configTime = "23:00";
|
||||
}
|
||||
|
||||
LogUtil.d(TAG,"Input trace :"+traceNo);
|
||||
LogUtil.d(TAG,"Input invoice :"+traceNo);
|
||||
|
||||
// voidViewModel.getGenericVoidTransactions(transType,POSUtil.getInstance().formatTrace(traceNo),isEmv).observe(getViewLifecycleOwner(), new Observer<PayDetail>() {
|
||||
voidViewModel.getVoidTrans(transType,POSUtil.getInstance().formatTrace(traceNo)).observe(getViewLifecycleOwner(), new Observer<PayDetail>() {
|
||||
voidViewModel.getVoidTransByInvoice(transType, POSUtil.getInstance().formatTrace(traceNo)).observe(getViewLifecycleOwner(), new Observer<PayDetail>() {
|
||||
@Override
|
||||
public void onChanged(PayDetail payDetail) {
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
|
||||
import com.github.gcacace.signaturepad.views.SignaturePad;
|
||||
import com.utsmm.kbz.util.helper.EReceiptHelper;
|
||||
import com.utsmyanmar.baselib.fragment.DataBindingFragment;
|
||||
import com.utsmyanmar.baselib.network.model.e_receipt.EReceiptCardRequest;
|
||||
import com.utsmyanmar.baselib.util.DataBindingConfig;
|
||||
import com.utsmm.kbz.BR;
|
||||
import com.utsmm.kbz.R;
|
||||
@ -141,14 +142,13 @@ public class SignatureFragment extends DataBindingFragment {
|
||||
payDetail.setESignBlob(blob);
|
||||
sharedViewModel.payDetail.setValue(payDetail);
|
||||
sharedViewModel.updateESignBlob(payDetail.voucherNo, blob);
|
||||
sharedViewModel.pushReceipt(EReceiptHelper.buildEReceiptCardReceipt(
|
||||
EReceiptCardRequest request = EReceiptHelper.buildEReceiptCardReceipt(
|
||||
requireContext(),
|
||||
payDetail,
|
||||
true,
|
||||
BaseErrorCode.getCode(payDetail.getTradeAnswerCode()),
|
||||
blob)
|
||||
);
|
||||
|
||||
null);
|
||||
sharedViewModel.pushReceiptWithImage(request, blob);
|
||||
}
|
||||
|
||||
public class ClickEvent {
|
||||
|
||||
@ -12,6 +12,7 @@ import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.utsmyanmar.baselib.network.model.e_receipt.EReceiptCardRequest;
|
||||
import com.utsmyanmar.baselib.network.model.e_receipt.EReceiptResponse;
|
||||
import com.utsmyanmar.baselib.network.model.sirius.SiriusRequest;
|
||||
import com.utsmyanmar.baselib.network.model.sirius.SiriusResponse;
|
||||
@ -535,6 +536,38 @@ public class SharedViewModel extends ViewModel {
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void pushReceiptWithImage(EReceiptCardRequest request, byte[] imageBytes) {
|
||||
Log.d("push receipt", new Gson().toJson(request));
|
||||
repository.sendReceiptWithImage(request, imageBytes)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
response -> {
|
||||
Log.d("E-Receipt", "Success =>" + response.getMessage());
|
||||
postToastMsg("E-Receipt saved successfully");
|
||||
},
|
||||
error -> {
|
||||
if (error instanceof HttpException) {
|
||||
HttpException httpEx = (HttpException) error;
|
||||
try {
|
||||
String errorJson = httpEx.response().errorBody().string();
|
||||
Log.e("E-Receipt", "Raw error JSON => " + errorJson);
|
||||
EReceiptResponse res = new Gson().fromJson(errorJson, EReceiptResponse.class);
|
||||
Log.e("E-Receipt", "Parsed Error => " + res.getMessage());
|
||||
postToastMsg("E-Receipt could not save!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
postToastMsg("E-Receipt could not save!");
|
||||
}
|
||||
} else {
|
||||
Log.e("E-Receipt", "Unexpected error => " + error.getMessage());
|
||||
postToastMsg("E-Receipt could not save!");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public void printTerminalHostConfigs(){
|
||||
PrintXReceipt.getInstance().printTerminalHostConfig(new PrintXStatus() {
|
||||
|
||||
@ -446,4 +446,46 @@ public class KPayViewModel extends ViewModel {
|
||||
return repository.qrCloseOrder(request);
|
||||
}
|
||||
|
||||
public KPayQRRequest.QRQueryRefundRequest getQueryRefundRequest(String merchOrderId, String mid) {
|
||||
String currentTime = String.valueOf(System.currentTimeMillis());
|
||||
String nonceStr = generateNonceStr();
|
||||
|
||||
Map<String, Object> bizContentMap = new HashMap<>();
|
||||
bizContentMap.put("appid", appId);
|
||||
bizContentMap.put("merch_code", mid);
|
||||
bizContentMap.put("merch_order_id", merchOrderId);
|
||||
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
requestMap.put("timestamp", currentTime);
|
||||
requestMap.put("nonce_str", nonceStr);
|
||||
requestMap.put("method", "kbz.payment.queryrefund");
|
||||
requestMap.put("sign_type", "SHA256");
|
||||
requestMap.put("version", "1.0");
|
||||
requestMap.put("biz_content", bizContentMap);
|
||||
|
||||
String sign = Sign.INSTANCE.generateSign(requestMap, appKey);
|
||||
|
||||
KPayQRRequest.QRQueryRefundRequest.Request.BizContent bizContent =
|
||||
new KPayQRRequest.QRQueryRefundRequest.Request.BizContent(appId, mid, merchOrderId);
|
||||
|
||||
KPayQRRequest.QRQueryRefundRequest.Request requestBody =
|
||||
new KPayQRRequest.QRQueryRefundRequest.Request(
|
||||
currentTime,
|
||||
nonceStr,
|
||||
"kbz.payment.queryrefund",
|
||||
"SHA256",
|
||||
sign,
|
||||
"1.0",
|
||||
bizContent
|
||||
);
|
||||
|
||||
return new KPayQRRequest.QRQueryRefundRequest(requestBody);
|
||||
}
|
||||
|
||||
public Observable<KPayRefund.RefundResponse> checkRefundStatus(KPayQRRequest.QRQueryRefundRequest request) {
|
||||
return repository.checkRefundStatus(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -13,6 +13,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.utsmm.kbz.util.tms.TMSUtil;
|
||||
import com.utsmyanmar.baselib.fragment.DataBindingFragment;
|
||||
import com.utsmyanmar.baselib.network.model.KPayQRRequest;
|
||||
import com.utsmyanmar.baselib.network.model.KPayRefund;
|
||||
//import com.utsmyanmar.baselib.network.model.e_receipt.EReceiptQRRequest;
|
||||
import com.utsmyanmar.baselib.util.DataBindingConfig;
|
||||
@ -56,6 +57,8 @@ public class QRRefundFragment extends DataBindingFragment {
|
||||
private boolean isPartialRefund = false;
|
||||
|
||||
CompositeDisposable refundDisposable = new CompositeDisposable();
|
||||
|
||||
CompositeDisposable refundStatusDisposable = new CompositeDisposable();
|
||||
CompositeDisposable retrieveUpdateDisposable = new CompositeDisposable();
|
||||
|
||||
private static final String TAG = QRRefundFragment.class.getSimpleName();
|
||||
@ -99,6 +102,7 @@ public class QRRefundFragment extends DataBindingFragment {
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
refundDisposable.dispose();
|
||||
refundStatusDisposable.dispose();
|
||||
retrieveUpdateDisposable.dispose();
|
||||
}
|
||||
|
||||
@ -171,7 +175,7 @@ public class QRRefundFragment extends DataBindingFragment {
|
||||
.subscribe(
|
||||
response -> {
|
||||
dismissLoadingDialog();
|
||||
handleRefundResponse(response, referenceNo);
|
||||
handleRefundResponse(response, referenceNo, originalAmount);
|
||||
},
|
||||
throwable -> {
|
||||
dismissLoadingDialog();
|
||||
@ -186,7 +190,39 @@ public class QRRefundFragment extends DataBindingFragment {
|
||||
refundDisposable.add(refundDi);
|
||||
}
|
||||
|
||||
private void handleRefundResponse(KPayRefund.RefundResponse response, String referenceNo) {
|
||||
private void callQueryRefund(String referenceNo, String orgAmount) {
|
||||
String mid = payDetail.getMerchantNo();
|
||||
|
||||
KPayQRRequest.QRQueryRefundRequest request = KPayViewModel.getQueryRefundRequest(referenceNo, mid);
|
||||
showLoadingDialog("Checking refund...");
|
||||
|
||||
refundStatusDisposable.add(KPayViewModel.checkRefundStatus(request)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(response -> {
|
||||
dismissLoadingDialog();
|
||||
|
||||
if (response == null || response.getResponse() == null) {
|
||||
LogUtil.d(TAG, "Query refund: null response");
|
||||
sharedViewModel.payDetail.setValue(payDetail);
|
||||
navigateToNext();
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.d(TAG, "Query refund result: " + response.getResponse().getResult());
|
||||
LogUtil.d(TAG, "Query refund status: " + response.getResponse().getRefundStatus());
|
||||
|
||||
handleRefundResponse(response, referenceNo, orgAmount);
|
||||
|
||||
}, throwable -> {
|
||||
throwable.printStackTrace();
|
||||
dismissLoadingDialog();
|
||||
sharedViewModel.payDetail.setValue(payDetail);
|
||||
navigateToNext();
|
||||
}));
|
||||
}
|
||||
|
||||
private void handleRefundResponse(KPayRefund.RefundResponse response, String referenceNo, String orgAmount) {
|
||||
if (response != null && response.getResponse() != null && "REFUND_SUCCESS".equalsIgnoreCase(response.getResponse().getRefundStatus())) {
|
||||
LogUtil.d(TAG, "Refund successful!");
|
||||
|
||||
@ -203,7 +239,16 @@ public class QRRefundFragment extends DataBindingFragment {
|
||||
|
||||
retrievedUpdatePayDetail(referenceNo);
|
||||
|
||||
} else {
|
||||
} else if (response != null && response.getResponse() != null
|
||||
&& "DUPLICATED_REFUND_REQ_NO".equalsIgnoreCase(response.getResponse().getCode())){
|
||||
LogUtil.d(TAG, "Duplicated refund request, querying actual result...");
|
||||
callQueryRefund(referenceNo , orgAmount);
|
||||
} else if (response != null && response.getResponse() != null
|
||||
&& "REFUNDING".equalsIgnoreCase(response.getResponse().getRefundStatus())){
|
||||
LogUtil.d(TAG, "Refunding refund request, querying actual result...");
|
||||
callQueryRefund(referenceNo , orgAmount);
|
||||
}
|
||||
else {
|
||||
LogUtil.d(TAG, "Refund failed!");
|
||||
payDetail.setQrTransStatus(-1);
|
||||
payDetail.setReferNo(referenceNo);
|
||||
|
||||
@ -309,8 +309,14 @@ public class ReprintAnyTransactionFragment extends DataBindingFragment {
|
||||
if(sharedViewModel.transactionsType.getValue() != null && sharedViewModel.transactionsType.getValue() == TransactionsType.MMQR_HISTORY) {
|
||||
// Wave Inquiry Status::
|
||||
// April 2, 2024 QR Inquiry status check is for unsuccessful transactions.
|
||||
if(yesterday.compareTo(transDate) <= 0 && (pay.getTransactionType() == TransactionsType.MMQR.value || pay.getTransactionType() == TransactionsType.MMQR_REFUND.value) ) {
|
||||
|
||||
// if(yesterday.compareTo(transDate) <= 0 && (pay.getTransactionType() == TransactionsType.MMQR.value || pay.getTransactionType() == TransactionsType.MMQR_REFUND.value) ) {
|
||||
//
|
||||
// filteredLists.add(pay);
|
||||
// }
|
||||
if(yesterday.compareTo(transDate) <= 0
|
||||
&& (pay.getTransactionType() == TransactionsType.MMQR.value
|
||||
|| pay.getTransactionType() == TransactionsType.MMQR_REFUND.value)
|
||||
&& pay.getQrTransStatus() == 1) {
|
||||
filteredLists.add(pay);
|
||||
}
|
||||
|
||||
|
||||
@ -173,7 +173,10 @@ public class QRRefundProcessFragment extends DataBindingFragment {
|
||||
|
||||
retrievedUpdatePayDetail(referenceNo);
|
||||
|
||||
} else {
|
||||
} else if (response != null && response.getResponse() != null && "DUPLICATED_REFUND_REQ_NO".equalsIgnoreCase(response.getResponse().getRefundStatus())) {
|
||||
|
||||
}
|
||||
else {
|
||||
LogUtil.d(TAG, "Refund failed!");
|
||||
payDetail.setQrTransStatus(-1);
|
||||
payDetail.setReferNo(referenceNo);
|
||||
|
||||
@ -39,6 +39,10 @@ public class VoidViewModel extends ViewModel {
|
||||
return repository.getVoidTransaction(transType,voucherNo);
|
||||
}
|
||||
|
||||
public LiveData<PayDetail> getVoidTransByInvoice(int transType, String invoiceNo) {
|
||||
return repository.getVoidTransactionByInvoice(transType, invoiceNo);
|
||||
}
|
||||
|
||||
|
||||
public void observeVoidTrans(int transType) {
|
||||
getVoidTransactions(transType).observeForever(new Observer<List<PayDetail>>() {
|
||||
|
||||
@ -278,7 +278,7 @@ public class SettlementTransactionFragment extends DataBindingFragment implement
|
||||
}
|
||||
});
|
||||
|
||||
settlementViewModel.getDeleteTrans(SystemParamsOperation.getInstance().getCurrentBatchNum()).observe(getViewLifecycleOwner(), new Observer<List<PayDetail>>() {
|
||||
settlementViewModel.getDeleteTrans().observe(getViewLifecycleOwner(), new Observer<List<PayDetail>>() {
|
||||
@Override
|
||||
public void onChanged(List<PayDetail> payDetails) {
|
||||
settlementViewModel.deleteTrans.clear();
|
||||
|
||||
@ -159,8 +159,8 @@ public class SettlementViewModel extends ViewModel {
|
||||
return repository.getSettlementPOS();
|
||||
}
|
||||
|
||||
public LiveData<List<PayDetail>> getDeleteTrans(String batchNo) {
|
||||
return repository.getDeleteTrans(batchNo);
|
||||
public LiveData<List<PayDetail>> getDeleteTrans() {
|
||||
return repository.getDeleteTrans();
|
||||
}
|
||||
|
||||
public LiveData<List<PayDetail>> getAdditionalSettlementPOS() {
|
||||
|
||||
@ -67,7 +67,9 @@ public class EReceiptHelper {
|
||||
request.setDE14(PrintUtils.getInstance().getFormatExpDate(payDetail.getEXPDate()));
|
||||
request.setDE43(formatDE43(cardHolderName));
|
||||
request.setDE48(payDetail.getAID());
|
||||
request.setDE115(signature != null ? Base64.encodeToString(signature, Base64.NO_WRAP) : "");
|
||||
if (signature != null) {
|
||||
request.setDE115(Base64.encodeToString(signature, Base64.NO_WRAP));
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
@ -132,6 +134,6 @@ public class EReceiptHelper {
|
||||
return value.substring(0, 40);
|
||||
}
|
||||
|
||||
return String.format("%-40s", value); // right pad with space
|
||||
return String.format("%-40s", value).trim();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
<domain includeSubdomains="true">api.kbzpay.com</domain>
|
||||
<domain includeSubdomains="true">api-uat.kbzpay.com</domain>
|
||||
<domain includeSubdomains="true">sirius-nest.utsmyanmar.com</domain>
|
||||
<domain includeSubdomains="true">192.168.10.105</domain>
|
||||
</domain-config>
|
||||
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
|
||||
@ -78,10 +78,11 @@ public interface PayDetailDao {
|
||||
LiveData<List<PayDetail>> getSettlementPOSClearBatch();
|
||||
|
||||
// 6 = PRE AUTH CANCEL, 7= PRE_AUTH_COMPLETE , 5 = PRE AUTH
|
||||
// Note: type 20 (MMQR) and type 34 (MMQR_REFUND) are intentionally excluded — QR records are managed separately by QR settlement only
|
||||
// @Query(("SELECT * FROM paydetail WHERE transactionType = 1 AND isCanceled = 1 OR transactionType = 2 AND isCanceled = 0 OR transactionType = 18 AND isCanceled = 0 AND batchNo IN(:batchNo)"))
|
||||
// @Query(("SELECT * FROM paydetail WHERE transactionType = 1 AND isCanceled = 1 OR transactionType = 5 AND isCanceled = 1 OR transactionType = 7 AND isCanceled = 1 OR transactionType = 8 OR transactionType = 6 OR transactionType = 10 OR transactionType = 2 AND isCanceled = 0 OR transactionType = 18 AND isCanceled = 0 OR transactionType = 20 AND isCanceled = 0 OR transactionType = 34 AND isCanceled = 1 AND batchNo IN(:batchNo)"))
|
||||
@Query(("SELECT * FROM paydetail WHERE transactionType = 1 AND isCanceled = 1 OR transactionType = 5 AND isCanceled = 1 OR transactionType = 7 AND isCanceled = 1 OR transactionType = 8 OR transactionType = 6 OR transactionType = 10 OR transactionType = 2 AND isCanceled = 0 OR transactionType = 18 AND isCanceled = 0 OR transactionType = 20 OR transactionType = 34 AND isCanceled = 1 AND batchNo IN(:batchNo)"))
|
||||
LiveData<List<PayDetail>> getDeleteTrans(String batchNo);
|
||||
@Query(("SELECT * FROM paydetail WHERE transactionType = 1 AND isCanceled = 1 OR transactionType = 5 AND isCanceled = 1 OR transactionType = 7 AND isCanceled = 1 OR transactionType = 8 OR transactionType = 6 OR transactionType = 10 OR transactionType = 2 AND isCanceled = 0 OR transactionType = 18 AND isCanceled = 0"))
|
||||
LiveData<List<PayDetail>> getDeleteTrans();
|
||||
|
||||
@Query("SELECT * FROM paydetail WHERE transactionType = 5 AND isCanceled = 0")
|
||||
LiveData<List<PayDetail>> getPreAuthTrans();
|
||||
@ -120,6 +121,9 @@ public interface PayDetailDao {
|
||||
@Query("SELECT * FROM paydetail WHERE isSettle = 0 AND transactionType IN(:transType) AND voucherNo IN(:voucherNo)")
|
||||
LiveData<PayDetail> getVoidTrans(int transType,String voucherNo);
|
||||
|
||||
@Query("SELECT * FROM paydetail WHERE isSettle = 0 AND transactionType IN(:transType) AND invoiceNo IN(:invoiceNo)")
|
||||
LiveData<PayDetail> getVoidTransByInvoice(int transType, String invoiceNo);
|
||||
|
||||
// 5 = PRE_SALE
|
||||
|
||||
@Query("SELECT * FROM paydetail WHERE isCanceled = 0 AND transactionType = 5 AND voucherNo IN(:voucherNo) AND accountType != 'MPU'")
|
||||
|
||||
@ -415,7 +415,9 @@ public Retrofit provideKPayRefundRetrofit(@ApplicationContext Context context) {
|
||||
@Singleton
|
||||
public EReceiptApiService provideEReceiptApiService(){
|
||||
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(
|
||||
message -> LogUtil.d("HTTP", message)
|
||||
);
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
package com.utsmyanmar.baselib.network;
|
||||
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.utsmyanmar.baselib.network.model.e_receipt.EReceiptResponse;
|
||||
|
||||
import java.util.Map;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.PartMap;
|
||||
|
||||
public interface EReceiptApiService {
|
||||
|
||||
@ -17,4 +20,13 @@ public interface EReceiptApiService {
|
||||
@Header("x-api-key") String apiKey,
|
||||
@Body Object body
|
||||
);
|
||||
|
||||
@Multipart
|
||||
@POST("transaction")
|
||||
Observable<EReceiptResponse> sendReceiptMultipart(
|
||||
@Header("x-timestamp") String timestamp,
|
||||
@Header("x-api-key") String apiKey,
|
||||
@PartMap Map<String, RequestBody> fields,
|
||||
@Part MultipartBody.Part de115Image
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.utsmyanmar.baselib.network;
|
||||
import com.utsmyanmar.baselib.network.model.KPayQRQueryRequest;
|
||||
import com.utsmyanmar.baselib.network.model.KPayQRRequest;
|
||||
import com.utsmyanmar.baselib.network.model.KPayQRResponse;
|
||||
import com.utsmyanmar.baselib.network.model.KPayRefund;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Body;
|
||||
@ -27,4 +28,6 @@ public interface KPayApiService {
|
||||
@POST("closeorder")
|
||||
Observable<KPayQRRequest.CloseOrderResponse> closeOrder(@Body KPayQRRequest.CloseOrderRequest closeOrderRequest);
|
||||
|
||||
@POST("queryrefund")
|
||||
Observable<KPayRefund.RefundResponse> checkRefundStatus(@Body KPayQRRequest.QRQueryRefundRequest request);
|
||||
}
|
||||
|
||||
@ -575,4 +575,82 @@ public class KPayQRRequest {
|
||||
}
|
||||
}
|
||||
|
||||
public static class QRQueryRefundRequest {
|
||||
|
||||
@SerializedName("Request")
|
||||
private Request request;
|
||||
|
||||
public QRQueryRefundRequest() {}
|
||||
|
||||
public QRQueryRefundRequest(Request request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public Request getRequest() { return request; }
|
||||
public void setRequest(Request request) { this.request = request; }
|
||||
|
||||
public static class Request {
|
||||
@SerializedName("timestamp")
|
||||
private String timestamp;
|
||||
|
||||
@SerializedName("nonce_str")
|
||||
private String nonceStr;
|
||||
|
||||
@SerializedName("method")
|
||||
private String method;
|
||||
|
||||
@SerializedName("sign_type")
|
||||
private String signType;
|
||||
|
||||
@SerializedName("sign")
|
||||
private String sign;
|
||||
|
||||
@SerializedName("version")
|
||||
private String version;
|
||||
|
||||
@SerializedName("biz_content")
|
||||
private BizContent bizContent;
|
||||
|
||||
public Request(String timestamp, String nonceStr, String method,
|
||||
String signType, String sign, String version, BizContent bizContent) {
|
||||
this.timestamp = timestamp;
|
||||
this.nonceStr = nonceStr;
|
||||
this.method = method;
|
||||
this.signType = signType;
|
||||
this.sign = sign;
|
||||
this.version = version;
|
||||
this.bizContent = bizContent;
|
||||
}
|
||||
|
||||
public String getTimestamp() { return timestamp; }
|
||||
public String getNonceStr() { return nonceStr; }
|
||||
public String getMethod() { return method; }
|
||||
public String getSignType() { return signType; }
|
||||
public String getSign() { return sign; }
|
||||
public String getVersion() { return version; }
|
||||
public BizContent getBizContent() { return bizContent; }
|
||||
|
||||
public static class BizContent {
|
||||
@SerializedName("appid")
|
||||
private String appId;
|
||||
|
||||
@SerializedName("merch_code")
|
||||
private String merchCode;
|
||||
|
||||
@SerializedName("merch_order_id")
|
||||
private String merchOrderId;
|
||||
|
||||
public BizContent(String appId, String merchCode, String merchOrderId) {
|
||||
this.appId = appId;
|
||||
this.merchCode = merchCode;
|
||||
this.merchOrderId = merchOrderId;
|
||||
}
|
||||
|
||||
public String getAppId() { return appId; }
|
||||
public String getMerchCode() { return merchCode; }
|
||||
public String getMerchOrderId() { return merchOrderId; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -165,6 +165,7 @@ public class EReceiptCardRequest {
|
||||
public void setDE43(String DE43){
|
||||
this.DE43 = DE43;
|
||||
}
|
||||
public String getDE48(){ return DE48; }
|
||||
public void setDE48(String DE48){
|
||||
this.DE48 = DE48;
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import com.utsmyanmar.baselib.network.KPayApiService;
|
||||
import com.utsmyanmar.baselib.network.KPayRefundApiService;
|
||||
import com.utsmyanmar.baselib.network.SiriusApiService;
|
||||
import com.utsmyanmar.baselib.network.model.DemoQRRequest;
|
||||
import com.utsmyanmar.baselib.network.model.e_receipt.EReceiptCardRequest;
|
||||
import com.utsmyanmar.baselib.network.model.DemoQRResponse;
|
||||
import com.utsmyanmar.baselib.network.model.DemoQRReturnRequest;
|
||||
import com.utsmyanmar.baselib.network.model.DemoQRReturnResponse;
|
||||
@ -42,12 +43,17 @@ import com.utsmyanmar.baselib.util.EReceiptHelper;
|
||||
import com.utsmyanmar.paylibs.model.PayDetail;
|
||||
import com.utsmyanmar.paylibs.utils.LogUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
@ -128,6 +134,58 @@ public class Repository {
|
||||
return eReceiptApiService.sendReceipt(timestamp, signature, body);
|
||||
}
|
||||
|
||||
public Observable<EReceiptResponse> sendReceiptWithImage(EReceiptCardRequest request, byte[] imageBytes) {
|
||||
String apiSecret = BuildConfig.ERECEIPT_SECRET;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
request.setDE115(null);
|
||||
String bodyString = new Gson().toJson(request);
|
||||
String dataToHash = bodyString + apiSecret + timestamp;
|
||||
LogUtil.d("HTTP", dataToHash);
|
||||
String apiKey = EReceiptHelper.sha256(dataToHash);
|
||||
|
||||
Map<String, RequestBody> fields = buildFormFields(request);
|
||||
MultipartBody.Part imagePart = null;
|
||||
if (imageBytes != null) {
|
||||
RequestBody imageBody = RequestBody.create(MediaType.parse("image/png"), imageBytes);
|
||||
imagePart = MultipartBody.Part.createFormData("DE115", "signature.png", imageBody);
|
||||
}
|
||||
|
||||
return eReceiptApiService.sendReceiptMultipart(timestamp, apiKey, fields, imagePart);
|
||||
}
|
||||
|
||||
private Map<String, RequestBody> buildFormFields(EReceiptCardRequest request) {
|
||||
Map<String, RequestBody> map = new HashMap<>();
|
||||
putField(map, "DE2", request.getDE2());
|
||||
putField(map, "DE3", request.getDE3());
|
||||
putField(map, "DE4", request.getDE4());
|
||||
putField(map, "DE7", request.getDE7());
|
||||
putField(map, "DE11", request.getDE11());
|
||||
putField(map, "DE14", request.getDE14());
|
||||
putField(map, "DE22", request.getDE22());
|
||||
putField(map, "DE37", request.getDE37());
|
||||
putField(map, "DE38", request.getDE38());
|
||||
putField(map, "DE39", request.getDE39());
|
||||
putField(map, "DE41", request.getDE41());
|
||||
putField(map, "DE42", request.getDE42());
|
||||
putField(map, "DE43", request.getDE43());
|
||||
putField(map, "DE48", request.getDE48());
|
||||
putField(map, "DE49", request.getDE49());
|
||||
putField(map, "DE55", request.getDE55());
|
||||
putField(map, "appId", request.getAppId());
|
||||
putField(map, "batchNumber", request.getBatchNumber());
|
||||
putField(map, "cardLabel", request.getCardLabel());
|
||||
putField(map, "description", request.getDescription());
|
||||
putField(map, "invoiceNumber", request.getInvoiceNumber());
|
||||
putField(map, "serial", request.getSerial());
|
||||
return map;
|
||||
}
|
||||
|
||||
private void putField(Map<String, RequestBody> map, String key, String value) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
map.put(key, RequestBody.create(MediaType.parse("text/plain"), value));
|
||||
}
|
||||
}
|
||||
|
||||
public void insertPayDetail(PayDetail payDetail){ payDetailDao.insert(payDetail);}
|
||||
|
||||
public Completable insertPay(PayDetail payDetail) { return payDetailDao.insertPay(payDetail); }
|
||||
@ -185,7 +243,10 @@ public class Repository {
|
||||
|
||||
public LiveData<PayDetail> getVoidTransaction(int transType,String voucherNo) {
|
||||
return payDetailDao.getVoidTrans(transType,voucherNo);
|
||||
}
|
||||
|
||||
public LiveData<PayDetail> getVoidTransactionByInvoice(int transType, String invoiceNo) {
|
||||
return payDetailDao.getVoidTransByInvoice(transType, invoiceNo);
|
||||
}
|
||||
|
||||
|
||||
@ -246,8 +307,8 @@ public class Repository {
|
||||
return payDetailDao.getSettlementPOSClearBatch();
|
||||
}
|
||||
|
||||
public LiveData<List<PayDetail>> getDeleteTrans(String batchNo) {
|
||||
return payDetailDao.getDeleteTrans(batchNo);
|
||||
public LiveData<List<PayDetail>> getDeleteTrans() {
|
||||
return payDetailDao.getDeleteTrans();
|
||||
}
|
||||
|
||||
public LiveData<List<PayDetail>> getPreAuthTrans() {
|
||||
@ -267,4 +328,8 @@ public class Repository {
|
||||
public LiveData<List<PayDetail>> getAllQRHistory(){ return payDetailDao.getAllQRHistory();}
|
||||
|
||||
public LiveData<List<PayDetail>> getRefundableQRHistory(){ return payDetailDao.getRefundableQRHistory(); }
|
||||
|
||||
public Observable<KPayRefund.RefundResponse> checkRefundStatus(KPayQRRequest.QRQueryRefundRequest request) {
|
||||
return kPayApiService.checkRefundStatus(request);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user