Skip to content

Commit

Permalink
AD-244 Develop OCC Endpoint for Retrieving Adyen Payment Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaneta committed May 10, 2024
1 parent 5155352 commit e592635
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 28 deletions.
3 changes: 2 additions & 1 deletion adyenocc/extensioninfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


<requires-extension name="commercewebservices"/>

<requires-extension name="adyenv6core"/>


<coremodule generated="true" manager="com.adyen.commerce.jalo.AdyenoccManager" packageroot="com.adyen.commerce"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
public class AdyenoccConstants extends GeneratedAdyenoccConstants
{
public static final String EXTENSIONNAME = "adyenocc";
public static final String ADYEN_USER_CART_PREFIX = "/{baseSiteId}/users/{userId}/carts/{cartId}/adyen";
public static final String ADYEN_USER_PREFIX = "/{baseSiteId}/users/{userId}/adyen";

private AdyenoccConstants()
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved.
*/
package com.adyen.commerce.controllers;

import com.adyen.commerce.constants.AdyenoccConstants;
import com.adyen.service.exception.ApiException;
import com.adyen.v6.dto.CheckoutConfigDTO;
import com.adyen.v6.facades.AdyenCheckoutFacade;
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.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value = AdyenoccConstants.ADYEN_USER_CART_PREFIX)
@ApiVersion("v2")
@Tag(name = "Adyen")
public class PaymentMethodsController
{
@Autowired
private AdyenCheckoutFacade adyenCheckoutFacade;

@GetMapping(value = "/checkout-configuration")
@Operation(operationId = "getCheckoutConfiguration", summary = "Get checkout configuration", description =
"Returns configuration for Adyen dropin component")
@ApiBaseSiteIdUserIdAndCartIdParam
public ResponseEntity<CheckoutConfigDTO> getCheckoutConfiguration() throws ApiException {
return ResponseEntity.ok().body(adyenCheckoutFacade.getReactCheckoutConfig());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.adyen.commerce.exception;

public class AdyenOCCControllerException extends RuntimeException {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.adyen.commerce.exceptionhandler;

import com.adyen.commerce.exception.AdyenOCCControllerException;
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) {
return ResponseEntity.badRequest().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//Set the allowed cards
const allowedCards = [];
<c:forEach items="${allowedCards}" var="allowedCard">
allowedCards.push("${allowedCard.code}");
allowedCards.push("${allowedCard}");
</c:forEach>
const initConfig = {
Expand Down
6 changes: 3 additions & 3 deletions adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CheckoutConfigDTO {
@Deprecated
private String creditCardLabel;
@Deprecated
private List<AdyenCardTypeEnum> allowedCards;
private List<String> allowedCards;
private Amount amount;
private String adyenClientKey;
private String adyenPaypalMerchantId;
Expand Down Expand Up @@ -82,11 +82,11 @@ public void setCreditCardLabel(String creditCardLabel) {
this.creditCardLabel = creditCardLabel;
}

public List<AdyenCardTypeEnum> getAllowedCards() {
public List<String> getAllowedCards() {
return allowedCards;
}

public void setAllowedCards(List<AdyenCardTypeEnum> allowedCards) {
public void setAllowedCards(List<String> allowedCards) {
this.allowedCards = allowedCards;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CheckoutConfigDTOBuilder {

private final CheckoutConfigDTO checkoutConfigDTO;

public CheckoutConfigDTOBuilder(){
public CheckoutConfigDTOBuilder() {
checkoutConfigDTO = new CheckoutConfigDTO();
}

Expand Down Expand Up @@ -49,7 +49,8 @@ public CheckoutConfigDTOBuilder setCreditCardLabel(String creditCardLabel) {
}

public CheckoutConfigDTOBuilder setAllowedCards(List<AdyenCardTypeEnum> allowedCards) {
checkoutConfigDTO.setAllowedCards(allowedCards);
List<String> mappedAllowedCards = allowedCards.stream().map(AdyenCardTypeEnum::toString).toList();
checkoutConfigDTO.setAllowedCards(mappedAllowedCards);
return this;
}

Expand Down

0 comments on commit e592635

Please sign in to comment.