Package com.google.checkout

Examples of com.google.checkout.CheckoutShoppingCart


  public static final CheckoutShoppingCart buildCheckoutShoppingCart(
      HttpServletRequest _request) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Building CheckoutShoppingCart from HTTP Request");
    }
    CheckoutShoppingCart checkoutCart = new CheckoutShoppingCart();
    ShoppingCart cart = new ShoppingCart();
    Items items = new Items();
    // Start with 0
    int lineNum = 0;
    while (_request.getParameter(PARAM_ITEM_NAME + lineNum) != null
        && _request.getParameter(PARAM_ITEM_DESCRIPTION + lineNum) != null
        && _request.getParameter(PARAM_UNIT_PRICE + lineNum) != null
        && _request.getParameter(PARAM_QUANTITY + lineNum) != null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found items for line " + lineNum);
      }
      Item item = new Item();
      item.setItemName(_request.getParameter(PARAM_ITEM_NAME + lineNum));
      item.setItemDescription(_request
          .getParameter(PARAM_ITEM_DESCRIPTION + lineNum));
      UnitPrice price = new UnitPrice();
      price.setContent(new BigDecimal(_request
          .getParameter(PARAM_UNIT_PRICE + lineNum)));
      if (_request.getParameter(PARAM_UNIT_PRICE + lineNum + PARAM_DOT_CURRENCY) != null) {
        price.setCurrency(_request.getParameter(PARAM_UNIT_PRICE
            + lineNum + PARAM_DOT_CURRENCY));
      } else {
        price.setCurrency(USD);
      }
      item.setUnitPrice(price);
      item.setQuantity(Integer.parseInt(_request.getParameter(PARAM_QUANTITY
          + lineNum)));
      items.addItem(item);
      lineNum++;
    }
    cart.setItems(items);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Added " + lineNum + " items to the cart.");
    }
    checkoutCart.setShoppingCart(cart);
    CheckoutFlowSupport flowSupport = new CheckoutFlowSupport();
    MerchantCheckoutFlowSupport mcfs = new MerchantCheckoutFlowSupport();
    if (_request.getParameter(PARAM_CONTINUE_SHOPPING_URL) != null) {
      mcfs.setContinueShoppingUrl(_request.getParameter(PARAM_CONTINUE_SHOPPING_URL));
    }
    if (_request.getParameter(PARAM_EDIT_CART_URL) != null) {
      mcfs.setEditCartUrl(_request.getParameter(PARAM_EDIT_CART_URL));
    }
    flowSupport.setMerchantCheckoutFlowSupport(mcfs);
    checkoutCart.setCheckoutFlowSupport(flowSupport);
    return checkoutCart;
  }
View Full Code Here


    Document xml = null;
    try {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Generating Shopping Cart");
      }
      CheckoutShoppingCart cart = APIUtil.buildCheckoutShoppingCart(_request);
      String encSig = APIUtil.generateCartSignature(cart);
      String encCart = APIUtil.encodeCart(cart);
      if (_request.getParameter(APIUtil.PARAM_REDIRECT) != null && _request.getParameter(APIUtil.PARAM_REDIRECT).equals("true")) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Posting Cart to Google");
View Full Code Here

TOP

Related Classes of com.google.checkout.CheckoutShoppingCart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.