Skip to content

Commit

Permalink
Merge pull request #181 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 6.5.0
  • Loading branch information
rkewlani authored May 28, 2020
2 parents 6e54e82 + ace2d9a commit 2ee7343
Show file tree
Hide file tree
Showing 27 changed files with 662 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pos.totaltimeout = 130
https://docs.adyen.com/developers/plugins/hybris

## Support
You can create issues in this repository. In case of specific problems with your account, please contact support@adyen.com.
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420).

## Contributing
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface MultiStepCheckout
String Validate3DSecurePaymentPage = ADDON_PREFIX + "pages/checkout/multi/3d-secure-payment-validation";
String HppPaymentPage = ADDON_PREFIX + "pages/checkout/multi/hpp-payment";
String Validate3DS2PaymentPage = ADDON_PREFIX + "pages/checkout/multi/3ds2_payment";
String BillingAddressformPage = ADDON_PREFIX + "pages/checkout/multi/billingAddressForm";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
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.lang.StringUtils;
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.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
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.AddressForm;
import com.adyen.v6.forms.AdyenPaymentForm;
import de.hybris.platform.acceleratorstorefrontcommons.annotations.RequireHardLogIn;
import de.hybris.platform.acceleratorstorefrontcommons.checkout.steps.CheckoutStep;
Expand All @@ -49,6 +55,11 @@
import de.hybris.platform.cms2.exceptions.CMSItemNotFoundException;
import de.hybris.platform.cms2.model.pages.ContentPageModel;
import de.hybris.platform.commercefacades.order.data.CartData;
import de.hybris.platform.commercefacades.user.UserFacade;
import de.hybris.platform.commercefacades.user.data.AddressData;
import de.hybris.platform.commercefacades.user.data.CountryData;
import de.hybris.platform.commercefacades.user.data.TitleData;
import static com.adyen.v6.constants.AdyenControllerConstants.Views.Pages.MultiStepCheckout.BillingAddressformPage;
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;
Expand All @@ -71,6 +82,23 @@ public class SelectPaymentMethodCheckoutStepController extends AbstractCheckoutS
@Resource(name = "adyenCheckoutFacade")
private AdyenCheckoutFacade adyenCheckoutFacade;

@Resource(name = "userFacade")
private UserFacade userFacade;

@ModelAttribute("billingCountries")
public Collection<CountryData> getBillingCountries() {
return getCheckoutFacade().getBillingCountries();
}

@ModelAttribute("titles")
public Collection<TitleData> getBillingTitleCodes() {
return getUserFacade().getTitles();
}

protected UserFacade getUserFacade() {
return userFacade;
}

@Autowired
private HttpServletRequest httpServletRequest;

