Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The subscription types live in adyensubscriptionconnector, which owns them. This addon adds only the CMS
restriction that hides its My Account entry while no billing platform connector is loaded.
This addon declares no types of its own: the subscription types and the CMS restriction
AdyenSubscriptionPlatformRestriction live in adyensubscriptionconnector, which owns them.

The file must exist in any case, because extensioninfo.xml declares a generated coremodule: without an
items.xml the Manager class named there is never generated, and the platform refuses to load the
extension at startup with ClassNotFoundException for Adyensubscriptionb2caddonManager.
-->
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">

<itemtypes>
<!-- Evaluated by SubscriptionPlatformRestrictionEvaluator: passes while at least one subscription billing
connector extension is loaded. Has no settings of its own. -->
<itemtype code="AdyenSubscriptionPlatformRestriction" extends="AbstractRestriction"
autocreate="true" generate="true"
jaloclass="com.adyen.commerce.subscription.jalo.AdyenSubscriptionPlatformRestriction">
<description>Shows a CMS item only while a subscription billing platform connector is loaded.</description>
<attributes>
<attribute qualifier="description" type="java.lang.String" redeclare="true">
<persistence type="dynamic"
attributeHandler="adyenSubscriptionPlatformRestrictionDescriptionHandler"/>
<modifiers write="false"/>
</attribute>
</attributes>
</itemtype>
</itemtypes>
</items>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

<!--
Everything else this addon adds is web-tier and lives in its own web context. What is here is the
restriction that follows the loaded connectors, and the pair of listeners that get the CMS page into
the content catalogue, because a controller and a JSP with no ContentPage behind them are a 404 with
pair of listeners that get the CMS page into the content catalogue, because a controller and a JSP with no ContentPage behind them are a 404 with
nothing in the log to explain it.
-->

Expand All @@ -32,22 +31,6 @@
</property>
</bean>

<!-- The My Account entry is hidden by this restriction while no billing platform connector is loaded; the
controller answers 404 on the same condition. -->
<bean id="adyenSubscriptionPlatformRestrictionEvaluator"
class="com.adyen.commerce.subscription.restrictions.SubscriptionPlatformRestrictionEvaluator">
<property name="mySubscriptionsFacade" ref="mySubscriptionsFacade"/>
</bean>

<bean id="adyenSubscriptionPlatformRestrictionEvaluatorMapping"
class="de.hybris.platform.cms2.servicelayer.services.evaluator.CMSRestrictionEvaluatorMapping">
<property name="restrictionTypeCode" value="AdyenSubscriptionPlatformRestriction"/>
<property name="restrictionEvaluator" ref="adyenSubscriptionPlatformRestrictionEvaluator"/>
</bean>

<bean id="adyenSubscriptionPlatformRestrictionDescriptionHandler"
class="com.adyen.commerce.subscription.restrictions.SubscriptionPlatformRestrictionDescriptionHandler"/>

