コード例 #1
0
  @Secured("PAYMENT")
  @RequestMapping(value = "/admin/payments/paymentMethod.html", method = RequestMethod.GET)
  public String displayPaymentMethod(
      @RequestParam("code") String code,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    this.setMenu(model, request);
    MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE);

    // get configured shipping modules
    IntegrationConfiguration configuration = paymentService.getPaymentConfiguration(code, store);
    if (configuration == null) {
      configuration = new IntegrationConfiguration();
      configuration.setEnvironment(
          com.salesmanager.core.constants.Constants.PRODUCTION_ENVIRONMENT);

      Map<String, String> keys = new HashMap<String, String>();
      keys.put("transaction", TransactionType.AUTHORIZECAPTURE.name());

      configuration.setIntegrationKeys(keys);
    }

    configuration.setModuleCode(code);

    List<String> environments = new ArrayList<String>();
    environments.add(com.salesmanager.core.constants.Constants.TEST_ENVIRONMENT);
    environments.add(com.salesmanager.core.constants.Constants.PRODUCTION_ENVIRONMENT);

    model.addAttribute("configuration", configuration);
    model.addAttribute("environments", environments);
    return ControllerConstants.Tiles.Payment.paymentMethod;
  }
コード例 #2
0
  @RequestMapping(value = "/admin/payments/paymentMethods.html", method = RequestMethod.GET)
  public String getPaymentMethods(
      Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {

    // set menu
    setMenu(model, request);

    MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE);

    // get payment methods
    List<IntegrationModule> modules = paymentService.getPaymentMethods(store);

    // get configured payment modules
    Map<String, IntegrationConfiguration> configuredModules =
        paymentService.getPaymentModulesConfigured(store);

    model.addAttribute("modules", modules);
    model.addAttribute("configuredModules", configuredModules);

    return ControllerConstants.Tiles.Payment.paymentMethods;
  }
コード例 #3
0
  @RequestMapping(value = "/admin/payments/deletePaymentMethod.html", method = RequestMethod.POST)
  public String deletePaymentMethod(
      @RequestParam("code") String code,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      Locale locale)
      throws Exception {

    this.setMenu(model, request);
    MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE);
    paymentService.removePaymentModuleConfiguration(code, store);

    return "redirect:/admin/payments/paymentMethods.html";
  }
コード例 #4
0
  @Secured("PAYMENT")
  @RequestMapping(value = "/admin/payments/savePaymentMethod.html", method = RequestMethod.POST)
  public String savePaymentMethod(
      @ModelAttribute("configuration") IntegrationConfiguration configuration,
      BindingResult result,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      Locale locale)
      throws Exception {

    this.setMenu(model, request);
    MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE);

    List<String> environments = new ArrayList<String>();
    environments.add(com.salesmanager.core.constants.Constants.TEST_ENVIRONMENT);
    environments.add(com.salesmanager.core.constants.Constants.PRODUCTION_ENVIRONMENT);

    model.addAttribute("environments", environments);
    model.addAttribute("configuration", configuration);

    try {
      paymentService.savePaymentModuleConfiguration(configuration, store);
    } catch (Exception e) {
      if (e instanceof IntegrationException) {
        if (((IntegrationException) e).getErrorCode()
            == IntegrationException.ERROR_VALIDATION_SAVE) {

          List<String> errorCodes = ((IntegrationException) e).getErrorFields();
          for (String errorCode : errorCodes) {
            model.addAttribute(errorCode, messages.getMessage("message.fielderror", locale));
          }
          model.addAttribute("validationError", "validationError");
          return ControllerConstants.Tiles.Payment.paymentMethod;
        }
      } else {
        throw new Exception(e);
      }
    }

    model.addAttribute("success", "success");
    return ControllerConstants.Tiles.Payment.paymentMethod;
  }