|
|
@ -5,6 +5,8 @@ import android.text.Spanned; |
|
|
|
import android.util.Log; |
|
|
|
|
|
|
|
import com.gmeremit.online.gmeremittance_native.R; |
|
|
|
import com.gmeremit.online.gmeremittance_native.accountmanage.model.paymentsources.PaymentSourceDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.accountmanage.presenter.paymentsources.PaymentSourceSelectionInteractorInterface; |
|
|
|
import com.gmeremit.online.gmeremittance_native.base.BasePresenter; |
|
|
|
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; |
|
|
|
import com.gmeremit.online.gmeremittance_native.customwidgets.banklistingdialog.BankIconMapper; |
|
|
@ -17,22 +19,31 @@ import com.gmeremit.online.gmeremittance_native.domesticremit.send.model.Domesti |
|
|
|
import com.gmeremit.online.gmeremittance_native.domesticremit.send.model.DomesticRemitTxnResponseDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.domesticremit.send.model.KFTCBalanceCheckDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.domesticremit.send.view.RecipientConfirmDialog; |
|
|
|
import com.gmeremit.online.gmeremittance_native.topup.local.model.topup.LocalTopUpResponseDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.topup.local.presenter.topup.LocalTopUpPresenter; |
|
|
|
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.PasswordPromptListener; |
|
|
|
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionBiometricPromptDialog; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.Constants; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.Utils; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponseV2; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.GenericResponseDataModel; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.GenericThrowable; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.HTTPConstants; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.https.HttpClientV2; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.security.SecurityUtils; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.lang.reflect.Type; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import io.reactivex.Observable; |
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
|
import io.reactivex.disposables.CompositeDisposable; |
|
|
|
import io.reactivex.observers.DisposableObserver; |
|
|
|
import io.reactivex.schedulers.Schedulers; |
|
|
|
import retrofit2.HttpException; |
|
|
|
|
|
|
|
public class DomesticRemitPresenterImpl extends BasePresenter implements DomesticRemitPresenterInterface { |
|
|
|
|
|
|
@ -44,10 +55,14 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
|
|
|
|
private List<DomesticBankDTO> availableBankList; |
|
|
|
private List<DomesticAccountsDTO> availableAccountList; |
|
|
|
private List<PaymentSourceDTO> paymentSourceList; |
|
|
|
private final PaymentSourceSelectionInteractorInterface.PaymentSourceSelectionGatewayInterface paymentSourceSelectionGateway; |
|
|
|
|
|
|
|
public DomesticRemitPresenterImpl(DomesticRemitContractInterface view, DomesticRemitGatewayInterface gatewayInterface) { |
|
|
|
|
|
|
|
public DomesticRemitPresenterImpl(DomesticRemitContractInterface view, DomesticRemitGatewayInterface gatewayInterface, PaymentSourceSelectionInteractorInterface.PaymentSourceSelectionGatewayInterface paymentSourceSelectionGateway) { |
|
|
|
this.view = view; |
|
|
|
this.gateway = gatewayInterface; |
|
|
|
this.paymentSourceSelectionGateway = paymentSourceSelectionGateway; |
|
|
|
domesticRemitDataValidator = new DomesticRemitDataValidator(); |
|
|
|
countDownRemainingValue = -1; |
|
|
|
compositeDisposable = new CompositeDisposable(); |
|
|
@ -56,14 +71,63 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
|
|
|
|
@Override |
|
|
|
public void getDomesticRemitRelatedInfo() { |
|
|
|
compositeDisposable.add( |
|
|
|
this.gateway.getDomesticRelatedData(gateway.getAuth(), gateway.getUserIDNumber()) |
|
|
|
.doOnSubscribe(disposable -> view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) |
|
|
|
// compositeDisposable.add( |
|
|
|
// this.gateway.getDomesticRelatedData(gateway.getAuth(), gateway.getUserIDNumber()) |
|
|
|
// .doOnSubscribe(disposable -> view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) |
|
|
|
// .subscribeOn(Schedulers.io()) |
|
|
|
// .observeOn(AndroidSchedulers.mainThread()) |
|
|
|
// .doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
// .subscribeWith(new DomesticRelatedDataObserver()) |
|
|
|
// ); |
|
|
|
|
|
|
|
|
|
|
|
this.compositeDisposable.add( |
|
|
|
Observable.zip( |
|
|
|
getDomesticTransferRelatedData(), |
|
|
|
getPaymentSourcesList(), |
|
|
|
DomesticRelatedData::new) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.doOnSubscribe(d -> { |
|
|
|
view.hideKeyBoard(); |
|
|
|
view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text)); |
|
|
|
}) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
.subscribeWith(new DomesticRelatedDataObserver()) |
|
|
|
.subscribeWith(new DomesticRelatedDataObserverV2()) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Observable<DomesticRemitRelatedInfoDTO> getDomesticTransferRelatedData() { |
|
|
|
Type domesticDataType = new TypeToken<GenericResponseDataModel<DomesticRemitRelatedInfoDTO>>() { |
|
|
|
}.getType(); |
|
|
|
return this.gateway.getDomesticRelatedData(this.gateway.getAuth(), gateway.getUserIDNumber()) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.flatMap(response -> { |
|
|
|
GenericResponseDataModel<DomesticRemitRelatedInfoDTO> data = HttpClientV2.getDeserializer().fromJson(response.string(), domesticDataType); |
|
|
|
if (data.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) |
|
|
|
return Observable.just(data.getData()); |
|
|
|
else if (data.getErrorCode().equalsIgnoreCase("5")) |
|
|
|
return Observable.error(new GenericThrowable(getStringfromStringId(R.string.waitinge_recent_request_text))); |
|
|
|
else |
|
|
|
return Observable.error(new GenericThrowable(data.getMsg())); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Observable<List<PaymentSourceDTO>> getPaymentSourcesList() { |
|
|
|
Type paymentSourceType = new TypeToken<GenericResponseDataModel<List<PaymentSourceDTO>>>() { |
|
|
|
}.getType(); |
|
|
|
return this.paymentSourceSelectionGateway.getAvailablePaymentSource(this.gateway.getAuth(), gateway.getUserIDNumber()) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.flatMap(response -> { |
|
|
|
GenericResponseDataModel<List<PaymentSourceDTO>> data = HttpClientV2.getDeserializer().fromJson(response.string(), paymentSourceType); |
|
|
|
if (data.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) |
|
|
|
return Observable.just(data.getData()); |
|
|
|
else |
|
|
|
return Observable.error(new GenericThrowable(data.getMsg())); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -144,7 +208,7 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onSenderAccountSelected(DomesticAccountsDTO selectedAccount) { |
|
|
|
public void onSenderAccountSelected(PaymentSourceDTO selectedAccount) { |
|
|
|
domesticRemitDataValidator.validateSenderAccount(selectedAccount); |
|
|
|
} |
|
|
|
|
|
|
@ -226,7 +290,7 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
} |
|
|
|
|
|
|
|
class DomesticRemitDataValidator { |
|
|
|
private DomesticAccountsDTO selectedSenderAccount; |
|
|
|
private PaymentSourceDTO selectedSenderAccount; |
|
|
|
private String sendAmount; |
|
|
|
private DomesticBankDTO selectedRecipientBank; |
|
|
|
private String bankAcNo; |
|
|
@ -272,7 +336,39 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
this.serviceCharge = serviceCharge; |
|
|
|
} |
|
|
|
|
|
|
|
public void validateSenderAccount(DomesticAccountsDTO selectedAccount) { |
|
|
|
// public void validateSenderAccount(DomesticAccountsDTO selectedAccount) { |
|
|
|
// currentBalance = null; |
|
|
|
// |
|
|
|
// if (selectedAccount == null) { |
|
|
|
// view.setErrorOnWidgetSenderAccount("Please select an account"); |
|
|
|
// view.showSelectedSenderAccount(""); |
|
|
|
// isValidSenderAccount = false; |
|
|
|
// } else { |
|
|
|
// this.selectedSenderAccount = selectedAccount; |
|
|
|
// view.setErrorOnWidgetSenderAccount(null); |
|
|
|
// view.showSelectedSenderAccount(selectedAccount.toString()); |
|
|
|
// isValidSenderAccount = true; |
|
|
|
// |
|
|
|
// String serviceChargeOnBasisOnType = ""; |
|
|
|
// if ("autodebit".equalsIgnoreCase(selectedSenderAccount.getType())) |
|
|
|
// serviceChargeOnBasisOnType = serviceCharge; |
|
|
|
// else |
|
|
|
// serviceChargeOnBasisOnType = serviceChargeWallet; |
|
|
|
// |
|
|
|
// String messageServiceCharge = getStringfromStringId(R.string.transfer_charge_text) + ": " + Utils.formatCurrencyWithoutTruncatingDecimal(serviceChargeOnBasisOnType) + " " + Constants.KRW_STRING; |
|
|
|
// view.updateServiceCharge(messageServiceCharge); |
|
|
|
// |
|
|
|
// if (sendAmount != null && sendAmount.length() > 0) |
|
|
|
// validateSendAmount(sendAmount); |
|
|
|
// |
|
|
|
// |
|
|
|
// } |
|
|
|
// validateAll(); |
|
|
|
// |
|
|
|
// view.showCheckBalanceButton(true); |
|
|
|
// |
|
|
|
// } |
|
|
|
public void validateSenderAccount(PaymentSourceDTO selectedAccount) { |
|
|
|
currentBalance = null; |
|
|
|
|
|
|
|
if (selectedAccount == null) { |
|
|
@ -337,9 +433,9 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
|
|
|
|
double deductionAmount = Utils.formatCurrencyForComparision(sendAmount) + Utils.formatCurrencyForComparision(serviceChargeOnBasisOnType); |
|
|
|
|
|
|
|
String formattedAmount=Utils.formatCurrency(new BigDecimal(deductionAmount).stripTrailingZeros().toPlainString()); |
|
|
|
String message = getStringfromStringId(R.string.will_deduct_info_text).replace("ooo",formattedAmount); |
|
|
|
Spanned sp = Html.fromHtml("• "+message); |
|
|
|
String formattedAmount = Utils.formatCurrency(new BigDecimal(deductionAmount).stripTrailingZeros().toPlainString()); |
|
|
|
String message = getStringfromStringId(R.string.will_deduct_info_text).replace("ooo", formattedAmount); |
|
|
|
Spanned sp = Html.fromHtml("• " + message); |
|
|
|
|
|
|
|
view.showDeductionAmount(sp.toString()); |
|
|
|
} |
|
|
@ -467,54 +563,122 @@ public class DomesticRemitPresenterImpl extends BasePresenter implements Domesti |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class DomesticRelatedDataObserver extends GenericApiObserverResponseV2<DomesticRemitRelatedInfoDTO> { |
|
|
|
public static class DomesticRelatedData { |
|
|
|
DomesticRemitRelatedInfoDTO domesticRelatedData; |
|
|
|
List<PaymentSourceDTO> paymentSourceList; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Type getDataType() { |
|
|
|
return TypeToken.getParameterized(DomesticRemitRelatedInfoDTO.class).getType(); |
|
|
|
public DomesticRelatedData(DomesticRemitRelatedInfoDTO domesticRelatedData, List<PaymentSourceDTO> paymentSourceList) { |
|
|
|
this.domesticRelatedData = domesticRelatedData; |
|
|
|
this.paymentSourceList = paymentSourceList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onSuccess(GenericResponseDataModel<DomesticRemitRelatedInfoDTO> t) { |
|
|
|
if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
public DomesticRemitRelatedInfoDTO getDomesticRelatedData() { |
|
|
|
return domesticRelatedData; |
|
|
|
} |
|
|
|
|
|
|
|
domesticRemitDataValidator.setServiceCharge(t.getData().getServiceFee()); |
|
|
|
domesticRemitDataValidator.setWalletServiceCharge(t.getData().getServiceFeeWallet()); |
|
|
|
public List<PaymentSourceDTO> getPaymentSourceList() { |
|
|
|
return paymentSourceList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
availableBankList = t.getData().getBankList(); |
|
|
|
availableAccountList = t.getData().getAccountList(); |
|
|
|
public class DomesticRelatedDataObserverV2 extends DisposableObserver<DomesticRelatedData> { |
|
|
|
|
|
|
|
if (t.getData().getAccountList() == null || t.getData().getAccountList().size() < 1) { |
|
|
|
String message = getStringfromStringId(R.string.doesnt_have_auto_debit_text); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.exitView()); |
|
|
|
} else { |
|
|
|
domesticRemitDataValidator.validateSenderAccount(availableAccountList.get(0)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onNext(DomesticRelatedData domesticRelatedData) { |
|
|
|
domesticRemitDataValidator.setServiceCharge(domesticRelatedData.getDomesticRelatedData().getServiceFee()); |
|
|
|
domesticRemitDataValidator.setWalletServiceCharge(domesticRelatedData.getDomesticRelatedData().getServiceFeeWallet()); |
|
|
|
|
|
|
|
availableBankList = domesticRelatedData.getDomesticRelatedData().getBankList(); |
|
|
|
availableAccountList = domesticRelatedData.getDomesticRelatedData().getAccountList(); |
|
|
|
|
|
|
|
paymentSourceList = domesticRelatedData.getPaymentSourceList(); |
|
|
|
|
|
|
|
//TODO add wallet no for wallet account in "accountMaskedKey" |
|
|
|
if(paymentSourceList!=null) |
|
|
|
{ |
|
|
|
for(PaymentSourceDTO paymentSourceDTO : paymentSourceList) |
|
|
|
{ |
|
|
|
if(!paymentSourceDTO.isAccountAutoDebitType()) |
|
|
|
paymentSourceDTO.setAccountNumMasked(gateway.getWalletNumber()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (domesticRelatedData.getDomesticRelatedData().getAccountList() == null || domesticRelatedData.getDomesticRelatedData().getAccountList().size() < 1) { |
|
|
|
String message = getStringfromStringId(R.string.doesnt_have_auto_debit_text); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.exitView()); |
|
|
|
} else { |
|
|
|
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
domesticRemitDataValidator.validateSenderAccount(paymentSourceList.get(0)); |
|
|
|
} |
|
|
|
|
|
|
|
view.updatePaymentSourceList(paymentSourceList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailed(String message) { |
|
|
|
public void onError(Throwable e) { |
|
|
|
String message = e.getMessage(); |
|
|
|
if (e instanceof HttpException) { |
|
|
|
message = HTTPConstants.getErrorMessageFromCode(((HttpException) e).code()); |
|
|
|
} else if (e instanceof IOException) { |
|
|
|
message = HTTPConstants.HTTP_RESPONSE_NO_INTERNET; |
|
|
|
} |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, alertType -> view.exitView()); |
|
|
|
|
|
|
|
} |
|
|
|
public void onComplete() { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void unauthorizedAccess(String message) { |
|
|
|
gateway.clearAllUserData(); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// public class DomesticRelatedDataObserver extends GenericApiObserverResponseV2<DomesticRemitRelatedInfoDTO> { |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// protected Type getDataType() { |
|
|
|
// return TypeToken.getParameterized(DomesticRemitRelatedInfoDTO.class).getType(); |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// protected void onSuccess(GenericResponseDataModel<DomesticRemitRelatedInfoDTO> t) { |
|
|
|
// if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
// |
|
|
|
// domesticRemitDataValidator.setServiceCharge(t.getData().getServiceFee()); |
|
|
|
// domesticRemitDataValidator.setWalletServiceCharge(t.getData().getServiceFeeWallet()); |
|
|
|
// |
|
|
|
// availableBankList = t.getData().getBankList(); |
|
|
|
// availableAccountList = t.getData().getAccountList(); |
|
|
|
// |
|
|
|
// if (t.getData().getAccountList() == null || t.getData().getAccountList().size() < 1) { |
|
|
|
// String message = getStringfromStringId(R.string.doesnt_have_auto_debit_text); |
|
|
|
// view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.exitView()); |
|
|
|
// } else { |
|
|
|
// domesticRemitDataValidator.validateSenderAccount(availableAccountList.get(0)); |
|
|
|
// } |
|
|
|
// |
|
|
|
// |
|
|
|
// } else { |
|
|
|
// view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void onFailed(String message) { |
|
|
|
// view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// protected void onConnectionNotEstablished(String message) { |
|
|
|
// view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, alertType -> view.exitView()); |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// protected void unauthorizedAccess(String message) { |
|
|
|
// gateway.clearAllUserData(); |
|
|
|
// view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
public class VerifyKFTCAccountObserver extends GenericApiObserverResponseV2<DomesticReicipientInfoDTO> { |
|
|
|
|
|
|
|
@Override |
|
|
|