Examples of CheckoutShoppingCart


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

Examples of com.google.checkout.CheckoutShoppingCart

    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

Examples of com.google.checkout.schema._2.CheckoutShoppingCart

    }
   
    CheckoutFlowSupport flowSupport
        = _objectFact.createCheckoutShoppingCartCheckoutFlowSupport();
    flowSupport.setMerchantCheckoutFlowSupport(checkoutFlowSupport);
    CheckoutShoppingCart chkoutCart = _objectFact.createCheckoutShoppingCart();
    chkoutCart.setShoppingCart(cart);
    chkoutCart.setCheckoutFlowSupport(flowSupport);
    JAXBElement<CheckoutShoppingCart> elem
        = _objectFact.createCheckoutShoppingCart(chkoutCart);
    return convertToDOM(elem);
  }
View Full Code Here

Examples of com.google.checkout.schema._2.CheckoutShoppingCart

   
    try {
      CheckoutFlowSupportType flowSupport
          = _objectFact.createCheckoutShoppingCartCheckoutFlowSupportType();
      flowSupport.setMerchantCheckoutFlowSupport(checkoutFlowSupport);
      CheckoutShoppingCart chkoutCart = _objectFact.createCheckoutShoppingCartElement();
      chkoutCart.setShoppingCart(cart);
      chkoutCart.setCheckoutFlowSupport(flowSupport);
         
      return convertToDOM(chkoutCart);
    } catch (JAXBException jaxbEx) {
      throw new ProtocolException(jaxbEx.getMessage());
    }
View Full Code Here

Examples of com.google.checkout.sdk.domain.CheckoutShoppingCart

    public CheckoutShoppingCart build() {
      if (hasBeenBuilt) {
        throw new IllegalStateException();
      }
      this.hasBeenBuilt = true;
      CheckoutShoppingCart checkoutShoppingCart = new CheckoutShoppingCart();
      checkoutShoppingCart.setShoppingCart(shoppingCart);
      checkoutShoppingCart.setOrderProcessingSupport(orderProcessingSupport);
      return checkoutShoppingCart;
    }
View Full Code Here

Examples of com.google.checkout.sdk.domain.CheckoutShoppingCart

* Tests for creating Google Checkout shopping carts.
*
*/
public class CartPosterTest extends AbstractCommandTestCase {
  public void testCartPosterDoublePrice() {
     CheckoutShoppingCart checkoutShoppingCart =
       apiContext().cartPoster()
         .makeCart()
         .addItem("itemName", "itemDescription", 10.0, 1)
         .build();
     assertNull(checkoutShoppingCart.getCheckoutFlowSupport());
     assertNull(checkoutShoppingCart.getOrderProcessingSupport());
     ShoppingCart shoppingCart = checkoutShoppingCart.getShoppingCart();
     assertNull(shoppingCart.getBuyerMessages());
     assertNull(shoppingCart.getCartExpiration());
     assertNull(shoppingCart.getMerchantPrivateData());
     List<Item> items = shoppingCart.getItems().getItem();
     assertEquals(1, items.size());
View Full Code Here

Examples of com.google.checkout.sdk.domain.CheckoutShoppingCart

     assertEquals(10.0, item.getUnitPrice().getValue().doubleValue());
     assertEquals(1, item.getQuantity());
  }

  public void testCartPosterBignumPrice() {
    CheckoutShoppingCart checkoutShoppingCart =
      apiContext().cartPoster()
        .makeCart()
        .addItem("itemName", "itemDescription", BigDecimal.valueOf(10.0), 1)
        .build();
    assertNull(checkoutShoppingCart.getCheckoutFlowSupport());
    assertNull(checkoutShoppingCart.getOrderProcessingSupport());
    ShoppingCart shoppingCart = checkoutShoppingCart.getShoppingCart();
    assertNull(shoppingCart.getBuyerMessages());
    assertNull(shoppingCart.getCartExpiration());
    assertNull(shoppingCart.getMerchantPrivateData());
    List<Item> items = shoppingCart.getItems().getItem();
    assertEquals(1, items.size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.