Esempio n. 1
0
  @RequestMapping(value = "confirm")
  public String confirm(Model model, Cart cart, @Valid Shipping shipping, Errors errors) {

    // if cart is empty, redirect to cart view page.
    if (cart.getReadOnlyItemList().size() < 1) {
      return "redirect:/cart/view";
    }

    // validation
    if (errors.hasErrors()) {
      logger.debug(errors);
      return "redirect:shipping?redirected=true";
    }

    model.addAttribute("cart", cart);
    model.addAttribute("shipping", shipping);
    return "checkout/confirm";
  }
Esempio n. 2
0
  @RequestMapping(value = "complete")
  public String complete(Shipping shipping, Cart cart, HttpSession httpSession) throws Exception {

    // check transaction token
    boolean checkResult =
        TransactionTokenHelper.checkToken(httpSession, shipping.getTransactionToken());
    if (!checkResult) {
      throw new Exception("Transaction Token Unmatch !");
    }

    boolean result = purchaseService.execPurchase(cart, shipping);
    if (result) {
      TransactionTokenHelper.removeToken(httpSession);
      cart.removeAll();
      logger.debug("### purchase succeed!!");
    }

    return "redirect:thankyou";
  }