Skip to content

Commit

Permalink
Release 2211 v4 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
adbame authored Jun 18, 2024
1 parent 5441288 commit d15bb57
Show file tree
Hide file tree
Showing 94 changed files with 1,255 additions and 1,172 deletions.
Binary file not shown.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Connector for SAP Commerce Cloud (formerly Hybris) enables customers to impl
This release is compatible with:
- SAP Commerce: B2C Accelerator of SAP Commerce Cloud 2211. It is advised to install the latest patch version of SAP Commerce Cloud.
- SAP Commerce REST API (OCC).
- Spartacus 4.2.7
- Spartacus 4.2.
- Java 17.
- Checkout.com Java SDK version 3.

Expand Down Expand Up @@ -79,7 +79,11 @@ Follow [this guideline](https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOU
Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud. Spartacus talks to SAP Commerce Cloud exclusively through the Commerce REST API (OCC). The Connector for SAP Commerce Cloud supports the Spartacus frontend. Check out details and release notes in the Checkout.com repository for Spartacus.

# Release Notes
- iDeal updated - BIC removed from the request
## Features:
- New Klarna payment method implemented
## Breaking changes:
- ABC decommissioned
- SOFORT payment method not longer supported

# Support
Contact your Checkout.com team if you have any question, technical problem or feature request for the SAP Commerce Cloud Connector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class CheckoutComKlarnaPaymentInfoDataReversePopulator implements Populator<PaymentDataForm, KlarnaPaymentInfoData> {

protected static final String AUTHORIZATION_TOKEN_KEY = "authorizationToken";
protected static final String PAYMENT_CONTEXT_ID = "paymentContextId";

/**
* {@inheritDoc}
Expand All @@ -27,6 +28,7 @@ public void populate(final PaymentDataForm source, final KlarnaPaymentInfoData t
final Map<String, Object> formAttributes = source.getFormAttributes();

target.setAuthorizationToken((String) formAttributes.get(AUTHORIZATION_TOKEN_KEY));
target.setPaymentContextId((String) formAttributes.get(PAYMENT_CONTEXT_ID));
target.setType(CheckoutComPaymentType.KLARNA.name());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ public class CheckoutComIsMerchantABCBeforeViewHandler implements BeforeViewHand
private static final Logger LOG = Logger.getLogger(CheckoutComIsMerchantABCBeforeViewHandler.class);
protected final CheckoutComMerchantConfigurationService checkoutComMerchantConfigurationService;

public CheckoutComIsMerchantABCBeforeViewHandler(CheckoutComMerchantConfigurationService checkoutComMerchantConfigurationService) {
public CheckoutComIsMerchantABCBeforeViewHandler(final CheckoutComMerchantConfigurationService checkoutComMerchantConfigurationService) {
this.checkoutComMerchantConfigurationService = checkoutComMerchantConfigurationService;
}

@Override
public void beforeView(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) throws Exception {
Boolean isMerchantABC = !checkoutComMerchantConfigurationService.isNasUsed();
modelAndView.addObject("isABC", isMerchantABC);
LOG.debug("The configuration of this merchant is " + (Boolean.TRUE.equals(isMerchantABC) ? "ABC" : "NAS"));
public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) {
modelAndView.addObject("isABC", Boolean.FALSE);
LOG.debug("The configuration of this merchant is NAS");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,35 @@
import com.checkout.hybris.addon.forms.PaymentDataForm;
import com.checkout.hybris.core.payment.enums.CheckoutComPaymentType;
import com.checkout.hybris.facades.beans.KlarnaPaymentInfoData;
import com.google.common.collect.ImmutableMap;
import de.hybris.bootstrap.annotations.UnitTest;
import org.junit.Test;

import java.util.Map;

import static com.checkout.hybris.addon.converters.populators.CheckoutComKlarnaPaymentInfoDataReversePopulator.AUTHORIZATION_TOKEN_KEY;
import static com.checkout.hybris.addon.converters.populators.CheckoutComKlarnaPaymentInfoDataReversePopulator.PAYMENT_CONTEXT_ID;
import static org.junit.Assert.assertEquals;

@UnitTest
public class CheckoutComKlarnaPaymentInfoDataReversePopulatorTest {

private static final String KLARNA_AUTH_TOKEN_VALUE = "12345678901_abdajkdjal";
private static final String KLARNA_PAYMENT_CONTEXT_VALUE = "12345678901_qwrqwrq";

private CheckoutComKlarnaPaymentInfoDataReversePopulator testObj = new CheckoutComKlarnaPaymentInfoDataReversePopulator();

private PaymentDataForm source = new PaymentDataForm();
private KlarnaPaymentInfoData target = new KlarnaPaymentInfoData();
private final PaymentDataForm source = new PaymentDataForm();
private final KlarnaPaymentInfoData target = new KlarnaPaymentInfoData();

@Test
public void populate_ShouldPopulateTargetCorrectly() {
source.setFormAttributes(ImmutableMap.of(AUTHORIZATION_TOKEN_KEY, KLARNA_AUTH_TOKEN_VALUE));
source.setFormAttributes(Map.of(AUTHORIZATION_TOKEN_KEY, KLARNA_AUTH_TOKEN_VALUE, PAYMENT_CONTEXT_ID, KLARNA_PAYMENT_CONTEXT_VALUE));

testObj.populate(source, target);

assertEquals(CheckoutComPaymentType.KLARNA.name(), target.getType());
assertEquals(KLARNA_AUTH_TOKEN_VALUE, target.getAuthorizationToken());
assertEquals(KLARNA_PAYMENT_CONTEXT_VALUE, target.getPaymentContextId());
}

@Test(expected = IllegalArgumentException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
import javax.servlet.http.HttpServletResponse;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

@UnitTest
@RunWith(MockitoJUnitRunner.class)
public class CheckoutComIsMerchantABCBeforeViewHandlerTest {
private static final Boolean MERCHANT_IS_ABC = Boolean.FALSE;
private static final Boolean MERCHANT_IS_NAS = Boolean.TRUE;
private static final String isABCKey = "isABC";

ModelAndView modelAndView;
Expand All @@ -43,16 +40,9 @@ public void setUp() {

@Test
public void beforeView_ShouldReturnFalse_IfMerchantIsNAS() throws Exception {
when(checkoutComMerchantConfigurationService.isNasUsed()).thenReturn(MERCHANT_IS_NAS);
testObj.beforeView(request, response, modelAndView);

assertEquals(Boolean.FALSE, modelAndView.getModel().get(isABCKey));
}
@Test
public void beforeView_ShouldReturnTrue_IfMerchantIsNAS() throws Exception {
when(checkoutComMerchantConfigurationService.isNasUsed()).thenReturn(MERCHANT_IS_ABC);
testObj.beforeView(request, response, modelAndView);

assertEquals(Boolean.TRUE, modelAndView.getModel().get(isABCKey));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
method="POST"
action="${submitPaymentDataUrl}">
<form:hidden id="authorizationToken" path="formAttributes['${'authorizationToken'}']" value=""/>
<form:hidden id="paymentContextId" path="formAttributes['${'paymentContextId'}']" value=""/>
<form:hidden id="type" path="formAttributes['${'type'}']" value="${paymentMethod}"/>
</form:form>

Expand All @@ -32,19 +33,10 @@
<c:choose>
<c:when test="${not empty klarnaClientToken and not empty klarnaClientToken.clientToken}">
let paymentMethodCategoryList = [
<c:forEach items="${klarnaClientToken.paymentMethodCategories}" var="paymentMethodCategory" varStatus="status">
'${paymentMethodCategory}'
<c:if test="${!status.last}">
,
</c:if>
</c:forEach>
];
window.klarnaSettings = {
klarnaInstanceId: '${klarnaClientToken.instanceId}',
clientToken: '${klarnaClientToken.clientToken}',
paymentMethodCategories: paymentMethodCategoryList,
paymentContextId: '${klarnaClientToken.paymentContext}',
backButton: '<spring:theme code="checkoutcom.klarna.error.back.button.label"/>',
paymentMethod: '${paymentMethod}',
billingAddress: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ACC.klarna = {
try {
Klarna.Payments.load({
container: "#klarnaContainer",
payment_method_categories: ACC.klarna.paymentMethodCategories,
instance_id: ACC.klarna.klarnaInstanceId
},
// data
Expand Down Expand Up @@ -111,6 +110,7 @@ ACC.klarna = {
if (response.approved === true && response.show_form === true) {
console.log(response.authorization_token);
$('#authorizationToken').val(response.authorization_token);
$('#paymentContextId').val(ACC.klarna.paymentContextId);
$('#checkoutComPaymentTokenForm').attr('action', ACC.config.encodedContextPath + '/checkout/multi/checkout-com/payment/submit-payment-data');
$('#checkoutComPaymentTokenForm').submit();
resolve();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Tue, 28 May 2024 13:17:07 +0000
#Tue, 18 Jun 2024 10:08:08 +0000
# Specifies the location of the spring context file added automatically to the global platform application context.
checkoutaddon.application-context=checkoutaddon-spring.xml

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#Ant properties
#Tue May 28 13:21:41 GMT 2024
#Tue Jun 18 10:12:55 GMT 2024
version.api=2211
vendor=hybris
group.id=de.hybris.platform
name=checkoutaddon
description=checkoutaddon
builddate=20240528 1321
builddate=20240618 1012
releasedate=20240307 1540
version=2211.20
module.name=platform-module
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,13 @@
</editorArea:essentials>
<editorArea:tab name="tab.configuration.checkoutcom.secrets">
<editorArea:section name="sec.configuration.checkoutcom.details">
<editorArea:attribute qualifier="publicKey"/>
<editorArea:attribute qualifier="secretKey"/>
<editorArea:attribute qualifier="privateSharedKey"/>
<editorArea:attribute qualifier="useNas"/>
<editorArea:attribute qualifier="nasPublicKey"/>
<editorArea:attribute qualifier="nasSecretKey"/>
<editorArea:attribute qualifier="nasSignatureKey"/>
<editorArea:attribute qualifier="nasAuthorisationHeaderKey"/>
<editorArea:attribute qualifier="useNasAuthorisationKeyOnNotifications"/>
<editorArea:attribute qualifier="useNasSignatureKeyOnNotifications"/>
<editorArea:attribute qualifier="useAbcSignatureKeyOnNotifications"/>
</editorArea:section>
</editorArea:tab>
<editorArea:tab name="tab.configuration.checkoutcom.global.settings">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#Ant properties
#Tue May 28 13:21:41 GMT 2024
#Tue Jun 18 10:12:56 GMT 2024
version.api=2211
vendor=hybris
group.id=de.hybris.platform
name=checkoutbackoffice
description=checkoutbackoffice
builddate=20240528 1321
builddate=20240618 1012
releasedate=20240307 1540
version=2211.20
module.name=platform-module
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#Ant properties
#Tue May 28 13:21:42 GMT 2024
#Tue Jun 18 10:12:56 GMT 2024
version.api=2211
vendor=hybris
group.id=de.hybris.platform
name=checkoutevents
description=checkoutevents
builddate=20240528 1321
builddate=20240618 1012
releasedate=20240307 1540
version=2211.20
module.name=platform-module
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import java.lang.reflect.Type;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.Optional;

/**
* Default implementation of {@link CheckoutComRequestEventValidator}
Expand Down Expand Up @@ -57,9 +55,7 @@ public boolean isRequestEventValid(final HttpServletRequest request, final Strin
LOG.debug("Received event signature: [{}]; ", ckoSignature);
LOG.debug("Received event body: [{}]", eventBody);

if (!isNasActive()) {
return !isAbcSignatureKeyActive() || isCkoSignatureValid(ckoSignature, eventBody);
} else if (isNasAuthorizationHeaderActive() && isNasAuthorizationHeaderInvalid(eventAuthorizationHeaderKey)) {
if (isNasAuthorizationHeaderActive() && isNasAuthorizationHeaderInvalid(eventAuthorizationHeaderKey)) {
return false;
} else {
return !isNasSignatureKeyActive() || isCkoSignatureValid(ckoSignature, eventBody);
Expand All @@ -83,39 +79,25 @@ private String createEventBodyHash(final String eventBody) throws NoSuchAlgorith
return new String(convertBytesToHex(bytes));
}

private boolean isNasActive() {
return checkoutComMerchantConfigurationService.isNasUsed();
}

private boolean isNasAuthorizationHeaderInvalid(final String eventAuthorizationHeaderKey) {
final String authorizationKeyForSite = checkoutComMerchantConfigurationService.getAuthorizationKey();
return StringUtils.isNotEmpty(eventAuthorizationHeaderKey) && !eventAuthorizationHeaderKey.equals(authorizationKeyForSite);
}

private boolean isNasAuthorizationHeaderActive() {
return checkoutComMerchantConfigurationService.isNasUsed() &&
checkoutComMerchantConfigurationService.isNasAuthorisationHeaderUsedOnNotificationValidation();
return checkoutComMerchantConfigurationService.isNasAuthorisationHeaderUsedOnNotificationValidation();
}

private boolean isNasSignatureKeyActive() {
return checkoutComMerchantConfigurationService.isNasUsed() &&
checkoutComMerchantConfigurationService.isNasSignatureKeyUsedOnNotificationValidation();
}

private boolean isAbcSignatureKeyActive() {
return !checkoutComMerchantConfigurationService.isNasUsed() &&
checkoutComMerchantConfigurationService.isAbcSignatureKeyUsedOnNotificationValidation();
return checkoutComMerchantConfigurationService.isNasSignatureKeyUsedOnNotificationValidation();
}

private String getSiteIdForTheEvent(final CheckoutComPaymentEventObject eventBody) {
return checkoutComPaymentEventService.getSiteIdForTheEvent(eventBody);
}

private byte[] getSecretPhrase() {
if (checkoutComMerchantConfigurationService.isNasUsed()) {
return checkoutComMerchantConfigurationService.getSignatureKey().getBytes();
}
return checkoutComMerchantConfigurationService.getSecretKey().getBytes();
return checkoutComMerchantConfigurationService.getSignatureKey().getBytes();
}

private char[] convertBytesToHex(final byte[] bytes) {
Expand Down
Loading

0 comments on commit d15bb57

Please sign in to comment.