Skip to content

Commit

Permalink
Merge pull request #128 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 6.0.0
  • Loading branch information
rkewlani authored Aug 1, 2019
2 parents f07c2d5 + 0c604d9 commit f023a1b
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Resource;
Expand Down Expand Up @@ -81,7 +82,7 @@
import static com.adyen.v6.constants.Adyenv6coreConstants.RATEPAY;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_MULTIBANCO;
import static com.adyen.v6.facades.DefaultAdyenCheckoutFacade.MODEL_CHECKOUT_SHOPPER_HOST;
import static com.adyen.v6.facades.DefaultAdyenCheckoutFacade.MODEL_ORIGIN_KEY;
import static com.adyen.v6.facades.DefaultAdyenCheckoutFacade.MODEL_ENVIRONMENT_MODE;

@Controller
@RequestMapping(value = AdyenControllerConstants.SUMMARY_CHECKOUT_PREFIX)
Expand All @@ -92,6 +93,7 @@ public class AdyenSummaryCheckoutStepController extends AbstractCheckoutStepCont
private static final String AUTHORISE_3D_SECURE_PAYMENT_URL = "/authorise-3d-adyen-response";
private static final String HPP_RESULT_URL = "/hpp-adyen-response";
private static final String ADYEN_PAYLOAD = "payload";
private static final String REDIRECT_RESULT = "redirectResult";

