java.lang.Object
de.hybris.platform.ycommercewebservices.v1.controller.BaseController
de.hybris.platform.ycommercewebservices.v1.controller.CartController

@Controller("cartControllerV1") @RequestMapping("/{baseSiteId}/cart") public class CartController extends BaseController
  • Field Summary

    Fields inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController

    DEFAULT_CURRENT_PAGE, DEFAULT_PAGE_SIZE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addPaymentInfo(javax.servlet.http.HttpServletRequest request)
    Web service for creating a credit card payment subscription.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/paymentinfo
    CCPaymentInfoData parameters need to be send as post body.
    Method uses dedicated populator - HttpRequestPaymentInfoPopulator - to populate the CCPaymentInfoData from request parameters.
    Method uses dedicated validator - CCPaymentInfoValidator - to validate request parameters.
    This method requires authentication and is restricted for HTTPS channel.
    Method type : POST.
    addToCart(String baseSiteId, String code, long qty, String storeName)
    Web service handler for adding new products to the session cart.
    Sample target URL : http://localhost:9001/rest/v1/cart/entry.
    Client should provide product code and quantity (optional) as POST body.
    It's also possible to add product that will be pickedup in store by specifying optional storeName parameter (product must be in stock in that particular store).
    For Content-Type=application/x-www-form-urlencoded;charset=UTF-8 a sample body is: (urlencoded) is: entryNumber=1&qty=2..
    Request Method = POST Response contains a set-cookie header with the jsessionId associated with the cart.
    applyPromotion(String promotionCode)
    Web service for enabling order promotions.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/promotion/{promotionCode}
    This method requires authentication and is restricted to HTTPS channel only.
    Method type : POST.
    Web service for applying voucher to cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/voucher/abc-9PSW-EDH2-RXKA
    This method requires authentication.
    Method type : POST.
    Method is restricted for HTTPS channel.
    authorizePayment(String securityCode)
    Web service for authorizing cart's credit cart payment.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/authorizePayment
    authorization security code - ccv - must be sent as a post body.
    Response contains a set-cookie header with the jsessionId associated with the cart.
    This method requires authentication and is restricted to HTTPS channel only.
    Method type : POST.
    protected AddressData
    createAddress(javax.servlet.http.HttpServletRequest request)
     
    deleteCartEntry(long entryNumber)
    Web service for deleting cart entry.
    Client should provide cart entry number as path variable.
    Sample target URL : http://localhost:9001/rest/v1/cart/entry/0
    Response contains a set-cookie header with the jsessionId associated with the cart.
    Request Method = DELETE
    protected OrderEntryData
    getCartEntryForNumber(long number)
     
     
    getSessionCart(boolean restore)
    Web service for getting session cart.
    Web service for getting all supported delivery modes for the session cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/deliverymodes
    Response contains a set-cookie header with the jsessionId associated with the cart.
    This method requires authentication and is restricted to HTTPS channel only.
    Method type : GET.
    oneStepCheckout(String addressId, String addressIsocode, String deliveryMode, String voucherCode, String paymentInfoId, String securityCode, javax.servlet.http.HttpServletRequest request)
    Web service for one-step checkout from current session cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/checkout
    This method requires authentication.
    Method type : POST.
    Method is restricted for HTTPS channel.
    pickupEntryInStore(String baseSiteId, long entryNumber, String storeName)
    Web service for setting store where cart entry will be picked up.
    Client should provide cart entry number as path variable and storeName parameter in body.
    Sample target URL : http://localhost:9001/rest/v1/cart/entry/{entryNumber}/store
    Response contains a set-cookie header with the jsessionId associated with the cart.
    Request Method = PUT
    placeOrder(javax.servlet.http.HttpSession session)
    Web service for placing order from current session cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/placeorder.
    Web service for removing voucher from cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/voucher/abc-9PSW-EDH2-RXKA
    This method requires authentication.
    Method type : DELETE.
    Method is restricted for HTTPS channel.
    Web service for removing delivery address from current cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/address/delivery
    Response contains a set-cookie header with the jsessionId associated with the cart.
    This method requires authentication.
    Method type : DELETE.
    Method is restricted for HTTPS channel.
    Web service for removing delivery mode from current cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/deliverymode
    Response contains a set-cookie header with the jsessionId associated with the cart.
    This method requires authentication.
    Method type : DELETE.
    Method is restricted for HTTPS channel.
    removePromotion(String promotionCode)
    Web service for disabling order promotions.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/promotion/{promotionCode}
    This method requires authentication and is restricted to HTTPS channel only.
    Method type : DELETE.
    Web service for restoring anonymous cart by guid.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/restore
    This method requires authentication and is restricted to HTTPS channel only.
    Method type : GET.
    Web service for setting cart's delivery address by address id.
    Address id must be given as path variable.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/address/delivery/1234
    Response contains a set-cookie header with the jsessionId associated with the cart.
    This method requires authentication.
    Method type : PUT.
    Method is restricted for HTTPS channel.
    Web service for setting cart's delivery mode by delivery mode code.
    Delivery mode code must be given as path variable.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/deliverymode/expressDelivery
    Response contains a set-cookie header with the jsessionId associated with the cart.
    This method requires authentication.
    Method type : PUT.
    Method is restricted for HTTPS channel.
    Web service for assigning given payment (by payment id) to the checkout cart.
    Sample call: https://localhost:9002/rest/v1/mysite/cart/paymentinfo/1234
    This method requires authentication and is restricted for HTTPS channel.
    Method type : PUT.
    updateCartEntry(long entryNumber, long qty)
    Web service for modifying cart entry quantity.
    Client should provide cart entry number as path variable and new quantity as url request parameter.
    Sample target URL : http://localhost:9001/rest/v1/cart/entry/0?qty=2
    Response contains a set-cookie header with the jsessionId associated with the cart.
    Request Method = PUT
    updateEntryToDelivery(String baseSiteId, long entryNumber)
    Web service reseting store where entry should be picked up.
    protected void
     

    Methods inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController

    handleErrorInternal, handleModelNotFoundException, sanitize

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CartController

      public CartController()
  • Method Details

    • getSessionCart

      public CartData getSessionCart()
    • getSessionCart

      @RequestMapping(method=GET) @ResponseBody public CartData getSessionCart(@RequestParam(required=false,defaultValue="true") boolean restore)
      Web service for getting session cart. If there is no cart in the current session it will be restored if possible, otherwise new one will be created.
      Sample call: http://localhost:9001/rest/v1/mysite/cart/
      Response contains a set-cookie header with the jsessionId associated with the cart.
      Parameters:
      restore - enables cart restoration (true by default)
      Returns:
      CartData as response body.
    • addToCart

      @RequestMapping(value="/entry", method=POST) @ResponseBody public CartModificationData addToCart(@PathVariable String baseSiteId, @RequestParam(required=true) String code, @RequestParam(required=false,defaultValue="1") long qty, @RequestParam(required=false) String storeName) throws CommerceCartModificationException, WebserviceValidationException, ProductLowStockException, StockSystemException
      Web service handler for adding new products to the session cart.
      Sample target URL : http://localhost:9001/rest/v1/cart/entry.
      Client should provide product code and quantity (optional) as POST body.
      It's also possible to add product that will be pickedup in store by specifying optional storeName parameter (product must be in stock in that particular store).
      For Content-Type=application/x-www-form-urlencoded;charset=UTF-8 a sample body is: (urlencoded) is: entryNumber=1&qty=2..
      Request Method = POST Response contains a set-cookie header with the jsessionId associated with the cart.
      Parameters:
      code -
      qty -
      storeName -
      Returns:
      CartModificationData as response body.
      Throws:
      CommerceCartModificationException
      WebserviceValidationException
      StockSystemException
      ProductLowStockException
    • updateCartEntry

      @RequestMapping(value="/entry/{entryNumber}", method=PUT) @ResponseBody public CartModificationData updateCartEntry(@PathVariable long entryNumber, @RequestParam(required=true) long qty) throws CommerceCartModificationException
      Web service for modifying cart entry quantity.
      Client should provide cart entry number as path variable and new quantity as url request parameter.
      Sample target URL : http://localhost:9001/rest/v1/cart/entry/0?qty=2
      Response contains a set-cookie header with the jsessionId associated with the cart.
      Request Method = PUT
      Parameters:
      entryNumber -
      qty -
      Returns:
      CartModificationData as response body.
      Throws:
      CommerceCartModificationException
    • deleteCartEntry

      @RequestMapping(value="/entry/{entryNumber}", method=DELETE) @ResponseBody public CartModificationData deleteCartEntry(@PathVariable long entryNumber) throws CommerceCartModificationException
      Web service for deleting cart entry.
      Client should provide cart entry number as path variable.
      Sample target URL : http://localhost:9001/rest/v1/cart/entry/0
      Response contains a set-cookie header with the jsessionId associated with the cart.
      Request Method = DELETE
      Parameters:
      entryNumber -
      Returns:
      CartModificationData as response body.
      Throws:
      CommerceCartModificationException
    • pickupEntryInStore

      @RequestMapping(value="/entry/{entryNumber}/store", method=PUT) @ResponseBody public CartModificationData pickupEntryInStore(@PathVariable String baseSiteId, @PathVariable long entryNumber, @RequestParam(required=true) String storeName) throws CommerceCartModificationException, LowStockException, StockSystemException, WebserviceValidationException
      Web service for setting store where cart entry will be picked up.
      Client should provide cart entry number as path variable and storeName parameter in body.
      Sample target URL : http://localhost:9001/rest/v1/cart/entry/{entryNumber}/store
      Response contains a set-cookie header with the jsessionId associated with the cart.
      Request Method = PUT
      Parameters:
      entryNumber - identifier of entry which should be updated
      storeName - name of store where items will be picked
      Returns:
      CartModificationData as response body.
      Throws:
      CommerceCartModificationException
      WebserviceValidationException
      StockSystemException
      LowStockException
    • updateEntryToDelivery

      @RequestMapping(value="/entry/{entryNumber}/store", method=DELETE) @ResponseBody public CartModificationData updateEntryToDelivery(@PathVariable String baseSiteId, @PathVariable long entryNumber) throws CommerceCartModificationException, LowStockException, StockSystemException
      Web service reseting store where entry should be picked up. Entry will be delivered by selected delivery method
      Client should provide cart entry number as path variable.
      Sample target URL : http://localhost:9001/rest/v1/cart/entry/{entryNumber}/store
      Request Method = DELETE
      Parameters:
      entryNumber - identifier of entry which should be updated
      Returns:
      CartModificationData as response body.
      Throws:
      CommerceCartModificationException
      StockSystemException
      LowStockException
    • setCartDeliveryAddress

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/address/delivery/{id}", method=PUT) @ResponseBody public CartData setCartDeliveryAddress(@PathVariable String id) throws UnsupportedDeliveryAddressException, NoCheckoutCartException
      Web service for setting cart's delivery address by address id.
      Address id must be given as path variable.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/address/delivery/1234
      Response contains a set-cookie header with the jsessionId associated with the cart.
      This method requires authentication.
      Method type : PUT.
      Method is restricted for HTTPS channel.
      Returns:
      true if carts delivery address was changed.
      Throws:
      UnsupportedDeliveryAddressException
      NoCheckoutCartException
    • removeDeliveryAddress

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/address/delivery", method=DELETE) @ResponseBody public CartData removeDeliveryAddress()
      Web service for removing delivery address from current cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/address/delivery
      Response contains a set-cookie header with the jsessionId associated with the cart.
      This method requires authentication.
      Method type : DELETE.
      Method is restricted for HTTPS channel.
      Returns:
      true if carts delivery address was removed.
    • setCartDeliveryMode

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/deliverymodes/{code}", method=PUT) @ResponseBody public CartData setCartDeliveryMode(@PathVariable String code) throws UnsupportedDeliveryModeException
      Web service for setting cart's delivery mode by delivery mode code.
      Delivery mode code must be given as path variable.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/deliverymode/expressDelivery
      Response contains a set-cookie header with the jsessionId associated with the cart.
      This method requires authentication.
      Method type : PUT.
      Method is restricted for HTTPS channel.
      Returns:
      true if carts delivery mode was changed.
      Throws:
      UnsupportedDeliveryModeException
    • removeDeliveryMode

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/deliverymodes", method=DELETE) @ResponseBody public CartData removeDeliveryMode()
      Web service for removing delivery mode from current cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/deliverymode
      Response contains a set-cookie header with the jsessionId associated with the cart.
      This method requires authentication.
      Method type : DELETE.
      Method is restricted for HTTPS channel.
      Returns:
      true if cart's delivery mode was removed.
    • placeOrder

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/placeorder", method=POST) @ResponseBody public OrderData placeOrder(javax.servlet.http.HttpSession session) throws InvalidCartException, NoCheckoutCartException, WebserviceValidationException
      Web service for placing order from current session cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/placeorder.
      This method requires authentication.
      Method type : POST.
      Method is restricted for HTTPS channel.
      Returns:
      OrderData as response body
      Throws:
      InvalidCartException
      NoCheckoutCartException
      WebserviceValidationException
    • validateCartForPlaceOrder

      protected void validateCartForPlaceOrder() throws NoCheckoutCartException, InvalidCartException, WebserviceValidationException
      Throws:
      NoCheckoutCartException
      InvalidCartException
      WebserviceValidationException
    • addPaymentInfo

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/paymentinfo", method=POST) @ResponseBody public CartData addPaymentInfo(javax.servlet.http.HttpServletRequest request) throws WebserviceValidationException, InvalidPaymentInfoException, NoCheckoutCartException
      Web service for creating a credit card payment subscription.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/paymentinfo
      CCPaymentInfoData parameters need to be send as post body.
      Method uses dedicated populator - HttpRequestPaymentInfoPopulator - to populate the CCPaymentInfoData from request parameters.
      Method uses dedicated validator - CCPaymentInfoValidator - to validate request parameters.
      This method requires authentication and is restricted for HTTPS channel.
      Method type : POST.
      Parameters:
      request - incoming HttpServletRequest. As there are many potential query parameters to handle they are not mapped using annotations.
      Returns:
      CartData as response body
      Throws:
      WebserviceValidationException
      InvalidPaymentInfoException
      NoCheckoutCartException
    • setPaymentDetails

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/paymentinfo/{id}", method=PUT) @ResponseBody public CartData setPaymentDetails(@PathVariable String id) throws InvalidPaymentInfoException
      Web service for assigning given payment (by payment id) to the checkout cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/paymentinfo/1234
      This method requires authentication and is restricted for HTTPS channel.
      Method type : PUT.
      Returns:
      true if paymentInfo was assigned to the session cart.
      Throws:
      InvalidPaymentInfoException
    • getSupportedDeliveryModes

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/deliverymodes", method=GET) @ResponseBody public DeliveryModesData getSupportedDeliveryModes()
      Web service for getting all supported delivery modes for the session cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/deliverymodes
      Response contains a set-cookie header with the jsessionId associated with the cart.
      This method requires authentication and is restricted to HTTPS channel only.
      Method type : GET.
      Returns:
      List of DeliveryModeData as response body.
    • authorizePayment

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/authorize", method=POST) @ResponseBody @ResponseStatus(ACCEPTED) public CartData authorizePayment(@RequestParam(required=true) String securityCode) throws PaymentAuthorizationException
      Web service for authorizing cart's credit cart payment.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/authorizePayment
      authorization security code - ccv - must be sent as a post body.
      Response contains a set-cookie header with the jsessionId associated with the cart.
      This method requires authentication and is restricted to HTTPS channel only.
      Method type : POST.
      Returns:
      true if the payment was authorized
      Throws:
      PaymentAuthorizationException
    • restoreCart

      @Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"}) @RequestMapping(value="/restore", method=GET) @ResponseBody public CartRestorationData restoreCart(@RequestParam String guid) throws CommerceCartRestorationException
      Web service for restoring anonymous cart by guid.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/restore
      This method requires authentication and is restricted to HTTPS channel only.
      Method type : GET.
      Parameters:
      guid -
      Returns:
      CartRestorationData
      Throws:
      CommerceCartRestorationException
    • applyPromotion

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_TRUSTED_CLIENT"}) @RequestMapping(value="/promotion/{promotionCode}", method=POST) @ResponseBody public CartData applyPromotion(@PathVariable String promotionCode) throws CommercePromotionRestrictionException
      Web service for enabling order promotions.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/promotion/{promotionCode}
      This method requires authentication and is restricted to HTTPS channel only.
      Method type : POST.
      Parameters:
      promotionCode - promotion code
      Returns:
      CartData
      Throws:
      CommercePromotionRestrictionException
    • removePromotion

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_TRUSTED_CLIENT"}) @RequestMapping(value="/promotion/{promotionCode}", method=DELETE) @ResponseBody public CartData removePromotion(@PathVariable String promotionCode) throws CommercePromotionRestrictionException, NoCheckoutCartException
      Web service for disabling order promotions.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/promotion/{promotionCode}
      This method requires authentication and is restricted to HTTPS channel only.
      Method type : DELETE.
      Parameters:
      promotionCode - promotion code
      Returns:
      CartData
      Throws:
      CommercePromotionRestrictionException
      NoCheckoutCartException
    • applyVoucherForCart

      @Secured({"ROLE_CLIENT","ROLE_CUSTOMERGROUP","ROLE_TRUSTED_CLIENT","ROLE_GUEST"}) @RequestMapping(value="/voucher/{voucherCode}", method=POST) @ResponseBody public CartData applyVoucherForCart(@PathVariable String voucherCode) throws NoCheckoutCartException, VoucherOperationException
      Web service for applying voucher to cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/voucher/abc-9PSW-EDH2-RXKA
      This method requires authentication.
      Method type : POST.
      Method is restricted for HTTPS channel.
      Returns:
      cart data with applied voucher.
      Throws:
      NoCheckoutCartException
      VoucherOperationException
    • releaseVoucherFromCart

      @Secured({"ROLE_CLIENT","ROLE_CUSTOMERGROUP","ROLE_TRUSTED_CLIENT","ROLE_GUEST"}) @RequestMapping(value="/voucher/{voucherCode}", method=DELETE) @ResponseBody public CartData releaseVoucherFromCart(@PathVariable String voucherCode) throws NoCheckoutCartException, VoucherOperationException
      Web service for removing voucher from cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/voucher/abc-9PSW-EDH2-RXKA
      This method requires authentication.
      Method type : DELETE.
      Method is restricted for HTTPS channel.
      Returns:
      updated cart data.
      Throws:
      NoCheckoutCartException
      VoucherOperationException
    • oneStepCheckout

      @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/checkout", method=POST) @ResponseBody public OrderData oneStepCheckout(@RequestParam(required=false) String addressId, @RequestParam(value="country.isocode",required=false) String addressIsocode, @RequestParam String deliveryMode, @RequestParam(required=false) String voucherCode, @RequestParam(required=false) String paymentInfoId, @RequestParam String securityCode, javax.servlet.http.HttpServletRequest request) throws NoCheckoutCartException, UnsupportedDeliveryAddressException, UnsupportedDeliveryModeException, InvalidPaymentInfoException, PaymentAuthorizationException, InvalidCartException, WebserviceValidationException, VoucherOperationException
      Web service for one-step checkout from current session cart.
      Sample call: https://localhost:9002/rest/v1/mysite/cart/checkout
      This method requires authentication.
      Method type : POST.
      Method is restricted for HTTPS channel.
      Parameters:
      addressId - id of created address
      addressIsocode - country isocode, parameter is also used as a flag to decide if new address should be created
      deliveryMode - delivery mode
      voucherCode - voucher code
      paymentInfoId - id of created payment info
      securityCode - security code for payment validation
      request - incoming HttpServletRequest. As there are many potential query parameters to handle they are not mapped using annotations.
      Returns:
      OrderData
      Throws:
      NoCheckoutCartException
      UnsupportedDeliveryAddressException
      UnsupportedDeliveryModeException
      InvalidPaymentInfoException
      PaymentAuthorizationException
      InvalidCartException
      WebserviceValidationException
      VoucherOperationException
    • getCartEntryForNumber

      protected OrderEntryData getCartEntryForNumber(long number)
    • createAddress

      protected AddressData createAddress(javax.servlet.http.HttpServletRequest request)