Skip to content

Commit

Permalink
Merge pull request #416 from Adyen/feature/AD-251
Browse files Browse the repository at this point in the history
Feature/ad 251
  • Loading branch information
pjaneta authored May 27, 2024
2 parents 575ab49 + 0a8eda5 commit 015604f
Show file tree
Hide file tree
Showing 19 changed files with 523 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.adyen.commerce.controllers.api;

import com.adyen.commerce.controllerbase.RedirectControllerBase;
import com.adyen.model.checkout.PaymentDetailsRequest;
import com.adyen.v6.facades.AdyenCheckoutFacade;
import de.hybris.platform.acceleratorstorefrontcommons.annotations.RequireHardLogIn;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Base64;

import static com.adyen.commerce.constants.AdyencheckoutaddonapiWebConstants.*;
import static de.hybris.platform.acceleratorstorefrontcommons.controllers.AbstractController.REDIRECT_PREFIX;

@Controller
@RequestMapping(value = ADYEN_CHECKOUT_API_PREFIX)
public class AdyenRedirectResponseController extends RedirectControllerBase {
private static final String SELECT_PAYMENT_METHOD_URL = ADYEN_CHECKOUT_PAGE_PREFIX + ADYEN_CHECKOUT_SELECT_PAYMENT;
private static final String ORDER_CONFIRMATION_URL = ADYEN_CHECKOUT_PAGE_PREFIX + ADYEN_CHECKOUT_ORDER_CONFIRMATION;

@Resource(name = "adyenCheckoutFacade")
private AdyenCheckoutFacade adyenCheckoutFacade;

@GetMapping(value = AUTHORISE_3D_SECURE_PAYMENT_URL)
@RequireHardLogIn
public String authoriseRedirectGetPayment(final HttpServletRequest request) {
return super.authoriseRedirectGetPayment(request);
}


@PostMapping(value = AUTHORISE_3D_SECURE_PAYMENT_URL)
@RequireHardLogIn
public String authoriseRedirectPostPayment(@RequestBody PaymentDetailsRequest detailsRequest) {
return super.authoriseRedirectPostPayment(detailsRequest);
}

@Override
public String getErrorRedirectUrl(String errorMessage) {
return REDIRECT_PREFIX + SELECT_PAYMENT_METHOD_URL + "/error/" + Base64.getUrlEncoder().encodeToString(errorMessage.getBytes());
}

@Override
public String getOrderConfirmationUrl(String orderCode) {
return REDIRECT_PREFIX + ORDER_CONFIRMATION_URL + '/' + orderCode;
}

@Override
public String getCartUrl() {
return REDIRECT_PREFIX + CART_PREFIX;
}

@Override
public AdyenCheckoutFacade getAdyenCheckoutFacade() {
return adyenCheckoutFacade;
}

}
2 changes: 1 addition & 1 deletion adyencheckoutaddonapi/extensioninfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


<requires-extension name="addonsupport"/>
<requires-extension name="adyenv6core"/>
<requires-extension name="adyenwebcommons"/>


<coremodule generated="true" manager="com.adyen.commerce.jalo.AdyencheckoutaddonapiManager" packageroot="com.adyen.commerce"/>
Expand Down
2 changes: 1 addition & 1 deletion adyenocc/extensioninfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


<requires-extension name="commercewebservices"/>
<requires-extension name="adyenv6core"/>
<requires-extension name="adyenwebcommons"/>


<coremodule generated="true" manager="com.adyen.commerce.jalo.AdyenoccManager" packageroot="com.adyen.commerce"/>
Expand Down
2 changes: 2 additions & 0 deletions adyenocc/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ adyenocc.application-context=adyenocc-spring.xml
#Use for generating static swagger documentation
adyenocc.documentation.static.generate=true
ext.adyenocc.extension.webmodule.webroot=/occ/v2

adyen.spartacus.baseurl=https://electronics.local:9002/spartacus
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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";
public static final String ADYEN_PREFIX = "/{baseSiteId}/adyen";

private AdyenoccConstants()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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.commerce.controllerbase.RedirectControllerBase;
import com.adyen.model.checkout.PaymentDetailsRequest;
import com.adyen.v6.facades.AdyenCheckoutFacade;
import de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService;
import de.hybris.platform.commerceservices.request.mapping.annotation.ApiVersion;
import de.hybris.platform.servicelayer.config.ConfigurationService;
import de.hybris.platform.site.BaseSiteService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import static com.adyen.commerce.constants.AdyenwebcommonsConstants.REDIRECT_PREFIX;

