Skip to content

Commit

Permalink
Merge pull request #151 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 6.2.0
  • Loading branch information
rkewlani authored Oct 18, 2019
2 parents 2db3022 + 964b615 commit cd83937
Show file tree
Hide file tree
Showing 45 changed files with 2,581 additions and 119 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ https://docs.adyen.com/developers/payment-methods/boleto-bancario/boleto-payment
```
is3DS2allowed = false
```
## POS Timeout configuration
POS timeout (time calculated since initiating a payment) is max time to keep terminal connection open. It is set to 130 seconds by default already. If you want to change it, please add following property in local.properties file, build your environment and restart the server. (Change 130 to your desired time, in seconds).
```
pos.totaltimeout = 130
```


## Documentation
https://docs.adyen.com/developers/plugins/hybris
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package com.adyen.v6.controllers.pages;

import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -43,6 +44,7 @@
import com.adyen.v6.constants.AdyenControllerConstants;
import com.adyen.v6.exceptions.AdyenNonAuthorizedPaymentException;
import com.adyen.v6.facades.AdyenCheckoutFacade;
import com.adyen.v6.util.TerminalAPIUtil;
import de.hybris.platform.acceleratorservices.enums.CheckoutPciOptionEnum;
import de.hybris.platform.acceleratorservices.urlresolver.SiteBaseUrlResolutionService;
import de.hybris.platform.acceleratorstorefrontcommons.annotations.PreValidateCheckoutStep;
Expand All @@ -61,7 +63,7 @@
import de.hybris.platform.commercefacades.product.ProductOption;
import de.hybris.platform.commercefacades.product.data.ProductData;
import de.hybris.platform.commerceservices.order.CommerceCartModificationException;
import de.hybris.platform.order.InvalidCartException;
import de.hybris.platform.servicelayer.config.ConfigurationService;
import de.hybris.platform.site.BaseSiteService;
import static com.adyen.constants.ApiConstants.Redirect.Data.MD;
import static com.adyen.constants.ApiConstants.Redirect.Data.PAREQ;
Expand All @@ -78,9 +80,10 @@
import static com.adyen.model.checkout.PaymentsResponse.ResultCodeEnum.REFUSED;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_BOLETO;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_CC;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_MULTIBANCO;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_ONECLICK;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_POS;
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_ENVIRONMENT_MODE;

Expand All @@ -95,6 +98,9 @@ public class AdyenSummaryCheckoutStepController extends AbstractCheckoutStepCont
private static final String ADYEN_PAYLOAD = "payload";
private static final String REDIRECT_RESULT = "redirectResult";

private static final int POS_TOTALTIMEOUT_DEFAULT = 130;
private static final String POS_TOTALTIMEOUT_KEY = "pos.totaltimeout";

@Resource(name = "siteBaseUrlResolutionService")
private SiteBaseUrlResolutionService siteBaseUrlResolutionService;

Expand All @@ -107,6 +113,9 @@ public class AdyenSummaryCheckoutStepController extends AbstractCheckoutStepCont
@Resource(name = "orderFacade")
private OrderFacade orderFacade;

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

