signature send to backend
This commit is contained in:
parent
ed304217ec
commit
b8bfd5d1a7
@ -162,6 +162,7 @@ public class MainActivity extends AppCompatActivity implements
|
||||
// SystemParamsOperation.getInstance().setEReceiptAddress("https://api-tms-uat.kbzbank.com:8443/receipt");
|
||||
SystemParamsOperation.getInstance().setTmsAddress("https://sirius-nest.utsmyanmar.com/api/v1");
|
||||
SystemParamsOperation.getInstance().setEReceiptAddress("https://receipt-nest.utsmyanmar.com");
|
||||
// SystemParamsOperation.getInstance().setEReceiptAddress("https://receipt-nest.utsmyanmar.com");
|
||||
|
||||
PinPad pinPad = MyApplication.getInstance().deviceEngine.getPinPad();
|
||||
byte[] encryptedPIK = SystemParamsOperation.getInstance().getPIK();
|
||||
|
||||
@ -345,14 +345,14 @@ public class ProcessingFragment extends DataBindingFragment {
|
||||
handleAfterTransaction();
|
||||
break;
|
||||
case SUCCESS:
|
||||
sharedViewModel.pushReceipt(buildEReceiptCardReceipt(payDetail, true, BaseErrorCode.getCode(payDetail.getTradeAnswerCode())));
|
||||
handleAfterTransaction();
|
||||
// if(requiresSignature()){
|
||||
// handleAfterTransaction();
|
||||
// }else{
|
||||
// sharedViewModel.pushReceipt(buildEReceiptCardReceipt(payDetail, true, BaseErrorCode.getCode(payDetail.getTradeAnswerCode())));
|
||||
// handleAfterTransaction();
|
||||
// }
|
||||
if(requiresSignature()){
|
||||
handleAfterTransaction();
|
||||
}else{
|
||||
sharedViewModel.pushReceipt(buildEReceiptCardReceipt(payDetail, true, BaseErrorCode.getCode(payDetail.getTradeAnswerCode())));
|
||||
handleAfterTransaction();
|
||||
}
|
||||
break;
|
||||
case OFFLINE_SUCCESS:
|
||||
if(SystemParamsOperation.getInstance().getDemoStatus()) {
|
||||
|
||||
@ -142,13 +142,13 @@ public class SignatureFragment extends DataBindingFragment {
|
||||
payDetail.setESignBlob(blob);
|
||||
sharedViewModel.payDetail.setValue(payDetail);
|
||||
sharedViewModel.updateESignBlob(payDetail.voucherNo, blob);
|
||||
// EReceiptCardRequest request = EReceiptHelper.buildEReceiptCardReceipt(
|
||||
// requireContext(),
|
||||
// payDetail,
|
||||
// true,
|
||||
// BaseErrorCode.getCode(payDetail.getTradeAnswerCode()),
|
||||
// null);
|
||||
// sharedViewModel.pushReceiptWithImage(request, blob);
|
||||
EReceiptCardRequest request = EReceiptHelper.buildEReceiptCardReceipt(
|
||||
requireContext(),
|
||||
payDetail,
|
||||
true,
|
||||
BaseErrorCode.getCode(payDetail.getTradeAnswerCode()),
|
||||
null);
|
||||
sharedViewModel.pushReceiptWithImage(request, blob);
|
||||
}
|
||||
|
||||
public class ClickEvent {
|
||||
|
||||
@ -7,6 +7,7 @@ import android.util.Log;
|
||||
import android.widget.ListView;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
@ -196,12 +197,13 @@ public class SharedViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setEmvTrans(boolean status) {
|
||||
isEmv.setValue(status);
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> isEmvTrans() { return isEmv;}
|
||||
public SingleLiveEvent<Boolean> isEmvTrans() {
|
||||
return isEmv;
|
||||
}
|
||||
|
||||
private PayDetail getPayDetail() {
|
||||
return mPayDetail;
|
||||
@ -231,8 +233,14 @@ public class SharedViewModel extends ViewModel {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setPrintReceiptMsg(String msg) { this.printReceiptMsg.setValue(msg);}
|
||||
public void postPrintReceiptMsg(String msg) { this.printReceiptMsg.postValue(msg);}
|
||||
public void setPrintReceiptMsg(String msg) {
|
||||
this.printReceiptMsg.setValue(msg);
|
||||
}
|
||||
|
||||
public void postPrintReceiptMsg(String msg) {
|
||||
this.printReceiptMsg.postValue(msg);
|
||||
}
|
||||
|
||||
public void setPrintStatus(PrintStatus printStatus) {
|
||||
// this.printStatus.postValue(printStatus);
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
@ -242,36 +250,67 @@ public class SharedViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
}
|
||||
public void postPrintStatus(PrintStatus printStatus) { this.printStatus.postValue(printStatus); }
|
||||
|
||||
public SingleLiveEvent<PrintStatus> getPrintStatus() { return this.printStatus; }
|
||||
public void postPrintStatus(PrintStatus printStatus) {
|
||||
this.printStatus.postValue(printStatus);
|
||||
}
|
||||
|
||||
public void setIsFallback(boolean status) { isFallback.setValue(status);}
|
||||
public SingleLiveEvent<PrintStatus> getPrintStatus() {
|
||||
return this.printStatus;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getIsFallback() { return isFallback;}
|
||||
public void setIsFallback(boolean status) {
|
||||
isFallback.setValue(status);
|
||||
}
|
||||
|
||||
public void setIsCardAppBlock(boolean status) { isCardAppBlock.setValue(status);}
|
||||
public SingleLiveEvent<Boolean> getIsFallback() {
|
||||
return isFallback;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getIsCardAppBlock() {return isCardAppBlock;}
|
||||
public void setIsCardAppBlock(boolean status) {
|
||||
isCardAppBlock.setValue(status);
|
||||
}
|
||||
|
||||
public void setIsSeePhone(boolean status) { isSeePhone.setValue(status);}
|
||||
public SingleLiveEvent<Boolean> getIsCardAppBlock() {
|
||||
return isCardAppBlock;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getIsSeePhone() { return isSeePhone;}
|
||||
public void setIsSeePhone(boolean status) {
|
||||
isSeePhone.setValue(status);
|
||||
}
|
||||
|
||||
public void setIsContactlessRestricted(boolean status) { isContactlessRestricted.setValue(status);}
|
||||
public SingleLiveEvent<Boolean> getIsSeePhone() {
|
||||
return isSeePhone;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getIsContactlessRestricted() {return isContactlessRestricted;}
|
||||
public void setIsContactlessRestricted(boolean status) {
|
||||
isContactlessRestricted.setValue(status);
|
||||
}
|
||||
|
||||
public void setCardDataExist(boolean exist) { _isCardDataExist.setValue(exist);}
|
||||
public SingleLiveEvent<Boolean> getIsContactlessRestricted() {
|
||||
return isContactlessRestricted;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getCardDataExist() { return _isCardDataExist; }
|
||||
public void setCardDataExist(boolean exist) {
|
||||
_isCardDataExist.setValue(exist);
|
||||
}
|
||||
|
||||
public void setAmountExist(boolean exist) { _isAmountExist.setValue(exist);}
|
||||
public SingleLiveEvent<Boolean> getCardDataExist() {
|
||||
return _isCardDataExist;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getAmountExist() { return _isAmountExist; }
|
||||
public void setAmountExist(boolean exist) {
|
||||
_isAmountExist.setValue(exist);
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> getAmountExist() {
|
||||
return _isAmountExist;
|
||||
}
|
||||
|
||||
|
||||
public MutableLiveData<Boolean> getManualEntryStatus() { return _manualEntryStatus;}
|
||||
public MutableLiveData<Boolean> getManualEntryStatus() {
|
||||
return _manualEntryStatus;
|
||||
}
|
||||
|
||||
public void setManualEntryStatus(boolean status) {
|
||||
_manualEntryStatus.setValue(status);
|
||||
@ -289,11 +328,18 @@ public class SharedViewModel extends ViewModel {
|
||||
return _successFragmentMsg;
|
||||
}
|
||||
|
||||
public void set_currencyText(String msg) { this._currencyText.setValue(msg);}
|
||||
public void set_currencyText(String msg) {
|
||||
this._currencyText.setValue(msg);
|
||||
}
|
||||
|
||||
public SingleLiveEvent<String> get_currencyText() { return _currencyText; }
|
||||
public SingleLiveEvent<String> get_currencyText() {
|
||||
return _currencyText;
|
||||
}
|
||||
|
||||
public void set_successFragmentMsg(String msg) {
|
||||
this._successFragmentMsg.setValue(msg);
|
||||
}
|
||||
|
||||
public void set_successFragmentMsg(String msg) { this._successFragmentMsg.setValue(msg);}
|
||||
public SingleLiveEvent<TransMenu> getTransMenu() {
|
||||
return _transMenu;
|
||||
}
|
||||
@ -356,8 +402,6 @@ public class SharedViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void startPrintReceipt(boolean isFirstPrint) {
|
||||
/*
|
||||
* First Print is Merchant Copy..
|
||||
@ -412,7 +456,6 @@ public class SharedViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void startPrintProcess() {
|
||||
LogUtil.d(TAG, "Print status :" + getPrintStatus().getValue());
|
||||
@ -457,7 +500,6 @@ public class SharedViewModel extends ViewModel {
|
||||
private void startPrintProcessQRSettlement(PrintXStatus printXStatus) {
|
||||
|
||||
|
||||
|
||||
if (payDetail.getValue() == null && payDetails.getValue() == null) return;
|
||||
|
||||
PrintXReceipt.getInstance().printQRSettlementReport(payDetail.getValue(), QRSettleData.convertFromPayDetail(payDetails.getValue()), printXStatus);
|
||||
@ -469,7 +511,6 @@ public class SharedViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public LiveData<PayDetail> getReversalTransaction(String voucherNo) {
|
||||
return repository.getReversalTransaction(voucherNo);
|
||||
}
|
||||
@ -490,7 +531,9 @@ public class SharedViewModel extends ViewModel {
|
||||
repository.updateESignBlob(voucherNo, blob);
|
||||
}
|
||||
|
||||
public void insertPayDetail(PayDetail payDetail) { repository.insertPayDetail(payDetail); }
|
||||
public void insertPayDetail(PayDetail payDetail) {
|
||||
repository.insertPayDetail(payDetail);
|
||||
}
|
||||
|
||||
|
||||
public void enableCardStatusIcon(boolean tapCard, boolean tapDevice, boolean insertCard, boolean swipeCard) {
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<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 includeSubdomains="true">192.168.10.104</domain>
|
||||
</domain-config>
|
||||
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
|
||||
@ -44,8 +44,10 @@ import com.utsmyanmar.paylibs.model.PayDetail;
|
||||
import com.utsmyanmar.paylibs.utils.LogUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
@ -137,10 +139,9 @@ public class Repository {
|
||||
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 bodyString = buildMultipartSignaturePayload(request);
|
||||
String dataToHash = bodyString + apiSecret + timestamp;
|
||||
LogUtil.d("HTTP", dataToHash);
|
||||
// LogUtil.d("HTTP", dataToHash);
|
||||
String apiKey = EReceiptHelper.sha256(dataToHash);
|
||||
|
||||
Map<String, RequestBody> fields = buildFormFields(request);
|
||||
@ -153,6 +154,40 @@ public class Repository {
|
||||
return eReceiptApiService.sendReceiptMultipart(timestamp, apiKey, fields, imagePart);
|
||||
}
|
||||
|
||||
private String buildMultipartSignaturePayload(EReceiptCardRequest request) {
|
||||
Map<String, String> flatBody = new LinkedHashMap<>();
|
||||
putIfNotEmpty(flatBody, "DE2", request.getDE2());
|
||||
putIfNotEmpty(flatBody, "DE3", request.getDE3());
|
||||
putIfNotEmpty(flatBody, "DE4", request.getDE4());
|
||||
putIfNotEmpty(flatBody, "DE7", request.getDE7());
|
||||
putIfNotEmpty(flatBody, "DE11", request.getDE11());
|
||||
putIfNotEmpty(flatBody, "DE14", request.getDE14());
|
||||
putIfNotEmpty(flatBody, "DE22", request.getDE22());
|
||||
putIfNotEmpty(flatBody, "DE37", request.getDE37());
|
||||
putIfNotEmpty(flatBody, "DE38", request.getDE38());
|
||||
putIfNotEmpty(flatBody, "DE39", request.getDE39());
|
||||
putIfNotEmpty(flatBody, "DE41", request.getDE41());
|
||||
putIfNotEmpty(flatBody, "DE42", request.getDE42());
|
||||
putIfNotEmpty(flatBody, "DE43", request.getDE43());
|
||||
putIfNotEmpty(flatBody, "DE48", request.getDE48());
|
||||
putIfNotEmpty(flatBody, "DE49", request.getDE49());
|
||||
putIfNotEmpty(flatBody, "DE55", request.getDE55());
|
||||
putIfNotEmpty(flatBody, "appId", request.getAppId());
|
||||
putIfNotEmpty(flatBody, "batchNumber", request.getBatchNumber());
|
||||
putIfNotEmpty(flatBody, "cardLabel", request.getCardLabel());
|
||||
putIfNotEmpty(flatBody, "description", request.getDescription());
|
||||
putIfNotEmpty(flatBody, "invoiceNumber", request.getInvoiceNumber());
|
||||
putIfNotEmpty(flatBody, "serial", request.getSerial());
|
||||
|
||||
return new Gson().toJson(new TreeMap<>(flatBody));
|
||||
}
|
||||
|
||||
private void putIfNotEmpty(Map<String, String> map, String key, String value) {
|
||||
if (value != null && !value.trim().isEmpty()) {
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, RequestBody> buildFormFields(EReceiptCardRequest request) {
|
||||
Map<String, RequestBody> map = new HashMap<>();
|
||||
putField(map, "DE2", request.getDE2());
|
||||
|
||||
@ -46,6 +46,7 @@ public class SystemParamsSettings implements Serializable {
|
||||
// private String ereceiptAddress = "https://api-tms-uat.kbzbank.com:8443/receipt";
|
||||
private String tmsAddress = "https://sirius-nest.utsmyanmar.com/api/v1";
|
||||
private String ereceiptAddress = "https://receipt-nest.utsmyanmar.com";
|
||||
// private String ereceiptAddress = "http://192.168.10.104:3003";
|
||||
|
||||
private String binValues = "";
|
||||
private String restrictedBinValues = "";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user