@Test public void shouldRedirectToErrorViewIfErrorsInForm() throws CMSItemNotFoundException { doReturn(true).when(testObj).addGlobalErrors(modelMock, bindingResultMock); doReturn(BILLING_ERROR_VIEW).when(testObj).handleFormErrors(modelMock, paymentDetailsFormMock); final String result = testObj.addPaymentDetails(modelMock, paymentDetailsFormMock, bindingResultMock, redirectAttrsMock); assertEquals(BILLING_ERROR_VIEW, result); }
@RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn public String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs) throws CMSItemNotFoundException { getPaymentDetailsFormValidator().validate(paymentDetailsForm, bindingResult); if (addGlobalErrors(model, bindingResult)) { return handleFormErrors(model, paymentDetailsForm); } handleAndSaveAddresses(paymentDetailsForm); final String shopperBankCode = paymentDetailsForm.getShopperBankCode(); worldpayCartFacade.resetDeclineCodeAndShopperBankOnCart(shopperBankCode); final String paymentMethod = paymentDetailsForm.getPaymentMethod(); if (isAPM(paymentMethod)) { redirectAttrs.addFlashAttribute(SHOPPER_BANK_CODE, shopperBankCode); } redirectAttrs.addFlashAttribute(SAVE_PAYMENT_INFO, paymentDetailsForm.getSaveInAccount()); redirectAttrs.addFlashAttribute(PAYMENT_METHOD_PARAM, paymentDetailsForm.getPaymentMethod()); return getRedirectToPaymentMethod(); }
WorldpayRedirectCheckoutStepController extends WorldpayChoosePaymentMethodCheckoutStepController { @RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn public String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs) throws CMSItemNotFoundException { getPaymentDetailsFormValidator().validate(paymentDetailsForm, bindingResult); if (addGlobalErrors(model, bindingResult)) { return handleFormErrors(model, paymentDetailsForm); } handleAndSaveAddresses(paymentDetailsForm); final String shopperBankCode = paymentDetailsForm.getShopperBankCode(); worldpayCartFacade.resetDeclineCodeAndShopperBankOnCart(shopperBankCode); final String paymentMethod = paymentDetailsForm.getPaymentMethod(); if (isAPM(paymentMethod)) { redirectAttrs.addFlashAttribute(SHOPPER_BANK_CODE, shopperBankCode); } redirectAttrs.addFlashAttribute(SAVE_PAYMENT_INFO, paymentDetailsForm.getSaveInAccount()); redirectAttrs.addFlashAttribute(PAYMENT_METHOD_PARAM, paymentDetailsForm.getPaymentMethod()); return getRedirectToPaymentMethod(); } }
WorldpayRedirectCheckoutStepController extends WorldpayChoosePaymentMethodCheckoutStepController { @RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn public String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs) throws CMSItemNotFoundException { getPaymentDetailsFormValidator().validate(paymentDetailsForm, bindingResult); if (addGlobalErrors(model, bindingResult)) { return handleFormErrors(model, paymentDetailsForm); } handleAndSaveAddresses(paymentDetailsForm); final String shopperBankCode = paymentDetailsForm.getShopperBankCode(); worldpayCartFacade.resetDeclineCodeAndShopperBankOnCart(shopperBankCode); final String paymentMethod = paymentDetailsForm.getPaymentMethod(); if (isAPM(paymentMethod)) { redirectAttrs.addFlashAttribute(SHOPPER_BANK_CODE, shopperBankCode); } redirectAttrs.addFlashAttribute(SAVE_PAYMENT_INFO, paymentDetailsForm.getSaveInAccount()); redirectAttrs.addFlashAttribute(PAYMENT_METHOD_PARAM, paymentDetailsForm.getPaymentMethod()); return getRedirectToPaymentMethod(); }  }
WorldpayRedirectCheckoutStepController extends WorldpayChoosePaymentMethodCheckoutStepController { @RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn public String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs) throws CMSItemNotFoundException { getPaymentDetailsFormValidator().validate(paymentDetailsForm, bindingResult); if (addGlobalErrors(model, bindingResult)) { return handleFormErrors(model, paymentDetailsForm); } handleAndSaveAddresses(paymentDetailsForm); final String shopperBankCode = paymentDetailsForm.getShopperBankCode(); worldpayCartFacade.resetDeclineCodeAndShopperBankOnCart(shopperBankCode); final String paymentMethod = paymentDetailsForm.getPaymentMethod(); if (isAPM(paymentMethod)) { redirectAttrs.addFlashAttribute(SHOPPER_BANK_CODE, shopperBankCode); } redirectAttrs.addFlashAttribute(SAVE_PAYMENT_INFO, paymentDetailsForm.getSaveInAccount()); redirectAttrs.addFlashAttribute(PAYMENT_METHOD_PARAM, paymentDetailsForm.getPaymentMethod()); return getRedirectToPaymentMethod(); }  @RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs); }
WorldpayRedirectCheckoutStepController extends WorldpayChoosePaymentMethodCheckoutStepController { @RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn public String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs) throws CMSItemNotFoundException { getPaymentDetailsFormValidator().validate(paymentDetailsForm, bindingResult); if (addGlobalErrors(model, bindingResult)) { return handleFormErrors(model, paymentDetailsForm); } handleAndSaveAddresses(paymentDetailsForm); final String shopperBankCode = paymentDetailsForm.getShopperBankCode(); worldpayCartFacade.resetDeclineCodeAndShopperBankOnCart(shopperBankCode); final String paymentMethod = paymentDetailsForm.getPaymentMethod(); if (isAPM(paymentMethod)) { redirectAttrs.addFlashAttribute(SHOPPER_BANK_CODE, shopperBankCode); } redirectAttrs.addFlashAttribute(SAVE_PAYMENT_INFO, paymentDetailsForm.getSaveInAccount()); redirectAttrs.addFlashAttribute(PAYMENT_METHOD_PARAM, paymentDetailsForm.getPaymentMethod()); return getRedirectToPaymentMethod(); }  @RequestMapping(value = "/add-payment-details", method = POST) @RequireHardLogIn String addPaymentDetails(final Model model, @Valid final PaymentDetailsForm paymentDetailsForm, final BindingResult bindingResult, final RedirectAttributes redirectAttrs);  }