Expand All @@ -87,10 +115,12 @@ public String enterStep(final Model model, final RedirectAttributes redirectAttr
model.addAttribute("metaRobots", "noindex,nofollow");
model.addAttribute("hasNoPaymentInfo", getCheckoutFlowFacade().hasNoPaymentInfo());
model.addAttribute(BREADCRUMBS_KEY, getResourceBreadcrumbBuilder().getBreadcrumbs(CHECKOUT_MULTI_PAYMENT_METHOD_BREADCRUMB));
model.addAttribute(ADYEN_PAYMENT_FORM, new AdyenPaymentForm());

if (! model.containsAttribute(ADYEN_PAYMENT_FORM)) {
model.addAttribute(ADYEN_PAYMENT_FORM, new AdyenPaymentForm());
}
model.addAttribute(CSE_GENERATION_TIME, fromCalendar(Calendar.getInstance()));
model.addAttribute(CART_DATA_ATTR, cartData);
model.addAttribute("deliveryAddress", cartData.getDeliveryAddress());
model.addAttribute("expiryYears", getExpiryYears());

try {
Expand All @@ -113,6 +143,40 @@ public String enterStep(final Model model, final RedirectAttributes redirectAttr
return AdyenControllerConstants.Views.Pages.MultiStepCheckout.SelectPaymentMethod;
}


@RequestMapping(value = "/billingaddressform", method = RequestMethod.GET)
public String getCountryAddressForm(@RequestParam("countryIsoCode") final String countryIsoCode,
@RequestParam("useAdyenDeliveryAddress") final boolean useAdyenDeliveryAddress,
final Model model) {

model.addAttribute("supportedCountries", getCountries());
model.addAttribute("regions", getI18NFacade().getRegionsForCountryIso(countryIsoCode));
model.addAttribute("country", countryIsoCode);

final AdyenPaymentForm adyenPaymentForm = new AdyenPaymentForm();
AddressForm addressForm = new AddressForm();

if (useAdyenDeliveryAddress) {
final AddressData deliveryAddress = getCheckoutFacade().getCheckoutCart().getDeliveryAddress();
if (deliveryAddress.getRegion() != null && ! StringUtils.isEmpty(deliveryAddress.getRegion().getIsocode())) {
addressForm.setRegionIso(deliveryAddress.getRegion().getIsocodeShort());
}
addressForm.setTitleCode(deliveryAddress.getTitleCode());
addressForm.setFirstName(deliveryAddress.getFirstName());
addressForm.setLastName(deliveryAddress.getLastName());
addressForm.setLine1(deliveryAddress.getLine1());
addressForm.setLine2(deliveryAddress.getLine2());
addressForm.setTownCity(deliveryAddress.getTown());
addressForm.setPostcode(deliveryAddress.getPostalCode());
addressForm.setCountryIsoCode(deliveryAddress.getCountry().getIsocode());
addressForm.setPhoneNumber(deliveryAddress.getPhone());
}
adyenPaymentForm.setBillingAddress(addressForm);
model.addAttribute("adyenPaymentForm", adyenPaymentForm);
return BillingAddressformPage;
}


@RequestMapping(value = "", method = POST)
@RequireHardLogIn
public String setPaymentMethod(final Model model,
Expand All @@ -122,9 +186,13 @@ public String setPaymentMethod(final Model model,
LOGGER.debug("PaymentForm: " + adyenPaymentForm);

adyenCheckoutFacade.handlePaymentForm(adyenPaymentForm, bindingResult);
if (bindingResult.hasErrors()) {

if (bindingResult.hasGlobalErrors()|| bindingResult.hasErrors()) {
LOGGER.debug(bindingResult.getAllErrors().stream().map(error -> (error.getCode())).reduce((x, y) -> (x = x + y)));
GlobalMessages.addErrorMessage(model, "checkout.error.paymentethod.formentry.invalid");
if (adyenPaymentForm.getBillingAddress() != null) {
adyenPaymentForm.resetFormExceptBillingAddress();
}
return enterStep(model, redirectAttributes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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.
checkout.error.billing.address=Some fields were not filled in correctly. Please check if your details are correct

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
@@ -0,0 +1,29 @@
<%@ attribute name="supportedCountries" required="false" type="java.util.List" %>
<%@ attribute name="regions" required="false" type="java.util.List" %>
<%@ attribute name="country" required="false" type="java.lang.String" %>
<%@ attribute name="tabindex" required="false" type="java.lang.String" %>
<%@ taglib prefix="formElement" tagdir="/WEB-INF/tags/responsive/formElement" %>
<%@ taglib prefix="address" tagdir="/WEB-INF/tags/addons/adyenv6b2ccheckoutaddon/responsive" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<div id="billingAdyenCountrySelector" data-address-code="${fn:escapeXml(cartData.deliveryAddress.id)}" data-country-iso-code="${fn:escapeXml(cartData.deliveryAddress.country.isocode)}"
data-display-title="false" class="clearfix">
<formElement:formSelectBox idKey="address.country"
labelKey="address.country"
path="billingAddress.countryIsoCode"
mandatory="true"
skipBlank="false"
skipBlankMessageKey="address.selectCountry"
items="${supportedCountries}"
itemValue="isocode"
tabindex="${tabindex}"
selectCSSClass="form-control"/>
</div>

<div id="adyenBillingAddressForm" class="billingAddressForm">
<address:billingAddressFormElements regions="${regions}"
country="${country}"
tabindex="${tabindex + 1}"/>
</div>


Loading

0 comments on commit 2ee7343

Please sign in to comment.