<!-- Imports resources/adyensubscriptionb2caddon/import/contentCatalogs/**. -->
<bean id="adyensubscriptionb2caddonSampleDataEventListener" parent="abstractGenericAddOnSampleDataEventListener">
<property name="extensionName" value="adyensubscriptionb2caddon"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Copyright (c) 2026 Adyen B.V. - MIT license.

type.AdyenSubscriptionPlatformRestriction.name=Subscription Platform Loaded Restriction
type.AdyenSubscriptionPlatformRestriction.description=Shows a CMS item only while a subscription billing platform connector is loaded
2 changes: 2 additions & 0 deletions adyensubscriptionconnector/extensioninfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<!-- The activation retry job: AbstractJobPerformable and the abstractJobPerformable bean. Reached
transitively through commerceservices already, but named because this extension uses it directly. -->
<requires-extension name="processing"/>
<!-- CMS restriction type AdyenSubscriptionPlatformRestriction (AbstractRestriction, the evaluator mapping). -->
<requires-extension name="cms2"/>
<!-- OCC webapp host for the inbound webhook endpoint -->
<requires-extension name="commercewebservices"/>

Expand Down
6 changes: 6 additions & 0 deletions adyensubscriptionconnector/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ adyen.subscription.retention.settledAfterDays=30
adyen.subscription.retention.troubledAfterDays=180
# Per run, per journal. Kept modest because this competes with live traffic.
adyen.subscription.retention.job.batchSize=500

# --- OCC error mapping for the shopper subscriptions endpoint ---------------------------------------
# The refusal is one fixed 400 whatever the reason; the stack is never logged (nothing useful is in it).
webservicescommons.resthandlerexceptionresolver.SubscriptionActionRefusedException.status=400
webservicescommons.resthandlerexceptionresolver.SubscriptionActionRefusedException.logstack=false
webservicescommons.resthandlerexceptionresolver.SubscriptionActionRefusedException.messageFormatterType=FORWARD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@
</attributes>
</itemtype>

<!-- CMS restriction that shows an item only while a subscription billing platform connector is loaded.
Used by the My Account navigation entry of both the accelerator addon and the Spartacus content
catalog, so it lives here and not in a storefront addon. Evaluated by
SubscriptionPlatformRestrictionEvaluator. Has no settings of its own. -->
<!-- generate="false": this extension is jaloLogicFree, so a generated jalo class would land in gensrc
under the jaloclass name and could not implement AbstractRestriction.getDescription(SessionContext).
The jalo class is hand-written instead; the model is still generated (generateModel defaults to true). -->
<itemtype code="AdyenSubscriptionPlatformRestriction" extends="AbstractRestriction"
autocreate="true" generate="false"
jaloclass="com.adyen.commerce.connector.jalo.AdyenSubscriptionPlatformRestriction">
<description>Shows a CMS item only while a subscription billing platform connector is loaded.</description>
<attributes>
<attribute qualifier="description" type="java.lang.String" redeclare="true">
<persistence type="dynamic"
attributeHandler="adyenSubscriptionPlatformRestrictionDescriptionHandler"/>
<modifiers write="false"/>
</attribute>
</attributes>
</itemtype>

<!-- Credentials every external platform needs. Each connector extension extends this with its
own config type and hangs it off BaseStore. -->
<itemtype code="AdyenSubscriptionConfig" extends="GenericItem" autocreate="true" generate="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,23 @@
<property name="subscriptionOrderCancellationService" ref="subscriptionOrderCancellationService"/>
</bean>

<!-- ============================================================= -->
<!-- CMS restriction: a My Account entry is shown only while a -->
<!-- billing platform connector is loaded. The controllers answer -->
<!-- 404 on the same condition. -->
<!-- ============================================================= -->
<bean id="adyenSubscriptionPlatformRestrictionEvaluator"
class="com.adyen.commerce.connector.restrictions.SubscriptionPlatformRestrictionEvaluator">
<property name="mySubscriptionsFacade" ref="mySubscriptionsFacade"/>
</bean>

<bean id="adyenSubscriptionPlatformRestrictionEvaluatorMapping"
class="de.hybris.platform.cms2.servicelayer.services.evaluator.CMSRestrictionEvaluatorMapping">
<property name="restrictionTypeCode" value="AdyenSubscriptionPlatformRestriction"/>
<property name="restrictionEvaluator" ref="adyenSubscriptionPlatformRestrictionEvaluator"/>
</bean>

<bean id="adyenSubscriptionPlatformRestrictionDescriptionHandler"
class="com.adyen.commerce.connector.restrictions.SubscriptionPlatformRestrictionDescriptionHandler"/>

</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# -----------------------------------------------------------------------
# The "My Subscriptions" page in My Account for the Spartacus storefront.
#
# NOT imported automatically: nothing in SystemSetup runs this file. Import it by hand in HAC
# (Console > ImpEx import) after the system update that creates the AdyenSubscriptionPlatformRestriction
# type, which this connector now owns. The Accelerator addon has its own impex for its own catalogue.
#
# Targets the Spartacus content catalogue of the sample data (electronics-spaContentCatalog). For another
# site change $contentCatalog below. It is idempotent: INSERT_UPDATE with unique keys, and `append` mode on
# the links of the restriction and the navigation nodes.
#
# What it creates, in BOTH catalogue versions (Spartacus serves Online, so a Staged-only import is
# invisible until somebody synchronises the catalogue):
# 1. ContentPage adyenSubscriptions, label /my-account/subscriptions, on AccountPageTemplate
# 2. a CMSFlexComponent whose flexType AdyenMySubscriptionsComponent is the key of
# cmsComponents in @adyen/adyen-spartacus, placed in the BodyContent slot of that page
# 3. a "Subscriptions" link with a restriction that lets it through only while a billing platform
# connector is loaded, and two navigation entries for it: the My Account dropdown
# (MyAccountNavNode) and the My Account side navigation (OrderInformationNavNode, created by
# spartacussampledata/myaccount-navigation.impex)
#
# The &...Staged and &...Online document ids are scoped to the whole import run, so the two halves must
# not share one.
# -----------------------------------------------------------------------
$contentCatalog=electronics-spaContentCatalog
$contentCVS=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]
$contentCVO=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Online])[default=$contentCatalog:Online]

# --- Staged ---
INSERT_UPDATE ContentPage;$contentCVS[unique=true];uid[unique=true];name;masterTemplate(uid,$contentCVS);label;defaultPage[default='true'];approvalStatus(code)[default='approved'];homepage[default='false']
;;adyenSubscriptions;My Subscriptions Page;AccountPageTemplate;/my-account/subscriptions

INSERT_UPDATE CMSFlexComponent;$contentCVS[unique=true];uid[unique=true];name;flexType
;;AdyenMySubscriptionsComponent;Adyen My Subscriptions Component;AdyenMySubscriptionsComponent

INSERT_UPDATE ContentSlot;$contentCVS[unique=true];uid[unique=true];name;active;cmsComponents(uid,$contentCVS)
;;BodyContent-adyenSubscriptions;Body Content Slot for My Subscriptions;true;AdyenMySubscriptionsComponent

INSERT_UPDATE ContentSlotForPage;$contentCVS[unique=true];uid[unique=true];position[unique=true];page(uid,$contentCVS)[unique=true][default='adyenSubscriptions'];contentSlot(uid,$contentCVS)[unique=true]
;;BodyContent-adyenSubscriptions;BodyContent;;BodyContent-adyenSubscriptions

INSERT_UPDATE AdyenSubscriptionPlatformRestriction;$contentCVS[unique=true];uid[unique=true];name
;;AdyenSubscriptionPlatformRestriction;Subscription billing platform loaded

INSERT_UPDATE CMSLinkComponent;$contentCVS[unique=true];uid[unique=true];name;url;&linkRefStaged;target(code)[default='sameWindow'];restrictions(uid,$contentCVS)[mode=append]
;;AdyenSubscriptionsLink;AdyenSubscriptionsLink;/my-account/subscriptions;AdyenSubscriptionsLink;;AdyenSubscriptionPlatformRestriction

UPDATE CMSLinkComponent;$contentCVS[unique=true];uid[unique=true];linkName[lang=en]
;;AdyenSubscriptionsLink;"Subscriptions"

# `links` stays empty on purpose: the CMSNavigationEntry binds the link, and filling both would show it twice.
INSERT_UPDATE CMSNavigationNode;uid[unique=true];$contentCVS[unique=true];name;parent(uid,$contentCVS);&nodeRefStaged;title[lang=en]
;AdyenSubscriptionsNavNode;;Subscriptions;MyAccountNavNode;AdyenSubscriptionsNavNode;Subscriptions
;AdyenSubscriptionsSideNavNode;;Subscriptions;OrderInformationNavNode;AdyenSubscriptionsSideNavNode;Subscriptions

INSERT_UPDATE CMSNavigationEntry;uid[unique=true];$contentCVS[unique=true];name;navigationNode(&nodeRefStaged);item(&linkRefStaged)
;AdyenSubscriptionsNavNodeEntry;;AdyenSubscriptionsNavNodeEntry;AdyenSubscriptionsNavNode;AdyenSubscriptionsLink
;AdyenSubscriptionsSideNavNodeEntry;;AdyenSubscriptionsSideNavNodeEntry;AdyenSubscriptionsSideNavNode;AdyenSubscriptionsLink

# The new node is appended to MyAccountNavNode, i.e. after Sign Out. Re-attach Sign Out so it moves back to
# the end: detaching and re-attaching a child appends it to the ordered children of the parent. Unlike
# re-setting the whole children list this does not depend on which other nodes a project has.
UPDATE CMSNavigationNode;uid[unique=true];$contentCVS[unique=true];parent(uid,$contentCVS)[allownull=true]
;SignOutNavNode;;
UPDATE CMSNavigationNode;uid[unique=true];$contentCVS[unique=true];parent(uid,$contentCVS)
;SignOutNavNode;;MyAccountNavNode

# --- Online ---
INSERT_UPDATE ContentPage;$contentCVO[unique=true];uid[unique=true];name;masterTemplate(uid,$contentCVO);label;defaultPage[default='true'];approvalStatus(code)[default='approved'];homepage[default='false']
;;adyenSubscriptions;My Subscriptions Page;AccountPageTemplate;/my-account/subscriptions

INSERT_UPDATE CMSFlexComponent;$contentCVO[unique=true];uid[unique=true];name;flexType
;;AdyenMySubscriptionsComponent;Adyen My Subscriptions Component;AdyenMySubscriptionsComponent

INSERT_UPDATE ContentSlot;$contentCVO[unique=true];uid[unique=true];name;active;cmsComponents(uid,$contentCVO)
;;BodyContent-adyenSubscriptions;Body Content Slot for My Subscriptions;true;AdyenMySubscriptionsComponent

INSERT_UPDATE ContentSlotForPage;$contentCVO[unique=true];uid[unique=true];position[unique=true];page(uid,$contentCVO)[unique=true][default='adyenSubscriptions'];contentSlot(uid,$contentCVO)[unique=true]
;;BodyContent-adyenSubscriptions;BodyContent;;BodyContent-adyenSubscriptions

INSERT_UPDATE AdyenSubscriptionPlatformRestriction;$contentCVO[unique=true];uid[unique=true];name
;;AdyenSubscriptionPlatformRestriction;Subscription billing platform loaded

INSERT_UPDATE CMSLinkComponent;$contentCVO[unique=true];uid[unique=true];name;url;&linkRefOnline;target(code)[default='sameWindow'];restrictions(uid,$contentCVO)[mode=append]
;;AdyenSubscriptionsLink;AdyenSubscriptionsLink;/my-account/subscriptions;AdyenSubscriptionsLink;;AdyenSubscriptionPlatformRestriction

UPDATE CMSLinkComponent;$contentCVO[unique=true];uid[unique=true];linkName[lang=en]
;;AdyenSubscriptionsLink;"Subscriptions"

# `links` stays empty on purpose: the CMSNavigationEntry binds the link, and filling both would show it twice.
INSERT_UPDATE CMSNavigationNode;uid[unique=true];$contentCVO[unique=true];name;parent(uid,$contentCVO);&nodeRefOnline;title[lang=en]
;AdyenSubscriptionsNavNode;;Subscriptions;MyAccountNavNode;AdyenSubscriptionsNavNode;Subscriptions
;AdyenSubscriptionsSideNavNode;;Subscriptions;OrderInformationNavNode;AdyenSubscriptionsSideNavNode;Subscriptions

INSERT_UPDATE CMSNavigationEntry;uid[unique=true];$contentCVO[unique=true];name;navigationNode(&nodeRefOnline);item(&linkRefOnline)
;AdyenSubscriptionsNavNodeEntry;;AdyenSubscriptionsNavNodeEntry;AdyenSubscriptionsNavNode;AdyenSubscriptionsLink
;AdyenSubscriptionsSideNavNodeEntry;;AdyenSubscriptionsSideNavNodeEntry;AdyenSubscriptionsSideNavNode;AdyenSubscriptionsLink

# The new node is appended to MyAccountNavNode, i.e. after Sign Out. Re-attach Sign Out so it moves back to
# the end: detaching and re-attaching a child appends it to the ordered children of the parent. Unlike
# re-setting the whole children list this does not depend on which other nodes a project has.
UPDATE CMSNavigationNode;uid[unique=true];$contentCVO[unique=true];parent(uid,$contentCVO)[allownull=true]
;SignOutNavNode;;
UPDATE CMSNavigationNode;uid[unique=true];$contentCVO[unique=true];parent(uid,$contentCVO)
;SignOutNavNode;;MyAccountNavNode
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ type.AdyenSubscriptionConfig.adyenGatewayMerchantAccount.description=The Adyen m

type.Customer.billingCustomerRefs.name=Billing Customer References
type.PaymentInfo.billingPaymentMethodRefs.name=Billing Payment Method References

type.AdyenSubscriptionPlatformRestriction.name=Subscription Platform Loaded Restriction
type.AdyenSubscriptionPlatformRestriction.description=Shows a CMS item only while a subscription billing platform connector is loaded
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
<property name="baseSiteService" ref="baseSiteService"/>
</bean>

<!-- Facade data to OCC DTOs for the shopper's subscriptions endpoint. Replace through the alias. -->
<alias name="defaultAdyenMySubscriptionsWsMapper" alias="adyenMySubscriptionsWsMapper"/>
<bean id="defaultAdyenMySubscriptionsWsMapper"
class="com.adyen.commerce.connector.occ.mapper.AdyenMySubscriptionsWsMapper"/>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
package com.adyen.commerce.subscription.jalo;
package com.adyen.commerce.connector.jalo;

import com.adyen.commerce.subscription.restrictions.SubscriptionPlatformRestrictionDescriptionHandler;
import com.adyen.commerce.connector.restrictions.SubscriptionPlatformRestrictionDescriptionHandler;

import de.hybris.platform.cms2.jalo.restrictions.AbstractRestriction;
import de.hybris.platform.jalo.SessionContext;

/**
* Jalo class of the restriction, required by the type system. The service layer reads the description through
* {@link SubscriptionPlatformRestrictionDescriptionHandler}; this returns the same sentence for jalo callers.
*
* <p>Hand-written and not generated (the type is {@code generate="false"}): in a jaloLogicFree extension the
* generator writes the jalo class itself into gensrc, where it could not implement the abstract
* {@link AbstractRestriction#getDescription(SessionContext)}.</p>
*/
public class AdyenSubscriptionPlatformRestriction extends GeneratedAdyenSubscriptionPlatformRestriction
public class AdyenSubscriptionPlatformRestriction extends AbstractRestriction
{
@Override
public String getDescription(final SessionContext ctx)
Expand Down
Loading
Loading