I have a method to check a users input is correct as card information & a method to return a error message (server side).
I want to return a payment successful page if all information is correct. Return a payment failed page if the user input does not match the card information in a spreadsheet. << Currently my program can do this.
If the user leaves a field blank i.e. card number I want it to return the same page with a validation message.
@RequestMapping(value = "/payment-submission", method = RequestMethod.POST)
public String handlePaymentSubmission(@ModelAttribute PaymentDetails paymentDetails, BindingResult resulttwo) {
if (payService.isPaymentDetailsCorrect(paymentDetails)) {
return PAYMENT_SUCCESSFUL;
}
return PAYMENT_FAILED;
This is my current code that works.
I am not sure how to call the method below which checks the validation into the above to make sure it returns the correct page.
private void validatePaymentDetails(final PaymentDetails paymentDetails, final BindingResult resulttwo) {
if (StringUtils.isBlank(paymentDetails.getCardNumber())) {
resulttwo.addError(new FieldError("paymentDetails", "cardNumber",
"validate.payment-details-cardnumber.empty.message"));
return;
}
}
As mentioned in previous posts, I am new and learning JAVA so apologies if this is confusing or is incorrect.
All help is appreciated.
Aucun commentaire:
Enregistrer un commentaire