Skip to content

Commit

Permalink
Merge pull request #244 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 9.3.0
  • Loading branch information
rkewlani authored Mar 17, 2021
2 parents 59ff141 + 3ab887a commit b626a10
Show file tree
Hide file tree
Showing 25 changed files with 210 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @rkewlani @martinsrenato @Aleffio @rikterbeek
* @rkewlani @martinsrenato @Aleffio @saquibsayyad
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Credit Card payments are supported using Checkout Components.

[Apple Pay](https://docs.adyen.com/payment-methods/apple-pay/) is supported using Checkout Components.


### Ratepay

Ratepay is supported via Adyen API.
Expand All @@ -82,6 +81,9 @@ Ratepay is supported via Adyen API.

[Boleto](https://docs.adyen.com/payment-methods/boleto-bancario) is supported via Adyen API.

### Pix
[Pix](https://docs.adyen.com/payment-methods/pix) is supported via Adyen component and API.

### Paypal Express Checkout Shortcut

Requires both Adyen API and HPP credentials.
Expand Down Expand Up @@ -149,6 +151,11 @@ POS timeout (time calculated since initiating a payment) is max time to keep ter
```
pos.totaltimeout = 130
```
## Credit card holder name configuration
By default Credit card holder name is a mandatory field, You can disable it by setting following property in `local.properties` file.
```
isCardHolderNameRequired = false
```

## Pending Order Timeout configuration
By default, an order remains in PAYMENT_PENDING status in order management for 1 hour and it is configured in dynamic order process defintiion file.
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 com.adyen.model.checkout.DefaultPaymentMethodDetails;
import com.adyen.model.checkout.PaymentMethodDetails;
import com.adyen.model.checkout.PaymentsResponse;
import com.adyen.model.checkout.details.ApplePayDetails;
Expand Down Expand Up @@ -60,6 +61,7 @@
import java.util.Map;

import static com.adyen.v6.constants.AdyenControllerConstants.COMPONENT_PREFIX;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_PIX;

@RestController
@RequestMapping(COMPONENT_PREFIX)
Expand Down Expand Up @@ -95,12 +97,15 @@ public String componentPayment(final HttpServletRequest request) throws AdyenCom
String paymentMethod = cartData.getAdyenPaymentMethod();

PaymentMethodDetails paymentMethodDetails;
if("paypal".equals(paymentMethod)) {
if(PayPalDetails.PAYPAL.equals(paymentMethod)) {
paymentMethodDetails = gson.fromJson(requestJson.get("paymentMethodDetails"), PayPalDetails.class);
} else if("mbway".equals(paymentMethod)) {
} else if(MbwayDetails.MBWAY.equals(paymentMethod)) {
paymentMethodDetails = gson.fromJson(requestJson.get("paymentMethodDetails"), MbwayDetails.class);
} else if("applepay".equals(paymentMethod)) {
} else if(ApplePayDetails.APPLEPAY.equals(paymentMethod)) {
paymentMethodDetails = gson.fromJson(requestJson.get("paymentMethodDetails"), ApplePayDetails.class);
} else if(PAYMENT_METHOD_PIX.equals(paymentMethod)) {
paymentMethodDetails = new DefaultPaymentMethodDetails();
paymentMethodDetails.setType(PAYMENT_METHOD_PIX);
} else {
throw new InvalidCartException("checkout.error.paymentethod.formentry.invalid");
}
Expand Down Expand Up @@ -163,8 +168,10 @@ public String adyenComponentExceptionHandler(AdyenComponentException e) {
protected void validateOrderForm(JsonObject requestJson) throws InvalidCartException {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
Boolean termsCheck = gson.fromJson(requestJson.get("termsCheck"), Boolean.class);
JsonObject paymentMethodDetails = requestJson.get("paymentMethodDetails").getAsJsonObject();
String paymentMethod = gson.fromJson(paymentMethodDetails.get("type"), String.class);

if(termsCheck == null || !termsCheck) {
if(!PAYMENT_METHOD_PIX.equals(paymentMethod) &&(termsCheck == null || !termsCheck)) {
throw new InvalidCartException("checkout.error.terms.not.accepted");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import static com.adyen.v6.constants.AdyenControllerConstants.CART_PREFIX;
import static com.adyen.v6.constants.AdyenControllerConstants.SELECT_PAYMENT_METHOD_PREFIX;
import static com.adyen.v6.constants.AdyenControllerConstants.SUMMARY_CHECKOUT_PREFIX;
import static com.adyen.v6.constants.Adyenv6coreConstants.AFTERPAY_TOUCH;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_APPLEPAY;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_BOLETO;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_CC;
Expand Down Expand Up @@ -254,6 +255,10 @@ public String placeOrder(@ModelAttribute("placeOrderForm") final PlaceOrderForm
LOGGER.debug("PaymentResponse resultCode is REDIRECTSHOPPER, redirecting shopper to 3DS flow");
return redirectTo3DSValidation(model, paymentsResponse);
}
if (AFTERPAY_TOUCH.equals(adyenPaymentMethod)) {
LOGGER.debug("PaymentResponse resultCode is REDIRECTSHOPPER, redirecting shopper to afterpaytouch page");
return REDIRECT_PREFIX + paymentsResponse.getAction().getUrl();
}
LOGGER.debug("PaymentResponse resultCode is REDIRECTSHOPPER, redirecting shopper to local payment method page");
return REDIRECT_PREFIX + paymentsResponse.getRedirect().getUrl();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ payment.method.terminal.selector=Select your terminal
checkout.summary.spinner.message=Please wait while your payment is processed. Do not click back or refresh the page.
checkout.summary.component.mbway.payment=Provide your MB WAY account data to finalize your payment
checkout.summary.component.notavailable=This payment method is not available on your current browser or device
checkout.summary.component.pix.generateqr = Generate QR Code
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ payment.method.terminal.selector=Select your terminal
checkout.summary.spinner.message=Please wait while your payment is processed. Do not click back or refresh the page.
checkout.summary.component.mbway.payment=Provide your MB WAY account data to finalize your payment
checkout.summary.component.notavailable=This payment method is not available on your current browser or device
checkout.summary.component.pix.generateqr = Generate QR Code
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ payment.method.last.name=Sobrenome
payment.method.issuer.selector=Selecione o banco
payment.method.terminal.selector=Selecione o terminal

checkout.summary.spinner.message=Aguarde...
checkout.summary.spinner.message=Aguarde...
checkout.summary.component.pix.generateqr = Gerar QR Code
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@
<span>
<spring:theme code="payment.method.social.security.number"/>
</span>
<input id="p_method_adyen_hpp_${brandCode}_ssn" class="p_method_adyen_hpp_ssn" type="text">
</label>
<input id="p_method_adyen_hpp_${brandCode}_ssn" class="p_method_adyen_hpp_ssn" type="text">
</c:when>
<c:otherwise>
<label for="p_method_adyen_hpp_${brandCode}_ssn">
<span>
<spring:theme code="payment.method.personal.number"/>
</span>
<input id="p_method_adyen_hpp_${brandCode}_ssn" class="p_method_adyen_hpp_ssn" type="text" size="4" title="personal number">
</label>
<input id="p_method_adyen_hpp_${brandCode}_ssn" class="p_method_adyen_hpp_ssn" type="text" size="4" title="personal number">
</c:otherwise>
</c:choose>
</c:if>
Expand All @@ -109,25 +109,23 @@
<span>
<spring:theme code="payment.method.first.name"/>
</span>
<input id="p_method_adyen_hpp_${brandCode}_first_name"
type="text"
name="${brandCode}_firstName"
value="${cartData.deliveryAddress.firstName}">
</label>

<input id="p_method_adyen_hpp_${brandCode}_first_name"
type="text"
name="firstName"
value="${cartData.deliveryAddress.firstName}">
</c:if>

<c:if test="${showLastName}">
<label for="p_method_adyen_hpp_${brandCode}_last_name">
<span>
<spring:theme code="payment.method.last.name"/>
</span>
<input id="p_method_adyen_hpp_${brandCode}_last_name"
type="text"
name="${brandCode}_lastName"
value="${cartData.deliveryAddress.lastName}">
</label>

<input id="p_method_adyen_hpp_${brandCode}_last_name"
type="text"
name="lastName"
value="${cartData.deliveryAddress.lastName}">
</c:if>

<c:if test="${brandCode eq 'afterpay_default'}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@
<spring:url value="/checkout/multi/termsAndConditions" var="getTermsAndConditionsUrl"/>

<%-- Components --%>
<c:if test="${selectedPaymentMethod eq 'mbway' || selectedPaymentMethod eq 'paypal' || selectedPaymentMethod eq 'applepay'}">
<c:if test="${selectedPaymentMethod eq 'mbway' || selectedPaymentMethod eq 'paypal' || selectedPaymentMethod eq 'applepay' || selectedPaymentMethod eq 'pix'}">
<%-- Render Paypal or Apple Pay button --%>
<c:if test="${selectedPaymentMethod eq 'paypal' || selectedPaymentMethod eq 'applepay'}">
<c:if test="${selectedPaymentMethod eq 'paypal' || selectedPaymentMethod eq 'applepay' || selectedPaymentMethod eq 'pix'}">
<div class="checkbox">
<label>
<input type="checkbox" id="terms-conditions-check-${label}" />
<spring:theme var="readTermsAndConditions" code="checkout.summary.placeOrder.readTermsAndConditions" arguments="${fn:escapeXml(getTermsAndConditionsUrl)}" htmlEscape="false"/>
${ycommerce:sanitizeHTML(readTermsAndConditions)}
</label>
</div>
<div id="adyen-component-button-container-${label}"></div>

<c:choose>
<c:when test="${selectedPaymentMethod eq 'pix'}">
<button id="generateqr-${label}" type="submit" class="btn btn-primary btn-block">
<spring:theme code="checkout.summary.component.pix.generateqr" text="Generate QR Code" />
</button>
<div id="pix-container-${label}"></div>
</c:when>
<c:otherwise>
<div id="adyen-component-button-container-${label}"></div>
</c:otherwise>
</c:choose>
</c:if>

<c:if test="${selectedPaymentMethod eq 'mbway'}">
Expand All @@ -33,7 +44,7 @@
</c:if>

<%-- Paypal and Apple Pay has it's own button --%>
<c:if test="${selectedPaymentMethod ne 'paypal' && selectedPaymentMethod ne 'applepay'}">
<c:if test="${selectedPaymentMethod ne 'paypal' && selectedPaymentMethod ne 'applepay' && selectedPaymentMethod ne 'pix'}">
<form:form action="${placeOrderUrl}" id="placeOrderForm-${label}" modelAttribute="placeOrderForm">
<div class="checkbox">
<label> <form:checkbox id="terms-conditions-check-${label}" path="termsCheck" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<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/3.19.0/adyen.js"></script>
<script type="text/javascript" src="https://${checkoutShopperHost}/checkoutshopper/sdk/3.23.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/3.19.0/adyen.css"/>
<link rel="stylesheet" href="https://${checkoutShopperHost}/checkoutshopper/sdk/3.23.0/adyen.css"/>

<script type="text/javascript">
AdyenCheckoutHybris.initiateCheckout("${shopperLocale}", "${environmentMode}", "${clientKey}");
Expand All @@ -40,6 +40,11 @@
AdyenCheckoutHybris.initiateApplePay(amountJS, "${countryCode}", "${applePayMerchantIdentifier}", "${applePayMerchantName}", "visible-xs");
</c:when>
<c:when test="${selectedPaymentMethod eq 'pix'}">
AdyenCheckoutHybris.initiatePix("hidden-xs");
AdyenCheckoutHybris.initiatePix("visible-xs");
</c:when>
<%-- API only payments methods --%>
<c:otherwise>
AdyenCheckoutHybris.configureButton($( "#placeOrderForm-hidden-xs" ), true, "hidden-xs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<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/3.19.0/adyen.js"></script>
<script type="text/javascript" src="https://${checkoutShopperHost}/checkoutshopper/sdk/3.23.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/3.19.0/adyen.css"/>
<link rel="stylesheet" href="https://${checkoutShopperHost}/checkoutshopper/sdk/3.23.0/adyen.css"/>

<script type="text/javascript">
AdyenCheckoutHybris.initiateCheckout( "${shopperLocale}", "${environmentMode}", "${clientKey}" );
Expand All @@ -30,7 +30,7 @@
<c:forEach items="${allowedCards}" var="allowedCard">
allowedCards.push( "${allowedCard.code}" );
</c:forEach>
AdyenCheckoutHybris.initiateCard( allowedCards, ${showRememberTheseDetails} );
AdyenCheckoutHybris.initiateCard( allowedCards, ${showRememberTheseDetails}, ${cardHolderNameRequired} );
</c:if>
Expand Down Expand Up @@ -117,6 +117,8 @@
<form:hidden path="issuerId"/>
<form:hidden path="dob"/>
<form:hidden path="socialSecurityNumber"/>
<form:hidden path="firstName"/>
<form:hidden path="lastName"/>
<form:hidden path="dfValue"/>
<form:hidden path="cardHolder"/>
<form:hidden path="cardBrand"/>
Expand Down Expand Up @@ -188,7 +190,10 @@
brandCode="${paymentMethod.type}"
name="${paymentMethod.name}"
showDob="${paymentMethod.type=='ratepay'}"
showSocialSecurityNumber="${showSocialSecurityNumber}"
showFirstName="${paymentMethod.type=='pix'}"
showLastName="${paymentMethod.type=='pix'}"
showSocialSecurityNumber="${showSocialSecurityNumber || paymentMethod.type=='pix'}"
countryCode="${countryCode}"
/>
</c:forEach>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ var AdyenCheckoutHybris = (function () {
(this.isDebitCard() && !this.isValidBrandType());

if ( isInvalidCard ) {
window.alert( 'This ' + this.getCardType() + ' card is not allowed' );
window.alert('Please check your card details.');
this.card.showValidation();
document.getElementById("card-div").scrollIntoView();
return false;
}
this.copyCardData();
Expand Down Expand Up @@ -125,6 +127,7 @@ var AdyenCheckoutHybris = (function () {
if (!this.afterPay.state.isValid) {
window.alert("Please fill all the details");
this.afterPay.showValidation();
document.getElementById("afterpay-container").scrollIntoView();
return false;
}
var dob = $("input[name=dateOfBirth]").val();
Expand Down Expand Up @@ -184,6 +187,16 @@ var AdyenCheckoutHybris = (function () {
if ( terminalId ) {
$( "#terminalId" ).val( terminalId.val() );
}

var firstName = $( '#p_method_adyen_hpp_' + paymentMethod + '_first_name' ).val();
if (firstName) {
$( "#firstName" ).val(firstName);
}

var lastName = $( '#p_method_adyen_hpp_' + paymentMethod + '_last_name' ).val();
if (lastName) {
$( "#lastName" ).val(lastName);
}
},

/**
Expand Down Expand Up @@ -232,12 +245,12 @@ var AdyenCheckoutHybris = (function () {
this.oneClickCards[storedCard.storedPaymentMethodId] = oneClickCard;
},

initiateCard: function (allowedCards, showRememberDetails) {
initiateCard: function (allowedCards, showRememberDetails, cardHolderNameRequired) {
var context = this;
this.card = this.checkout.create( 'card', {
type: 'card',
hasHolderName: true,
holderNameRequired: true,
holderNameRequired: cardHolderNameRequired,
enableStoreDetails: showRememberDetails,
brands: allowedCards,
onBrand: copyCardBrand
Expand Down Expand Up @@ -457,6 +470,30 @@ var AdyenCheckoutHybris = (function () {
}
},

initiatePix: function (label) {
$("#generateqr-" + label).click(function () {
AdyenCheckoutHybris.showSpinner();
if (!AdyenCheckoutHybris.isTermsAccepted(label)) {
AdyenCheckoutHybris.handleResult(ErrorMessages.TermsNotAccepted, true)
} else {
$("#generateqr-" + label).hide();
$(".checkbox").hide();
var actionHandler = {
handleAction : function (action) {
AdyenCheckoutHybris.checkout.createFromAction(action, {
onAdditionalDetails : (state) => {
AdyenCheckoutHybris.hideSpinner();
AdyenCheckoutHybris.submitDetails(state.data, AdyenCheckoutHybris.handleResult);
}
}).mount('#pix-container-' + label);
AdyenCheckoutHybris.hideSpinner();
}
};
AdyenCheckoutHybris.makePayment({ type: "pix" }, actionHandler, AdyenCheckoutHybris.handleResult, label);
}
});
},

configureButton: function (form, useSpinner, label) {
$(document).ready(function () {
$("#placeOrder-" + label).click(function () {
Expand Down Expand Up @@ -553,10 +590,12 @@ var AdyenCheckoutHybris = (function () {
showSpinner: function () {
document.getElementById("spinner_wrapper").style.display = "flex";
},

hideSpinner: function () {
document.getElementById("spinner_wrapper").style.display = "none";
},
enablePlaceOrder: function (label) {
//hide spinner
document.getElementById("spinner_wrapper").style.display = "none";
this.hideSpinner();
//enable button
$("#placeOrder-" + label).prop('disabled', false);
}
Expand Down
Loading

0 comments on commit b626a10

Please sign in to comment.