@Controller
@RequestMapping(value = AdyenoccConstants.ADYEN_PREFIX)
@ApiVersion("v2")
@Tag(name = "Adyen")
public class RedirectController extends RedirectControllerBase {
private static final String REDIRECT_URL = "/redirect";

@Resource(name = "adyenCheckoutFacade")
private AdyenCheckoutFacade adyenCheckoutFacade;

@Resource(name = "configurationService")
private ConfigurationService configurationService;

@Resource(name = "commerceCommonI18NService")
private CommerceCommonI18NService commerceCommonI18NService;

@Resource(name = "baseSiteService")
private BaseSiteService baseSiteService;

@GetMapping(value = REDIRECT_URL)
@Operation(operationId = "adyenRedirect", summary = "Handle redirect payment method", description =
"Handles return after payment method redirect flow returns")
public String authorizeRedirectPaymentGet(final HttpServletRequest request) {
return super.authoriseRedirectGetPayment(request);
}

@PostMapping(value = REDIRECT_URL)
@Operation(operationId = "adyenRedirect", summary = "Handle redirect payment method", description =
"Handles return after payment method redirect flow returns")
public String authorizeRedirectPaymentPost(@Parameter(description = "Payment details data", required = true) @RequestBody PaymentDetailsRequest detailsRequest) {
return super.authoriseRedirectPostPayment(detailsRequest);
}

@Override
public String getErrorRedirectUrl(String errorMessage) {
//TODO: will be implemented
return "error url";
}

@Override
public String getOrderConfirmationUrl(String orderCode) {
//TODO: will be implemented
return "order confirmation";
}

@Override
public String getCartUrl() {
String currency = commerceCommonI18NService.getCurrentCurrency().getIsocode();
String language = commerceCommonI18NService.getCurrentLanguage().getIsocode();
String baseSiteUid = baseSiteService.getCurrentBaseSite().getUid();

String baseUrl = configurationService.getConfiguration().getString("adyen.spartacus.baseurl");
return REDIRECT_PREFIX + baseUrl + "/" + baseSiteUid + "/" + language + "/" + currency + "/cart";
}

@Override
public AdyenCheckoutFacade getAdyenCheckoutFacade() {
return adyenCheckoutFacade;
}
}
99 changes: 99 additions & 0 deletions adyenwebcommons/buildcallbacks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
--><!--
All hybris buildcallbacks.xml macrodefinitions:
Build/Documentation
before/after ant macro "clean"
<macrodef name="adyenwebcommons_before_clean"/>
<macrodef name="adyenwebcommons_after_clean"/>
before/after ant macro "build"
<macrodef name="adyenwebcommons_before_build"/>
<macrodef name="adyenwebcommons_after_build"/>
before/after ant macro "compile_core" - the core module of the extension
<macrodef name="adyenwebcommons_before_compile_core">
<macrodef name="adyenwebcommons_after_compile_core">
before/after ant macro "compile_web" - the web module of the extension
<macrodef name="adyenwebcommons_before_compile_web" />
<macrodef name="adyenwebcommons_after_compile_web" />
before/after ant macro "compile_hmc" - the hmc module of the extension
<macrodef name="adyenwebcommons_before_compile_hmc" />
<macrodef name="adyenwebcommons_after_compile_hmc" />
Preparing extension
will be called in the beginning of the ant call and only once (also when using multiple
ant targets e.g. ant build yunittest)
<macrodef name="adyenwebcommons_only_once_prepare"/>
Creating ear module/production
before/after ant macro "ear"
<macrodef name="adyenwebcommons_before_ear"/>
<macrodef name="adyenwebcommons_after_ear"/>
before/after ant macro "production" - for hybris server only
<macrodef name="adyenwebcommons_before_production" />
<macrodef name="adyenwebcommons_after_production" />
JUnit Test
before/after ant macro "yunitinit"
<macrodef name="adyenwebcommons_before_yunitinit" />
<macrodef name="adyenwebcommons_after_yunitinit" />
before/after ant macro "yunit"
<macrodef name="adyenwebcommons_before_yunit" />
<macrodef name="adyenwebcommons_after_yunit" />
Distribution package
before/after ant macro "dist" - internal target; only for use when platform is available in source code
<macrodef name="adyenwebcommons_after_dist"/>
<macrodef name="adyenwebcommons_before_dist"/>
before/after ant macro "dist_copy" - internal target; only for use when platform is available in source code
<macrodef name="adyenwebcommons_before_dist_copy"/>
<macrodef name="adyenwebcommons_after_dist_copy"/>
With these filters you can override the default extension filters defined in platform/resources/ant/dist/filtersets.xml
<patternset id="extension.adyenwebcommons.binary.filter">
<patternset refid="extension.filter" />
<exclude name="**/*-source.jar" />
</patternset>
<patternset id="extension.adyenwebcommons.source.filter">
<exclude name="**/bin/**" />
</patternset>
With this filter you can decide what should be excluded from development zip.
<patternset id="extension.adyenwebcommons.devzip.filter">
Include all files from extension.source.filter.
<patternset refid="extension.source.filter" />
Exclude unwanted files.
<exclude name="lib/exclude-me.jar" />
</patternset>
--><project name="adyenwebcommons_buildcallbacks">

<!--
Called whenever 'ant ear' is used. this callback can be used to modify the content of the ear file
${ear.path}: path to ear
-->

<macrodef name="adyenwebcommons_before_ear">

<sequential>

<!-- you can do anything before the EAR file is being packed -->

</sequential>

</macrodef>

</project>
34 changes: 34 additions & 0 deletions adyenwebcommons/extensioninfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
--><extensioninfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="extensioninfo.xsd">


<extension abstractclassprefix="Generated" classprefix="Adyenwebcommons" jaloLogicFree="true" managername="AdyenwebcommonsManager" managersuperclass="de.hybris.platform.jalo.extension.Extension" name="adyenwebcommons" usemaven="false">



<!-- for more information on maven managed libraries please consult https://wiki.hybris.com/x/Nq8sDQ -->



<!-- you should add all required extensions to this list, except platform extensions which are automatically required -->



<!-- <requires-extension name="cms"/> -->

<requires-extension name="adyenv6core"/>



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




</extension>



</extensioninfo>
15 changes: 15 additions & 0 deletions adyenwebcommons/external-dependencies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hybris.platform</groupId>
<artifactId>adyenwebcommons</artifactId>
<version>2211.3</version>

<packaging>jar</packaging>

<dependencies>
</dependencies>
</project>
9 changes: 9 additions & 0 deletions adyenwebcommons/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -----------------------------------------------------------------------
# Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
# -----------------------------------------------------------------------

# adyenwebcommons.key=value

# Specifies the location of the spring context file putted automatically to the global platform application context.
adyenwebcommons.application-context=adyenwebcommons-spring.xml

Loading

0 comments on commit 015604f

Please sign in to comment.