-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #515 from Adyen/feature/AD-374
Feature/ad 374
- Loading branch information
Showing
13 changed files
with
518 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...eratoraddon/web/src/com/adyen/v6/controllers/checkout/AdyenExpressCheckoutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.adyen.v6.controllers.checkout; | ||
|
||
import com.adyen.v6.controllers.checkout.dto.CartDataDTO; | ||
import com.adyen.v6.facades.AdyenExpressCheckoutFacade; | ||
import de.hybris.platform.commercefacades.order.CartFacade; | ||
import de.hybris.platform.commercefacades.order.data.CartData; | ||
import de.hybris.platform.commercefacades.order.data.DeliveryModeData; | ||
import de.hybris.platform.commercefacades.user.data.AddressData; | ||
import de.hybris.platform.order.InvalidCartException; | ||
import de.hybris.platform.order.exceptions.CalculationException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.util.List; | ||
|
||
|
||
@Controller | ||
@RequestMapping("/express-checkout/configure/") | ||
public class AdyenExpressCheckoutController { | ||
|
||
@Autowired | ||
private AdyenExpressCheckoutFacade adyenExpressCheckoutFacade; | ||
|
||
@Autowired | ||
private CartFacade cartFacade; | ||
|
||
@GetMapping("cart") | ||
public ResponseEntity<CartDataDTO> getCartForExpressCheckout(final HttpServletRequest request, final HttpServletResponse response){ | ||
CartData cartForExpressCheckout = cartFacade.getSessionCart(); | ||
return ResponseEntity.ok(populateCartDataDto(cartForExpressCheckout)); | ||
} | ||
|
||
@PostMapping("create-cart/{productCode}") | ||
public ResponseEntity<CartDataDTO> createCartForExpressCheckout(final HttpServletRequest request, final HttpServletResponse response, @PathVariable("productCode") String productCode){ | ||
CartData cartForExpressCheckout = adyenExpressCheckoutFacade.createOrGetCartForExpressCheckout(productCode); | ||
return ResponseEntity.ok(populateCartDataDto(cartForExpressCheckout)); | ||
} | ||
|
||
@PostMapping("{cartId}/addresses/delivery") | ||
@ResponseBody | ||
public ResponseEntity createCartDeliveryAddress(final HttpServletRequest request, final HttpServletResponse response, @PathVariable("cartId") String cartId, final @RequestBody AddressData addressData) | ||
{ | ||
adyenExpressCheckoutFacade.setDeliveryAddressForCart(addressData, cartId); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@PostMapping("{cartId}/product/{productCode}/quantity/{quantity}") | ||
public ResponseEntity setProductForExpressCheckout(final HttpServletRequest request, final HttpServletResponse response, @PathVariable("cartId") String cartId, @PathVariable("productCode") String productCode, @PathVariable("quantity") Integer quantity) throws CalculationException { | ||
adyenExpressCheckoutFacade.prepareCartForExpressCheckoutWithProduct(cartId, productCode, quantity); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@GetMapping("{cartId}/delivery-methods") | ||
public ResponseEntity<List<DeliveryModeData>> getDeliveryMethods(final HttpServletRequest request, final HttpServletResponse response, @PathVariable("cartId") String cartId){ | ||
return ResponseEntity.ok().body(adyenExpressCheckoutFacade.getDeliveryModes(cartId)); | ||
} | ||
|
||
@PostMapping("{cartId}/delivery-method/{deliveryMethodId}") | ||
public ResponseEntity<CartDataDTO> setDeliveryMethod(final HttpServletRequest request, final HttpServletResponse response, @PathVariable("cartId") String cartId, @PathVariable("deliveryMethodId") String deliveryMethodId) throws CalculationException { | ||
CartData cartForExpressCheckout = adyenExpressCheckoutFacade.setDeliveryModeForCart(deliveryMethodId, cartId); | ||
return ResponseEntity.ok(populateCartDataDto(cartForExpressCheckout)); | ||
} | ||
|
||
private static CartDataDTO populateCartDataDto(CartData cartForExpressCheckout) { | ||
CartDataDTO cartDataDTO = new CartDataDTO(); | ||
cartDataDTO.setCode(cartForExpressCheckout.getCode()); | ||
cartDataDTO.setTotalPriceWithTax(cartForExpressCheckout.getTotalPriceWithTax()); | ||
return cartDataDTO; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...koutaddon/acceleratoraddon/web/src/com/adyen/v6/controllers/checkout/dto/CartDataDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.adyen.v6.controllers.checkout.dto; | ||
|
||
import de.hybris.platform.commercefacades.product.data.PriceData; | ||
|
||
public class CartDataDTO { | ||
private String code; | ||
private PriceData totalPriceWithTax; | ||
|
||
// Getters and Setters | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public PriceData getTotalPriceWithTax() { | ||
return totalPriceWithTax; | ||
} | ||
|
||
public void setTotalPriceWithTax(PriceData totalPriceWithTax) { | ||
this.totalPriceWithTax = totalPriceWithTax; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.