diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/BankContract.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/BankContract.java index 3974c8efb..fb252c06c 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/BankContract.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/BankContract.java @@ -50,7 +50,7 @@ interface DebitCardView extends BaseView { void verifyDebitCardSuccess(String otp); - void verifyDebitCardError(String message); + void verifyDebitCardError(String message, int viewNumber); } interface UpiPinPresenter extends BasePresenter { diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/fragment/DebitCardFragment.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/fragment/DebitCardFragment.java index 49d81c885..cb7b5c150 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/fragment/DebitCardFragment.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/fragment/DebitCardFragment.java @@ -94,10 +94,16 @@ public void verifyDebitCardSuccess(String otp) { } @Override - public void verifyDebitCardError(String message) { + public void verifyDebitCardError(String message, int viewNumber) { hideProgressDialog(); - mEtDebitCardNumber.requestFocusFromTouch(); showToast(message); + if (viewNumber == 1) { + mEtDebitCardNumber.requestFocusFromTouch(); + } else if (viewNumber == 2) { + mPeMonth.requestFocusFromTouch(); + } else if (viewNumber == 3) { + mPeYear.requestFocusFromTouch(); + } } public void showToast(String message) { diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/presenter/DebitCardPresenter.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/presenter/DebitCardPresenter.java index df91aca03..dad9a71b7 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/presenter/DebitCardPresenter.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/bank/presenter/DebitCardPresenter.java @@ -4,6 +4,8 @@ import org.mifos.mobilewallet.mifospay.bank.BankContract; import org.mifos.mobilewallet.mifospay.base.BaseView; +import java.util.Calendar; + import javax.inject.Inject; import static org.mifos.mobilewallet.mifospay.MifosPayApp.getContext; @@ -30,9 +32,22 @@ public void attachView(BaseView baseView) { @Override public void verifyDebitCard(String s, String s1, String s2) { String otp = "0000"; + int expiryMonth = Integer.parseInt(s1); + int expiryYear = Integer.parseInt(s2); + int currentYear = Calendar.getInstance().get(Calendar.YEAR); + int currentMonth = Calendar.getInstance().get(Calendar.MONTH) + 1; if ((s.length() < 12) || (s.length() > 19)) { mDebitCardView.verifyDebitCardError(getContext() - .getString(R.string.debit_card_error_message)); + .getString(R.string.debit_card_error_message), 1); + } else if (expiryMonth < 01 || expiryMonth > 12) { + mDebitCardView.verifyDebitCardError(getContext() + .getString(R.string.expiry_month_error_message), 2); + } else if (expiryYear < currentYear || expiryYear > currentYear + 10) { + mDebitCardView.verifyDebitCardError(getContext() + .getString(R.string.expiry_year_error_message), 3); + } else if (expiryMonth < currentMonth && expiryYear <= currentYear) { + mDebitCardView.verifyDebitCardError(getContext() + .getString(R.string.expiry_month_error_message), 2); } else { mDebitCardView.verifyDebitCardSuccess(otp); } diff --git a/mifospay/src/main/res/values/strings.xml b/mifospay/src/main/res/values/strings.xml index 897c38189..a1a604311 100644 --- a/mifospay/src/main/res/values/strings.xml +++ b/mifospay/src/main/res/values/strings.xml @@ -160,6 +160,8 @@ Log out Debit Card Details Invalid Debit Card Number + Invalid Expiry Month + Invalid Expiry Year One Time Password UPI PIN Setup All fields are mandatory.