Class CartController


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

      Constructors 
      Constructor Description
      CartController()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CartData 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.
      CartModificationData addToCart​(java.lang.String baseSiteId, java.lang.String code, long qty, java.lang.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.
      CartData applyPromotion​(java.lang.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.
      CartData applyVoucherForCart​(java.lang.String voucherCode)
      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.
      CartData authorizePayment​(java.lang.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)  
      CartModificationData 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)  
      CartData getSessionCart()  
      CartData getSessionCart​(boolean restore)
      Web service for getting session cart.
      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.
      OrderData oneStepCheckout​(java.lang.String addressId, java.lang.String addressIsocode, java.lang.String deliveryMode, java.lang.String voucherCode, java.lang.String paymentInfoId, java.lang.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.
      CartModificationData pickupEntryInStore​(java.lang.String baseSiteId, long entryNumber, java.lang.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
      OrderData 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.
      CartData releaseVoucherFromCart​(java.lang.String voucherCode)
      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.
      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.
      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.
      CartData removePromotion​(java.lang.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.
      CartRestorationData restoreCart​(java.lang.String guid)
      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.
      CartData setCartDeliveryAddress​(java.lang.String id)
      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.
      CartData setCartDeliveryMode​(java.lang.String code)
      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.
      CartData setPaymentDetails​(java.lang.String id)
      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.
      CartModificationData 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
      CartModificationData updateEntryToDelivery​(java.lang.String baseSiteId, long entryNumber)
      Web service reseting store where entry should be picked up.
      protected void validateCartForPlaceOrder()  
      • Methods inherited from class java.lang.Object

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

      • CartController

        public CartController()
    • Method Detail

      • 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.
      • 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
      • setCartDeliveryAddress

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/address/delivery/{id}",
                        method=PUT)
        @ResponseBody
        public CartData setCartDeliveryAddress​(@PathVariable
                                               java.lang.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
                                            java.lang.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.
      • setPaymentDetails

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/paymentinfo/{id}",
                        method=PUT)
        @ResponseBody
        public CartData setPaymentDetails​(@PathVariable
                                          java.lang.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)
                                         java.lang.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
                                               java.lang.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
                                       java.lang.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
      • applyVoucherForCart

        @Secured({"ROLE_CLIENT","ROLE_CUSTOMERGROUP","ROLE_TRUSTED_CLIENT","ROLE_GUEST"})
        @RequestMapping(value="/voucher/{voucherCode}",
                        method=POST)
        @ResponseBody
        public CartData applyVoucherForCart​(@PathVariable
                                            java.lang.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
                                               java.lang.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
      • getCartEntryForNumber

        protected OrderEntryData getCartEntryForNumber​(long number)
      • createAddress

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