@Resource(name = "siteBaseUrlResolutionService")
private SiteBaseUrlResolutionService siteBaseUrlResolutionService;
Expand Down Expand Up @@ -208,20 +210,20 @@ public String placeOrder(@ModelAttribute("placeOrderForm") final PlaceOrderForm
errorMessage = getErrorMessageByRefusalReason(paymentsResponse.getRefusalReason());
}
if (IDENTIFYSHOPPER == paymentsResponse.getResultCode()) {
if (adyenPaymentMethod.equals(PAYMENT_METHOD_CC)|| adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) {
if (adyenPaymentMethod.equals(PAYMENT_METHOD_CC) || adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) {
model.addAttribute(MODEL_CHECKOUT_SHOPPER_HOST, adyenCheckoutFacade.getCheckoutShopperHost());
model.addAttribute(MODEL_ENVIRONMENT_MODE, adyenCheckoutFacade.getEnvironmentMode());
model.addAttribute(SHOPPER_LOCALE, adyenCheckoutFacade.getShopperLocale());
model.addAttribute(MODEL_ORIGIN_KEY, adyenCheckoutFacade.getOriginKey());
model.addAttribute(PAYMENT_DATA, paymentsResponse.getPaymentData());
model.addAttribute(FINGERPRINT_TOKEN, paymentsResponse.getAuthentication().get(THREEDS2_FINGERPRINT_TOKEN));
return AdyenControllerConstants.Views.Pages.MultiStepCheckout.Validate3DS2PaymentPage;
}
}
if (CHALLENGESHOPPER == paymentsResponse.getResultCode()) {
if (adyenPaymentMethod.equals(PAYMENT_METHOD_CC)|| adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) {
if (adyenPaymentMethod.equals(PAYMENT_METHOD_CC) || adyenPaymentMethod.indexOf(PAYMENT_METHOD_ONECLICK) == 0) {
model.addAttribute(MODEL_CHECKOUT_SHOPPER_HOST, adyenCheckoutFacade.getCheckoutShopperHost());
model.addAttribute(MODEL_ENVIRONMENT_MODE, adyenCheckoutFacade.getEnvironmentMode());
model.addAttribute(SHOPPER_LOCALE, adyenCheckoutFacade.getShopperLocale());
model.addAttribute(MODEL_ORIGIN_KEY, adyenCheckoutFacade.getOriginKey());
model.addAttribute(PAYMENT_DATA, paymentsResponse.getPaymentData());
model.addAttribute(CHALLENGE_TOKEN, paymentsResponse.getAuthentication().get(THREEDS2_CHALLENGE_TOKEN));
return AdyenControllerConstants.Views.Pages.MultiStepCheckout.Validate3DS2PaymentPage;
Expand Down Expand Up @@ -251,8 +253,8 @@ public String authorise3DS2Payment(final Model model,
PaymentsResponse paymentsResponse = e.getPaymentsResponse();
if (paymentsResponse != null && paymentsResponse.getResultCode() == CHALLENGESHOPPER) {
model.addAttribute(MODEL_CHECKOUT_SHOPPER_HOST, adyenCheckoutFacade.getCheckoutShopperHost());
model.addAttribute(MODEL_ENVIRONMENT_MODE, adyenCheckoutFacade.getEnvironmentMode());
model.addAttribute(SHOPPER_LOCALE, adyenCheckoutFacade.getShopperLocale());
model.addAttribute(MODEL_ORIGIN_KEY, adyenCheckoutFacade.getOriginKey());
model.addAttribute(PAYMENT_DATA, paymentsResponse.getPaymentData());
model.addAttribute(CHALLENGE_TOKEN, paymentsResponse.getAuthentication().get("threeds2.challengeToken"));
return AdyenControllerConstants.Views.Pages.MultiStepCheckout.Validate3DS2PaymentPage;
Expand All @@ -264,7 +266,7 @@ public String authorise3DS2Payment(final Model model,
LOGGER.debug("Redirecting to summary" + errorMessage);
return redirectToSummaryWithError(redirectModel, errorMessage);
}
LOGGER.debug("Redirecting to final step of checkout" +errorMessage);
LOGGER.debug("Redirecting to final step of checkout" + errorMessage);
return redirectToSummaryWithError(redirectModel, errorMessage);
}

Expand Down Expand Up @@ -298,11 +300,19 @@ public String authorise3DSecurePayment(final Model model,
@RequestMapping(value = HPP_RESULT_URL, method = RequestMethod.GET)
@RequireHardLogIn
public String handleAdyenResponse(final HttpServletRequest request, final RedirectAttributes redirectModel) {
//Compose HPP response data map
String payload = request.getParameter(ADYEN_PAYLOAD);
String redirectResult = request.getParameter(REDIRECT_RESULT);
HashMap<String, String> details = new HashMap<>();

if (payload != null && ! payload.isEmpty()) {
details.put(ADYEN_PAYLOAD, payload);
}
if (redirectResult != null && ! redirectResult.isEmpty()) {
details.put(REDIRECT_RESULT, redirectResult);
}

try {
PaymentsResponse response = adyenCheckoutFacade.handleRedirectPayload(payload);
PaymentsResponse response = adyenCheckoutFacade.handleRedirectPayload(details);

switch (response.getResultCode()) {
case AUTHORISED:
Expand Down Expand Up @@ -352,12 +362,20 @@ private void addMultibancoMessage(RedirectAttributes redirectModel, final String

GlobalMessages.addFlashMessage(redirectModel,
GlobalMessages.INFO_MESSAGES_HOLDER,
"<p> Multibanco order summary " + "</p>" +
"<p> Amount: " + orderData.getAdyenMultibancoAmount() + "</p>"
+ "<p> Entity: " + orderData.getAdyenMultibancoEntity() + "</p>"
+ "<p> Deadline: " + orderData.getAdyenMultibancoDeadline() + "</p>"
+ "<p> Reference: " + orderData.getAdyenMultibancoReference() + "</p>"
);
"<p> Multibanco order summary "
+ "</p>"
+ "<p> Amount: "
+ orderData.getAdyenMultibancoAmount()
+ "</p>"
+ "<p> Entity: "
+ orderData.getAdyenMultibancoEntity()
+ "</p>"
+ "<p> Deadline: "
+ orderData.getAdyenMultibancoDeadline()
+ "</p>"
+ "<p> Reference: "
+ orderData.getAdyenMultibancoReference()
+ "</p>");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@
*/
package com.adyen.v6.controllers.pages.checkout.steps;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.adyen.service.exception.ApiException;
import com.adyen.v6.constants.AdyenControllerConstants;
import com.adyen.v6.facades.AdyenCheckoutFacade;
import com.adyen.v6.forms.AdyenPaymentForm;
Expand All @@ -44,6 +49,7 @@
import de.hybris.platform.cms2.exceptions.CMSItemNotFoundException;
import de.hybris.platform.cms2.model.pages.ContentPageModel;
import de.hybris.platform.commercefacades.order.data.CartData;
import static com.adyen.v6.facades.DefaultAdyenCheckoutFacade.MODEL_ORIGIN_KEY;
import static de.hybris.platform.acceleratorstorefrontcommons.constants.WebConstants.BREADCRUMBS_KEY;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
Expand All @@ -65,6 +71,9 @@ public class SelectPaymentMethodCheckoutStepController extends AbstractCheckoutS
@Resource(name = "adyenCheckoutFacade")
private AdyenCheckoutFacade adyenCheckoutFacade;

@Autowired
private HttpServletRequest httpServletRequest;

/**
* {@inheritDoc}
*/
Expand All @@ -84,6 +93,14 @@ public String enterStep(final Model model, final RedirectAttributes redirectAttr
model.addAttribute(CART_DATA_ATTR, cartData);
model.addAttribute("expiryYears", getExpiryYears());

try {
model.addAttribute(MODEL_ORIGIN_KEY, adyenCheckoutFacade.getOriginKey(httpServletRequest));
} catch (IOException e) {
LOGGER.error("Exception occurred during getting the origin key" + ExceptionUtils.getStackTrace(e));
} catch (ApiException e) {
LOGGER.error("Exception occurred during getting origin key" + ExceptionUtils.getStackTrace(e));
}

adyenCheckoutFacade.initializeCheckoutData(model);

super.prepareDataForPage(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
<html>
<head>

<script type="text/javascript" src="https://${checkoutShopperHost}/checkoutshopper/sdk/2.5.0/adyen.js"></script>
<link rel="stylesheet" href="https://${checkoutShopperHost}/checkoutshopper/sdk/2.5.0/adyen.css"/>
<script type="text/javascript" src="https://${checkoutShopperHost}/checkoutshopper/sdk/3.0.0/adyen.js"></script>
<link rel="stylesheet" href="https://${checkoutShopperHost}/checkoutshopper/sdk/3.0.0/adyen.css"/>

<script type="text/javascript">
function initiateCheckout ( locale, loadingContext, originKey ) {
function initiateCheckout ( locale, environmentMode ) {
var configuration = {
locale: locale,// shopper's locale
loadingContext: loadingContext,
originKey: originKey,
environment: environmentMode, //test or live
risk: {
enabled: false
}
Expand All @@ -21,7 +20,7 @@
}
function perform3DS2Operations () {
initiateCheckout( "${shopperLocale}", "https://${checkoutShopperHost}/checkoutshopper/", "${originKey}" );
initiateCheckout( "${shopperLocale}", "${environmentMode}" );
var challengeToken = "${challengeToken}";
var fingerprintToken = "${fingerprintToken}";
if ( challengeToken ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<template:page pageTitle="${pageTitle}" hideHeaderLinks="true">
<jsp:attribute name="pageScripts">
<script type="text/javascript" src="${dfUrl}"></script>
<script type="text/javascript" src="https://${checkoutShopperHost}/checkoutshopper/sdk/2.5.0/adyen.js"></script>
<script type="text/javascript" src="https://${checkoutShopperHost}/checkoutshopper/sdk/3.0.0/adyen.js"></script>
<link rel="stylesheet" href="https://checkoutshopper-live.adyen.com/checkoutshopper/css/chckt-default-v1.css"/>
<link rel="stylesheet" href="https://${checkoutShopperHost}/checkoutshopper/sdk/2.5.0/adyen.css"/>
<link rel="stylesheet" href="https://${checkoutShopperHost}/checkoutshopper/sdk/3.0.0/adyen.css"/>

<script type="text/javascript">
AdyenCheckoutHybris.initiateCheckout("${shopperLocale}", "https://${checkoutShopperHost}/checkoutshopper/", "${originKey}" );
AdyenCheckoutHybris.initiateCheckout("${shopperLocale}", "${environmentMode}", "${originKey}" );
<c:if test="${not empty allowedCards}">
//Set the allowed cards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var AdyenCheckoutHybris = (function () {

// Check if it is a valid card and encrypt
if ( paymentMethod === "adyen_cc" ) {
if (!this.card.isValid()) {
if (!this.card.isValid) {
window.alert('This credit card is not allowed');
return false;
}
Expand All @@ -36,15 +36,15 @@ var AdyenCheckoutHybris = (function () {
var recurringReference = paymentMethod.slice("adyen_oneclick_".length);
var oneClickCard = this.oneClickCards[recurringReference];

if (!(oneClickCard && oneClickCard.isValid())) {
if (!(oneClickCard && oneClickCard.isValid)) {
window.alert('This credit card is not allowed');
return false;
}
if ( (oneClickCard.props.type == "bcmc") ) {
this.copyOneClickCardDataBCMC( recurringReference )
}
else {
this.copyOneClickCardData( recurringReference, oneClickCard.state.data.encryptedSecurityCode );
this.copyOneClickCardData( recurringReference, oneClickCard.data.paymentMethod.encryptedSecurityCode );
}
}

Expand All @@ -54,14 +54,14 @@ var AdyenCheckoutHybris = (function () {
},

copyCardData: function() {
var state = this.card.state.data;
var state = this.card.data.paymentMethod;
$( 'input[name="encryptedCardNumber"]' ).val( state.encryptedCardNumber );
$( 'input[name="encryptedExpiryMonth"]' ).val( state.encryptedExpiryMonth );
$( 'input[name="encryptedExpiryYear"]' ).val( state.encryptedExpiryYear );
$( 'input[name="encryptedSecurityCode"]' ).val( state.encryptedSecurityCode );
$( 'input[name="cardHolder"]' ).val( state.holderName );
if(state.storeDetails!=null){
$( 'input[name="rememberTheseDetails"]' ).val( state.storeDetails );}
if(this.card.data.storePaymentMethod!=null){
$( 'input[name="rememberTheseDetails"]' ).val( this.card.data.storePaymentMethod );}

},

Expand Down Expand Up @@ -118,10 +118,10 @@ var AdyenCheckoutHybris = (function () {
createDfValue: function () {
window.dfDo( "dfValue" );
},
initiateCheckout: function ( locale, loadingContext, originKey ) {
initiateCheckout: function ( locale, environment, originKey ) {
var configuration = {
locale: locale,// shopper's locale
loadingContext: loadingContext,
environment: environment,
originKey: originKey,
risk: {
enabled: false
Expand Down Expand Up @@ -180,7 +180,7 @@ var AdyenCheckoutHybris = (function () {

function handleChange(event) {
var issuerIdField = document.getElementById('issuerId');
var issuerId = event.data.issuer;
var issuerId = event.data.paymentMethod.issuer;
issuerIdField.value = issuerId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.name=platform-module
name=adyenv6b2ccheckoutaddon
releasedate=20170509 1903
vendor=adyen
version=5.0.0
version.api=5.0.0
version=6.0.0
version.api=6.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
<editorArea:attribute qualifier="adyenRecurringContractMode"/>
<editorArea:attribute qualifier="adyenTestMode"/>
</editorArea:section>
<editorArea:section name="hmc.adyen.api">
<editorArea:attribute qualifier="adyenAPIEndpointPrefix"/>
<editorArea:attribute qualifier="adyenAPIKey" editor="com.hybris.cockpitng.editor.defaultpassword"/>
<editorArea:attribute qualifier="adyenOriginKey"/>
</editorArea:section>
<editorArea:section name="hmc.adyen.api">
<editorArea:attribute qualifier="adyenAPIEndpointPrefix"/>
<editorArea:attribute qualifier="adyenAPIKey" editor="com.hybris.cockpitng.editor.defaultpassword"/>
</editorArea:section>
<editorArea:section name="hmc.adyen.hpp">
<editorArea:attribute qualifier="adyenSkinCode"/>
<editorArea:attribute qualifier="adyenSkinHMAC" editor="com.hybris.cockpitng.editor.defaultpassword"/>
Expand Down
4 changes: 2 additions & 2 deletions adyenv6backoffice/resources/adyenv6backoffice.build.number
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.name=platform-module
name=adyenv6backoffice
releasedate=20170509 1903
vendor=adyen
version=5.0.0
version.api=5.0.0
version=6.0.0
version.api=6.0.0
Binary file removed adyenv6core/lib/adyen-java-api-library-2.1.0-rc.jar
Binary file not shown.
Binary file added adyenv6core/lib/adyen-java-api-library-2.4.1.jar
Binary file not shown.
8 changes: 0 additions & 8 deletions adyenv6core/resources/adyenv6core-items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,6 @@
<description>Merchant account name</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenOriginKey" type="java.lang.String">
<description>WS User Origin key</description>
<persistence type="property">
<columntype>
<value>HYBRIS.LONG_STRING</value>
</columntype>
</persistence>
</attribute>
<attribute qualifier="adyenSkinCode" type="java.lang.String">
<description>HPP skin code</description>
<persistence type="property"/>
Expand Down
4 changes: 2 additions & 2 deletions adyenv6core/resources/adyenv6core.build.number
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ group.id=com.adyen.v6
module.name=platform-module
name=adyenv6core
vendor=adyen
version=5.0.0
version.api=5.0.0
version=6.0.0
version.api=6.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ type.basestore.adyenNotificationPassword.name=Server Communication HTTP Basic pa
type.basestore.adyenNotificationPassword.description=Set your own password and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => Password.
type.basestore.adyenMerchantAccount.name=Merchant account name
type.basestore.adyenMerchantAccount.description=The merchant account identifier you want to process the (transaction) request with. Find this at the top of the screen in the Adyen Customer Area (CA), where you will see [YourCompanyAccount] > [YourMerchantAccount] .
type.basestore.adyenOriginKey.name=WS User Origin Key
type.basestore.adyenOriginKey.description=Copy this from the Adyen Customer Area > Settings > Users > System (from the dropdown) > [web service user] > Origin key.
type.basestore.adyenSkinCode.name=HPP skin code
type.basestore.adyenSkinCode.description=Copy and paste the skin code of the skin you want to use from Customer Area => Skins. Leave empty to disable Alternative Payment Methods.
type.basestore.adyenSkinHMAC.name=HPP skin HMAC key
Expand Down
Loading

0 comments on commit f023a1b

Please sign in to comment.