-
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.
AD-254 Develop New Endpoint in OCC to Handle PaymentDetailsRequest an…
…d Return PaymentDetailsResponse
- Loading branch information
Showing
14 changed files
with
105 additions
and
30 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
3 changes: 1 addition & 2 deletions
3
...eratoraddon/web/src/com/adyen/commerce/controllers/api/AdyenDeliveryAddressContoller.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
3 changes: 1 addition & 2 deletions
3
...ratoraddon/web/src/com/adyen/commerce/controllers/api/AdyenDeliveryMethodsController.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
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
2 changes: 1 addition & 1 deletion
2
...src/com/adyen/commerce/controllers/exceptionhandlers/AdyenControllerExceptionHandler.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
46 changes: 46 additions & 0 deletions
46
adyenocc/src/com/adyen/commerce/controllers/PlaceOrderController.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,46 @@ | ||
package com.adyen.commerce.controllers; | ||
|
||
import com.adyen.commerce.constants.AdyenoccConstants; | ||
import com.adyen.commerce.controllerbase.PlaceOrderControllerBase; | ||
import com.adyen.commerce.facades.AdyenCheckoutApiFacade; | ||
import com.adyen.commerce.response.PlaceOrderResponse; | ||
import com.adyen.model.checkout.PaymentDetailsRequest; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import de.hybris.platform.commerceservices.request.mapping.annotation.ApiVersion; | ||
import de.hybris.platform.webservicescommons.swagger.ApiBaseSiteIdUserIdAndCartIdParam; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Controller | ||
@RequestMapping(value = AdyenoccConstants.ADYEN_USER_CART_PREFIX) | ||
@ApiVersion("v2") | ||
@Tag(name = "Adyen") | ||
public class PlaceOrderController extends PlaceOrderControllerBase { | ||
|
||
@Autowired | ||
private AdyenCheckoutApiFacade adyenCheckoutApiFacade; | ||
|
||
|
||
@PostMapping(value = "/additional-details", produces= MediaType.APPLICATION_JSON_VALUE) | ||
@Operation(operationId = "additionalDetails", summary = "Handle additional details action", description = | ||
"Places pending order based on additional details request") | ||
@ApiBaseSiteIdUserIdAndCartIdParam | ||
public ResponseEntity<String> onAdditionalDetails(@RequestBody PaymentDetailsRequest detailsRequest) throws JsonProcessingException { | ||
PlaceOrderResponse placeOrderResponse = handleAdditionalDetails(detailsRequest); | ||
|
||
String response = objectMapper.writeValueAsString(placeOrderResponse); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
@Override | ||
public AdyenCheckoutApiFacade getAdyenCheckoutApiFacade() { | ||
return adyenCheckoutApiFacade; | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
adyenocc/src/com/adyen/commerce/exception/AdyenOCCControllerException.java
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
adyenocc/src/com/adyen/commerce/exceptionhandler/AdyenOCCControllerExceptionHandler.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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
package com.adyen.commerce.exceptionhandler; | ||
|
||
import com.adyen.commerce.exception.AdyenOCCControllerException; | ||
import com.adyen.commerce.exception.AdyenControllerException; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class AdyenOCCControllerExceptionHandler { | ||
|
||
@ExceptionHandler(value = AdyenOCCControllerException.class) | ||
public ResponseEntity<Void> handleAdyenControllerException(AdyenOCCControllerException exception) { | ||
@ExceptionHandler(value = AdyenControllerException.class) | ||
public ResponseEntity<Void> handleAdyenControllerException(AdyenControllerException exception) { | ||
return ResponseEntity.badRequest().build(); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
adyenwebcommons/src/com/adyen/commerce/controllerbase/PlaceOrderControllerBase.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,35 @@ | ||
package com.adyen.commerce.controllerbase; | ||
|
||
import com.adyen.commerce.exception.AdyenControllerException; | ||
import com.adyen.commerce.facades.AdyenCheckoutApiFacade; | ||
import com.adyen.commerce.response.PlaceOrderResponse; | ||
import com.adyen.model.checkout.PaymentDetailsRequest; | ||
import com.adyen.service.exception.ApiException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import de.hybris.platform.commercefacades.order.data.OrderData; | ||
import org.apache.log4j.Logger; | ||
|
||
import static com.adyen.commerce.constants.AdyenwebcommonsConstants.CHECKOUT_ERROR_AUTHORIZATION_FAILED; | ||
|
||
public abstract class PlaceOrderControllerBase { | ||
private static final Logger LOGGER = Logger.getLogger(PlaceOrderControllerBase.class); | ||
protected static final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
|
||
public PlaceOrderResponse handleAdditionalDetails(final PaymentDetailsRequest paymentDetailsRequest) { | ||
try { | ||
OrderData orderData = getAdyenCheckoutApiFacade().placeOrderWithAdditionalDetails(paymentDetailsRequest); | ||
PlaceOrderResponse placeOrderResponse = new PlaceOrderResponse(); | ||
placeOrderResponse.setOrderNumber(orderData.getCode()); | ||
return placeOrderResponse; | ||
} catch (ApiException e) { | ||
LOGGER.error("ApiException: " + e); | ||
throw new AdyenControllerException(CHECKOUT_ERROR_AUTHORIZATION_FAILED); | ||
} catch (Exception e) { | ||
LOGGER.error("Exception", e); | ||
throw new AdyenControllerException(CHECKOUT_ERROR_AUTHORIZATION_FAILED); | ||
} | ||
} | ||
|
||
public abstract AdyenCheckoutApiFacade getAdyenCheckoutApiFacade(); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../exceptions/AdyenControllerException.java → ...e/exception/AdyenControllerException.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
File renamed without changes.
File renamed without changes.