예제 #1
0
  // goes to summary page
  public String subscribe() {

    try {

      preparePage();
      validateCustomer();

      SessionUtil.setCustomer(customer, getServletRequest());

      prepareZones();

      if (this.getPaymentMethod() == null
          || this.getPaymentMethod().getPaymentModuleName() == null) {
        super.addActionError("error.nopaymentmethod");
        return INPUT;
      }

      super.getServletRequest().setAttribute("SELECTEDPAYMENT", this.getPaymentMethod());

      MerchantStore store = SessionUtil.getMerchantStore(getServletRequest());

      // check if payment method is credit card type
      if (com.salesmanager.core.util.PaymentUtil.isPaymentModuleCreditCardType(
          this.getPaymentMethod().getPaymentModuleName())) {
        super.validateCreditCard(this.getPaymentMethod(), store.getMerchantId());
      } else {
        super.setCreditCard(null); // reset credit card information
      }

      if (getFieldErrors().size() > 0) {
        return INPUT;
      }

      SessionUtil.setPaymentMethod(this.getPaymentMethod(), getServletRequest());

    } catch (Exception e) {
      log.error(e);
      super.addActionError(getText("error.process.notransaction"));
      return "GLOBALERROR";
    }

    return SUCCESS;
  }
예제 #2
0
  @RequestMapping(
      value = {"/password/reset.html"},
      method = RequestMethod.POST)
  public String resetPassword(HttpServletRequest request) throws Exception {

    String userName = request.getParameter("resetpasswordusername");
    CustomerService cservice =
        (CustomerService) ServiceFactory.getService(ServiceFactory.CustomerService);

    MerchantStore store = SessionUtil.getMerchantStore(request);
    Customer customer = cservice.findCustomerByUserName(userName, store.getMerchantId());

    if (customer != null) {
      cservice.resetCustomerPassword(customer);
    }

    super.setMessage("label.customer.passwordreset", request);

    return "redirect:/home.html";
  }
예제 #3
0
  /** Complete overwrite * */
  public String comitOrder() {

    try {

      boolean paymentProcessed = false;

      // Get all entities

      Order order = SessionUtil.getOrder(getServletRequest());
      MerchantStore store = SessionUtil.getMerchantStore(getServletRequest());

      PaymentMethod payment = SessionUtil.getPaymentMethod(getServletRequest());

      order.setPaymentMethod(payment.getPaymentMethodName());
      order.setPaymentModuleCode(payment.getPaymentModuleName());

      Customer customer = SessionUtil.getCustomer(getServletRequest());

      if (super.getServletRequest().getSession().getAttribute("TRANSACTIONCOMITED") != null) {
        addActionError(
            getText(
                "error.transaction.duplicate",
                new String[] {String.valueOf(order.getOrderId()), store.getStoreemailaddress()}));
        return "GENERICERROR";
      }

      OrderService oservice = (OrderService) ServiceFactory.getService(ServiceFactory.OrderService);

      try {

        Map orderProducts = SessionUtil.getOrderProducts(getServletRequest());
        Set s = new HashSet();

        for (Object o : orderProducts.values()) {

          OrderProduct op = (OrderProduct) o;
          s.add(op);
        }

        order.setOrderProducts(s);

        String comments = null;
        if (this.getOrderHistory() != null) {
          comments = this.getOrderHistory().getComments();
        }

        // Order, PaymentMethod,
        ProcessorContext context = new ProcessorContext();

        Collection files = oservice.getOrderProductDownloads(order.getOrderId());
        if (files != null && files.size() > 0) {
          context.addObject("files", files);
        }

        context.addObject("Order", order);
        context.addObject("Customer", customer);
        context.addObject("MerchantStore", store);
        context.addObject("PaymentMethod", payment);
        context.addObject("Locale", super.getLocale());
        context.addObject("comments", comments);
        context.addObject("products", orderProducts.values());

        WorkflowProcessor wp = (WorkflowProcessor) SpringUtil.getBean("invoiceWorkflow");
        wp.doWorkflow(context);

        paymentProcessed = true;

        // set an indicator in HTTPSession to prevent duplicates
        super.getServletRequest().getSession().setAttribute("TRANSACTIONCOMITED", "true");

        if (!StringUtils.isBlank(comments)) {
          SessionUtil.setOrderStatusHistory(this.getOrderHistory(), getServletRequest());
        }

      } catch (Exception e) {
        if (e instanceof TransactionException) {
          super.addErrorMessage("error.payment.paymenterror");
          return "PAYMENTERROR";
        }

        if (e instanceof OrderException) {
          try {
            oservice.sendOrderProblemEmail(order.getMerchantId(), order, customer, store);
          } catch (Exception ee) {
            log.error(ee);
          }
        }

        addActionError(
            getText(
                "message.error.comitorder.error",
                new String[] {String.valueOf(order.getOrderId()), store.getStoreemailaddress()}));
        log.error(e);
        return "GENERICERROR";
      }

      return SUCCESS;

    } catch (Exception e) {
      log.error(e);
    }

    return SUCCESS;
  }