@RequestMapping(value = "/view", method = RequestMethod.GET)
@RequireHardLogIn
@Override
Expand Down Expand Up @@ -144,8 +153,7 @@ public String enterStep(final Model model, final RedirectAttributes redirectAttr
public String placeOrder(@ModelAttribute("placeOrderForm") final PlaceOrderForm placeOrderForm,
final Model model,
final HttpServletRequest request,
final RedirectAttributes redirectModel) throws CMSItemNotFoundException, // NOSONAR
InvalidCartException, CommerceCartModificationException {
final RedirectAttributes redirectModel) throws CMSItemNotFoundException, CommerceCartModificationException {
if (validateOrderForm(placeOrderForm, model)) {
return enterStep(model, redirectModel);
}
Expand Down Expand Up @@ -178,6 +186,43 @@ public String placeOrder(@ModelAttribute("placeOrderForm") final PlaceOrderForm
} catch (Exception e) {
LOGGER.error(ExceptionUtils.getStackTrace(e));
}
} else if (PAYMENT_METHOD_POS.equals(adyenPaymentMethod)) {
try {
String originalServiceId = Long.toString(System.currentTimeMillis() % 10000000000L);
request.setAttribute("originalServiceId", originalServiceId);
Long paymentStartTime = System.currentTimeMillis();
request.setAttribute("paymentStartTime", paymentStartTime);
OrderData orderData = adyenCheckoutFacade.initiatePosPayment(request, cartData);
LOGGER.debug("Redirecting to confirmation!");
return redirectToOrderConfirmationPage(orderData);
} catch (SocketTimeoutException e) {
try {
LOGGER.debug("POS request timed out. Checking POS Payment status ");
int totalTimeout = POS_TOTALTIMEOUT_DEFAULT;
if(configurationService.getConfiguration().containsKey(POS_TOTALTIMEOUT_KEY)) {
totalTimeout = configurationService.getConfiguration().getInt(POS_TOTALTIMEOUT_KEY);
}
request.setAttribute("totalTimeout", totalTimeout);
OrderData orderData = adyenCheckoutFacade.checkPosPaymentStatus(request, cartData);
LOGGER.debug("Redirecting to confirmation!");
return redirectToOrderConfirmationPage(orderData);
} catch (AdyenNonAuthorizedPaymentException nx) {
LOGGER.debug("AdyenNonAuthorizedPaymentException", nx);
errorMessage = TerminalAPIUtil.getErrorMessageForNonAuthorizedPosPayment(nx.getTerminalApiResponse());
} catch (SocketTimeoutException to) {
LOGGER.debug("POS Status request timed out. Returning error message.");
errorMessage = "checkout.error.authorization.pos.configuration";
} catch (Exception ex) {
LOGGER.error("Exception", ex);
}
} catch (ApiException e) {
LOGGER.error("API exception " + e.getError(), e);
} catch (AdyenNonAuthorizedPaymentException e) {
LOGGER.debug("AdyenNonAuthorizedPaymentException", e);
errorMessage = TerminalAPIUtil.getErrorMessageForNonAuthorizedPosPayment(e.getTerminalApiResponse());
} catch (Exception e) {
LOGGER.error("Exception", e);
}
} else {
try {
cartData.setAdyenReturnUrl(getReturnUrl());
Expand Down Expand Up @@ -493,6 +538,7 @@ protected boolean validateOrderForm(final PlaceOrderForm placeOrderForm, final M
return invalid;
}


@RequestMapping(value = "/back", method = RequestMethod.GET)
@RequireHardLogIn
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ checkout.error.authorization.payment.detail.not.found=The payment is REFUSED bec
checkout.error.authorization.payment.refused=The payment is REFUSED.
checkout.error.authorization.payment.cancelled=The payment is Cancelled.
checkout.error.authorization.payment.error=An error occured.
checkout.error.authorization.pos.configuration=Error reaching POS terminal. Check the terminal connection/configuration and try again.
checkout.error.authorization.pos.busy=The terminal is busy. Wait for the current transaction to end and try again later.
checkout.error.authorization.pos.pin=The payment is REFUSED. Please check your Card details.

text.account.storedCards.empty=There are no stored cards
text.account.storedCard.delete=Remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<%@ attribute name="showSocialSecurityNumber" required="false" type="java.lang.Boolean" %>
<%@ attribute name="showFirstName" required="false" type="java.lang.Boolean" %>
<%@ attribute name="showLastName" required="false" type="java.lang.Boolean" %>
<%@ attribute name="showTerminalList" required="false" type="java.lang.Boolean" %>
<%@ attribute name="countryCode" required="false" type="java.lang.String" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Expand Down Expand Up @@ -52,6 +53,19 @@
</label>
</c:if>

<c:if test="${showTerminalList}">
<c:if test="${not empty connectedTerminalList}">
<label class="chckt-form-label chckt-form-label--full-width">
<select class="chckt-select-box js-chckt-terminal-select-box" id="adyen_pos_terminal" name="${brandCode}">
<option value="" label="SELECT YOUR TERMINAL"/>
<c:forEach items="${connectedTerminalList}" var="connectedTerminal">
<option value="${connectedTerminal}">${connectedTerminal}</option>
</c:forEach>
</select>
</label>
</c:if>
</c:if>

<c:if test="${showDob}">
<label for="p_method_adyen_hpp_${brandCode}_dob">
<span>Date of birth</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

<template:page pageTitle="${pageTitle}" hideHeaderLinks="true">

<div id="spinner_wrapper" style="display: none">
<div id="spinner"></div>
<div id="spinner_text">
<p>Please wait while your payment is processed. Do not click back or refresh the page.</p>
</div>
</div>

<div class="row">
<div class="col-sm-6">
<div class="checkout-headline">
Expand All @@ -32,8 +39,8 @@
</label>
</div>

<button id="placeOrder" type="submit" class="btn btn-primary btn-place-order btn-block">
<spring:theme code="checkout.summary.placeOrder" text="Place Order"/>
<button id="placeOrder" type="submit" class="btn btn-primary btn-place-order btn-block" onclick="AdyenCheckoutHybris.showSpinner()">
<spring:theme code="checkout.summary.placeOrder" text="Place Order" />
</button>
</form:form>
</div>
Expand All @@ -52,4 +59,4 @@
</cms:pageSlot>
</div>
</div>
</template:page>
</template:page>
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<form:hidden path="encryptedSecurityCode"/>

<form:hidden path="browserInfo"/>
<form:hidden path="terminalId"/>
<form:hidden path="rememberTheseDetails" value="false"/>

<div class="chckt-pm-list js-chckt-pm-list">
Expand All @@ -130,7 +131,7 @@
<adyen:alternativeMethod
brandCode="${paymentMethod.type}"
name="${paymentMethod.name}"
showDob="${openInvoiceMethods.contains(paymentMethod.type)}"
showDob="${paymentMethod.type=='ratepay'}"
showSocialSecurityNumber="${showSocialSecurityNumber}"
/>
</c:forEach>
Expand All @@ -152,6 +153,13 @@
countryCode="BR"
/>
</c:if>
<c:if test="${not empty connectedTerminalList}">
<adyen:alternativeMethod
brandCode="pos"
name="POS"
showTerminalList="true"
/>
</c:if>
</div>
</form:form>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,75 @@
.checkout-paymentmethod li {
list-style: none;
}

/* Spinner for "place order" */
div#spinner {
position: absolute;
z-index: 1;
width: 75px;
height: 75px;
border: 10px solid #f3f3f3;
border-radius: 50%;
border-top: 10px solid #0f7384;
animation: spin 2s linear infinite;
}

@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

/* Add animation to "page content" */
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}

@-webkit-keyframes animatebottom {
from { bottom:-100px; opacity:0 }
to { bottom:0px; opacity:1 }
}

@keyframes animatebottom {
from{ bottom:-100px; opacity:0 }
to{ bottom:0; opacity:1 }
}

div#spinner_wrapper {
position: fixed;
padding: 0;
margin: 0;
top: 0;
left: 0;
height: 100vh;
width: 100vw;
background: rgba(0,0,0,0.65);
z-index: 999999;
justify-content: center;
align-items: center;
}

