|
|
@ -53,10 +53,8 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
|
|
|
|
private final ReceiverInfoV3Model selectedRecipient; |
|
|
|
private final CompositeDisposable compositeObservable; |
|
|
|
private final AutoDebitAccount selectedPaymentType; |
|
|
|
private final SendMoneyV2ContractInterface view; |
|
|
|
private final SendMoneyV2GatewayInterface gateway; |
|
|
|
private final CouponV2InteractorInterface.CouponV2GatewayInterface couponGateway; |
|
|
|
|
|
|
|
|
|
|
|
//Exrate data |
|
|
@ -71,57 +69,30 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
|
|
|
|
private MutableLiveData<AmountDetailRelatedDataModel> amountDetailRelatedDataModelLiveData; |
|
|
|
private MutableLiveData<ExchangeCalculationModel> exchangeCalculationModelMutableLiveData; |
|
|
|
private MutableLiveData<Integer> exchangeRateCouponResetActionLiveData; |
|
|
|
private MutableLiveData<Boolean> exchangeRateCouponViewRequiredLiveData; |
|
|
|
private MutableLiveData<AmountDetailSendMoneyFragment.CouponDetailViewDTO> couponSelectionLiveData; |
|
|
|
|
|
|
|
|
|
|
|
private long countDownRemainingValue; |
|
|
|
private ArrayList<CouponDTO> couponList; |
|
|
|
private ExchangeCalculationModel currentExchangeCalcResult; |
|
|
|
private CouponDTO selectedCoupon; |
|
|
|
|
|
|
|
|
|
|
|
public SendMoneyV2Presenter(SendMoneyV2ContractInterface view, SendMoneyV2GatewayInterface gateway, SendMoneyRequiredDataV3 sendMoneyRequiredData, CouponV2InteractorInterface.CouponV2GatewayInterface couponV2Gateway) { |
|
|
|
public SendMoneyV2Presenter(SendMoneyV2ContractInterface view, SendMoneyV2GatewayInterface gateway, SendMoneyRequiredDataV3 sendMoneyRequiredData) { |
|
|
|
this.view = view; |
|
|
|
this.selectedRecipient = sendMoneyRequiredData.getRecipientInfoModel(); |
|
|
|
this.selectedPaymentType = sendMoneyRequiredData.getSelectedAutoDebitAccount(); |
|
|
|
this.gateway = gateway; |
|
|
|
this.couponGateway = couponV2Gateway; |
|
|
|
this.compositeObservable = new CompositeDisposable(); |
|
|
|
countDownRemainingValue = -1; |
|
|
|
amountDetailRelatedDataModelLiveData = null; |
|
|
|
exchangeCalculationModelMutableLiveData = null; |
|
|
|
exchangeRateCouponResetActionLiveData = new MutableLiveData<>(); |
|
|
|
exchangeRateCouponViewRequiredLiveData = new MutableLiveData<>(); |
|
|
|
|
|
|
|
couponSelectionLiveData = new MutableLiveData<>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void clearPaymentData() { |
|
|
|
// this.selectedPaymentModeData = null; |
|
|
|
// this.selectedAccountNo = null; |
|
|
|
// this.selectedBranchData = null; |
|
|
|
// this.selectedBankData = null; |
|
|
|
// this.isAccountValidationRequired = false; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String returnNullOnValidaitonAndSetPaymentModeData(PayoutMode selectedPayoutMode, BankList selectedBank, BankBranchDTO selectedBranch, String accNo) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String getPaymentModeTitle() { |
|
|
|
String selectedLocale = this.gateway.getPreferredLanguage(); |
|
|
|
if (selectedLocale.equalsIgnoreCase("ne") || selectedLocale.equalsIgnoreCase("mn")) |
|
|
|
return this.selectedRecipient.getCountry() + " " + getStringfromStringId(R.string.pick_money_text) + "?"; |
|
|
|
else if (selectedLocale.equalsIgnoreCase("ko")) |
|
|
|
return getStringfromStringId(R.string.pick_money_text) + " " + this.selectedRecipient.getCountry(); |
|
|
|
else |
|
|
|
return getStringfromStringId(R.string.pick_money_text) + " " + this.selectedRecipient.getCountry() + "?"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Observable<BranchListApiResponse> getBranchListFromNetwork(BankList selectedBank, String searchKeyword) { |
|
|
@ -179,14 +150,7 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
this.selectedTransferAmount = transferAmount; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void clearExRateData() { |
|
|
|
selectedSendingAmount = null; |
|
|
|
selectedExRate = null; |
|
|
|
selectedSendingCurrency = null; |
|
|
|
selectedRecievingAmount = null; |
|
|
|
selectedTransferAmount = null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void promptPinAndPerformTransaction() { |
|
|
@ -196,7 +160,7 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
getPaymentType(), |
|
|
|
getTransactionAmount(), |
|
|
|
getKftcId() |
|
|
|
).enableFallbackAuth().withCountdownTimer(countDownRemainingValue) |
|
|
|
).enableFallbackAuth() |
|
|
|
).setListener(new GMEAuthManager.GMEAuthListener() { |
|
|
|
@Override |
|
|
|
public void onGMEAuthSuccess(GMEAuthSuccessResult result) { |
|
|
@ -230,20 +194,15 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
|
|
|
|
@Override |
|
|
|
public String getPaymentType() { |
|
|
|
if (selectedPaymentType != null && selectedPaymentType.getType() != null) |
|
|
|
return selectedPaymentType.getType(); |
|
|
|
else |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateRemainingCountDownValue(long value) { |
|
|
|
this.countDownRemainingValue = value; |
|
|
|
return "wallet"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public String getKftcId() { |
|
|
|
return selectedPaymentType.getKftcAccountId(); |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -251,28 +210,11 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
return Utils.removeSpecialCharacterAndDecimalFromCurrency(selectedSendingAmount); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void getCouponRelatedData() { |
|
|
|
compositeObservable.add( |
|
|
|
this.couponGateway.getCouponList(this.couponGateway.getAuth(), this.couponGateway.getUserIDNumber()) |
|
|
|
.doOnSubscribe(subs -> view.showProgressBar(true, "")) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
.subscribeWith(new CouponListObserver()) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ArrayList<CouponDTO> getCouponList() { |
|
|
|
return this.couponList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onCouponSelected(CouponDTO selectedCoupon) { |
|
|
|
this.selectedCoupon = selectedCoupon; |
|
|
|
couponSelectionLiveData.setValue(calculateNetAppliedAmount()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void preSelectDefaultCouponIfAvailable() { |
|
|
|
if (couponList == null || couponList.size() == 1) |
|
|
@ -281,73 +223,18 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
try { |
|
|
|
List<CouponDTO> sortedCouponList = couponList.subList(1, couponList.size()); |
|
|
|
Collections.sort(sortedCouponList); |
|
|
|
onCouponSelected(sortedCouponList.get(0)); |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private AmountDetailSendMoneyFragment.CouponDetailViewDTO calculateNetAppliedAmount() { |
|
|
|
if (selectedCoupon == null) { |
|
|
|
resetCouponData(); |
|
|
|
return null; |
|
|
|
} |
|
|
|
String couponName; |
|
|
|
|
|
|
|
double serviceFee = 0; |
|
|
|
double discountValue = 0; |
|
|
|
|
|
|
|
serviceFee = Utils.formatCurrencyForComparision(currentExchangeCalcResult.getScCharge()); |
|
|
|
discountValue = Utils.formatCurrencyForComparision(selectedCoupon.getDiscountValue()); |
|
|
|
|
|
|
|
//1 -> Percent Type ; 2 -> Value type |
|
|
|
if ("1".equalsIgnoreCase(selectedCoupon.getDiscountType())) { |
|
|
|
discountValue = serviceFee * (discountValue / 100); |
|
|
|
couponName = "Service Discount " + (selectedCoupon.getDiscountValue() != null ? selectedCoupon.getDiscountValue() : 0) + "%"; |
|
|
|
} else { |
|
|
|
couponName = "Service Discount " + (selectedCoupon.getDiscountValue() != null ? Utils.formatCurrency(selectedCoupon.getDiscountValue()) : 0) + " KRW"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String netAppliedAmount = Utils.formatCurrency(String.valueOf(Utils.formatCurrencyForComparision(currentExchangeCalcResult.getCollAmt()) - discountValue)); |
|
|
|
|
|
|
|
|
|
|
|
return new AmountDetailSendMoneyFragment.CouponDetailViewDTO(couponName, netAppliedAmount); |
|
|
|
} |
|
|
|
|
|
|
|
private String calculatedDiscountedServiceFee() { |
|
|
|
return selectedTransferFee; |
|
|
|
|
|
|
|
if (selectedCoupon == null) |
|
|
|
return selectedTransferFee; |
|
|
|
else { |
|
|
|
double serviceFee = 0; |
|
|
|
double discountValue = 0; |
|
|
|
|
|
|
|
serviceFee = Utils.formatCurrencyForComparision(currentExchangeCalcResult.getScCharge()); |
|
|
|
discountValue = Utils.formatCurrencyForComparision(selectedCoupon.getDiscountValue()); |
|
|
|
|
|
|
|
if ("1".equalsIgnoreCase(selectedCoupon.getDiscountType())) { |
|
|
|
return String.valueOf(serviceFee - (serviceFee * (discountValue / 100))); |
|
|
|
} else { |
|
|
|
return String.valueOf(serviceFee - discountValue); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getSelectedCouponIndex() { |
|
|
|
if (couponList != null && selectedCoupon != null) { |
|
|
|
String selectedCouponSchemeId = selectedCoupon.getSchemeId(); |
|
|
|
for (int i = 1; i < couponList.size(); i++) { |
|
|
|
if (couponList.get(i).getSchemeId().equalsIgnoreCase(selectedCouponSchemeId)) |
|
|
|
return i; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void performSendMoneyTransaction(String password, boolean isBiometricUsed) { |
|
|
@ -380,7 +267,7 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
sendMoneyAPIRequestBody.setPayOutPartner(selectedRecipient.getPayoutPartner()); |
|
|
|
|
|
|
|
|
|
|
|
sendMoneyAPIRequestBody.setPaymentType(selectedPaymentType.getType()); |
|
|
|
sendMoneyAPIRequestBody.setPaymentType("wallet"); |
|
|
|
|
|
|
|
|
|
|
|
sendMoneyAPIRequestBody.setpCurr(selectedSendingCurrency); |
|
|
@ -406,12 +293,12 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
sendMoneyAPIRequestBody.setIsAgreed(Constants.TRUE_STRING); |
|
|
|
|
|
|
|
//KFTC Related Params |
|
|
|
sendMoneyAPIRequestBody.setKftcAccountId(selectedPaymentType.getKftcAccountId()); |
|
|
|
sendMoneyAPIRequestBody.setKftcAccountId(""); |
|
|
|
|
|
|
|
sendMoneyAPIRequestBody.setTxnPassword(password); |
|
|
|
sendMoneyAPIRequestBody.setUseBiometric(isBiometricUsed); |
|
|
|
|
|
|
|
sendMoneyAPIRequestBody.setSchemeId(selectedCoupon != null ? selectedCoupon.getSchemeId() : ""); |
|
|
|
sendMoneyAPIRequestBody.setSchemeId( ""); |
|
|
|
|
|
|
|
compositeObservable.add( |
|
|
|
gateway.performSendMoneyTransaction(gateway.getAuth(), sendMoneyAPIRequestBody) |
|
|
@ -488,7 +375,7 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
gateway.sendDataForForexCalculation(gateway.getAuth(), senderCountryId, |
|
|
|
senderCurrency, recieverCurrency, Utils.removeCommaFromAmount(senderAmount), |
|
|
|
Utils.removeCommaFromAmount(recieveAmount), paymentMethodId, calculationPreference, recipientCountryName, |
|
|
|
recipientCountryID, bankId, paymentPartnerId, gateway.getUserID(), selectedPaymentType.getType()) |
|
|
|
recipientCountryID, bankId, paymentPartnerId, gateway.getUserID(), "wallet") |
|
|
|
.doOnSubscribe(subs -> view.showProgressBar(true, "")) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
@ -526,61 +413,34 @@ public class SendMoneyV2Presenter extends BaseViewModel implements SendMoneyV2Pr |
|
|
|
return exchangeCalculationModelMutableLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public LiveData<Integer> subscribeToExRateCouponAvailableEvent() { |
|
|
|
return exchangeRateCouponResetActionLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public LiveData<Boolean> subscribeToExRateCouponRequireEvent() { |
|
|
|
return exchangeRateCouponViewRequiredLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public LiveData<AmountDetailSendMoneyFragment.CouponDetailViewDTO> subscribeToCouponSelectedEvent() { |
|
|
|
return couponSelectionLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
private void resetCouponData() { |
|
|
|
selectedCoupon = null; |
|
|
|
exchangeRateCouponResetActionLiveData.setValue(couponList != null ? couponList.size() - 1 : 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void showCouponRelatedData(boolean action) { |
|
|
|
selectedCoupon = null; |
|
|
|
exchangeRateCouponViewRequiredLiveData.setValue(action); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { |
|
|
|
resetCouponData(); |
|
|
|
if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
currentExchangeCalcResult = exchangeCalculationApiResponse.getData(); |
|
|
|
exchangeCalculationModelMutableLiveData.setValue(exchangeCalculationApiResponse.getData()); |
|
|
|
showCouponRelatedData(true); |
|
|
|
preSelectDefaultCouponIfAvailable(); |
|
|
|
} else { |
|
|
|
view.showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
showCouponRelatedData(false); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailed(String message) { |
|
|
|
showCouponRelatedData(false); |
|
|
|
resetCouponData(); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
showCouponRelatedData(false); |
|
|
|
resetCouponData(); |
|
|
|
|
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); |
|
|
|
} |
|
|
|
|
|
|
|