Class CartController
- 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 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 theCCPaymentInfoData
from request parameters.
Method uses dedicated validator -CCPaymentInfoValidator
- to validate request parameters.
This method requires authentication and is restricted forHTTPS
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 toHTTPS
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 forHTTPS
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 toHTTPS
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 toHTTPS
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 forHTTPS
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 forHTTPS
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 forHTTPS
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 forHTTPS
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 toHTTPS
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 toHTTPS
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 forHTTPS
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 forHTTPS
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 forHTTPS
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 de.hybris.platform.ycommercewebservices.v1.controller.BaseController
handleErrorInternal, handleModelNotFoundException, sanitize
-
-
-
-
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.
-
addToCart
@RequestMapping(value="/entry", method=POST) @ResponseBody public CartModificationData addToCart(@PathVariable java.lang.String baseSiteId, @RequestParam(required=true) java.lang.String code, @RequestParam(required=false,defaultValue="1") long qty, @RequestParam(required=false) java.lang.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 java.lang.String baseSiteId, @PathVariable long entryNumber, @RequestParam(required=true) java.lang.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 updatedstoreName
- 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 java.lang.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 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 forHTTPS
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 forHTTPS
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 forHTTPS
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 forHTTPS
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 forHTTPS
channel.- Returns:
OrderData
as response body- Throws:
InvalidCartException
NoCheckoutCartException
WebserviceValidationException
-
validateCartForPlaceOrder
protected void validateCartForPlaceOrder() 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 theCCPaymentInfoData
from request parameters.
Method uses dedicated validator -CCPaymentInfoValidator
- to validate request parameters.
This method requires authentication and is restricted forHTTPS
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 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 forHTTPS
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 toHTTPS
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 toHTTPS
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 toHTTPS
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 toHTTPS
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 java.lang.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 toHTTPS
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 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 forHTTPS
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 forHTTPS
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) java.lang.String addressId, @RequestParam(value="country.isocode",required=false) java.lang.String addressIsocode, @RequestParam java.lang.String deliveryMode, @RequestParam(required=false) java.lang.String voucherCode, @RequestParam(required=false) java.lang.String paymentInfoId, @RequestParam java.lang.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 forHTTPS
channel.- Parameters:
addressId
- id of created addressaddressIsocode
- country isocode, parameter is also used as a flag to decide if new address should be createddeliveryMode
- delivery modevoucherCode
- voucher codepaymentInfoId
- id of created payment infosecurityCode
- security code for payment validationrequest
- 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)
-
-