div#spinner_text {
position: absolute;
bottom: 25%;
width: 100%;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}

div#spinner_text p {
margin: 25px 0 25px;
color: white;
width: 50%;
padding: 20px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ var AdyenCheckoutHybris = (function () {
}
}

if ( paymentMethod === "pos" ) {
var terminalId = $( '#adyen_pos_terminal' );
if( terminalId.val() === "" ) {
window.alert("Please select a terminal");
return false;
}
}

$( 'input[name="txvariant"]' ).remove();

return true;
Expand Down Expand Up @@ -80,7 +88,6 @@ var AdyenCheckoutHybris = (function () {
*/
setCustomPaymentMethodValues: function () {
var paymentMethod = $( 'input[type=radio][name=paymentMethod]:checked' ).val();

var dob = $( '#p_method_adyen_hpp_' + paymentMethod + '_dob' );
if ( dob ) {
$( "#dob" ).val( dob.val() );
Expand All @@ -90,6 +97,11 @@ var AdyenCheckoutHybris = (function () {
if ( ssn ) {
$( "#socialSecurityNumber" ).val( ssn.val() );
}

var terminalId = $( '#adyen_pos_terminal' );
if ( terminalId ) {
$( "#terminalId" ).val( terminalId.val() );
}
},

/**
Expand Down Expand Up @@ -189,6 +201,10 @@ var AdyenCheckoutHybris = (function () {
} catch (e) {
console.log('Something went wrong trying to mount the iDEAL component: ${e}');
}
},

showSpinner: function () {
document.getElementById("spinner_wrapper").style.display = "flex";
}
};
})();
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=6.1.1
version.api=6.1.1
version=6.2.0
version.api=6.2.0
Loading

0 comments on commit cd83937

Please sign in to comment.