Skip to content

Commit

Permalink
AD-304: Fix to click to pay locale
Browse files Browse the repository at this point in the history
  • Loading branch information
kpieloch committed Dec 18, 2024
1 parent 70a617b commit 2465cd4
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class Payment extends React.Component<Props, State> {
enableStoreDetails: this.props.adyenConfig.showRememberTheseDetails,
clickToPayConfiguration: {
merchantDisplayName: this.props.adyenConfig.merchantDisplayName,
shopperEmail: this.props.adyenConfig.shopperEmail
shopperEmail: this.props.adyenConfig.shopperEmail,
locale: this.props.adyenConfig.clicktoPayLocale,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const adyenConfigInitialState : AdyenConfigData = {
storedPaymentMethodList: [],
merchantDisplayName: "",
shopperEmail: "",
clicktoPayLocale: "",
}

export function adyenConfigReducer(adyenConfig: AdyenConfigData, action: RootAction): AdyenConfigData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface AdyenConfigData {
sepaDirectDebit: boolean;
merchantDisplayName: string,
shopperEmail: string,
clicktoPayLocale: string,
}

interface SessionData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
<editorArea:attribute qualifier="expressPaymentConfig.paypalExpressEnabledOnProduct" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<editorArea:attribute qualifier="expressPaymentConfig.amazonPayExpressEnabledOnProduct" editor="com.hybris.cockpitng.editor.defaultboolean"/>
</editorArea:section>
<editorArea:section name="hmc.adyen.clicktopat">
<editorArea:attribute qualifier="clickToPayLocale" />
</editorArea:section>
<editorArea:section name="hmc.adyen.amazonpay">
<editorArea:attribute qualifier="amazonpayPublicKey"/>
<editorArea:attribute qualifier="amazonpayEnvironment"/>
Expand Down
4 changes: 4 additions & 0 deletions adyenv6core/resources/adyenv6core-items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@
<description>Configuration for express payment methods</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="clickToPayLocale" type="java.lang.String">
<description>Click to Pay Locale in form eq. en_US</description>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>

Expand Down
14 changes: 10 additions & 4 deletions adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public class CheckoutConfigDTO {
private boolean showComboCard;
private boolean showPos;
private boolean immediateCapture;
private String countryCode;
private String countryCode;
private boolean cardHolderNameRequired;
private boolean sepaDirectDebit;
private BigDecimal amountDecimal;
private ExpressPaymentConfigDto expressPaymentConfig;
private String merchantDisplayName;
private String shopperEmail;
private String clickToPayLocale;

// Getters and setters for the new field
public ExpressPaymentConfigDto getExpressPaymentConfig() {
Expand All @@ -54,9 +55,6 @@ public void setExpressPaymentConfig(ExpressPaymentConfigDto expressPaymentConfig
this.expressPaymentConfig = expressPaymentConfigDto;
}




public List<PaymentMethod> getAlternativePaymentMethods() {
return alternativePaymentMethods;
}
Expand Down Expand Up @@ -288,4 +286,12 @@ public String getShopperEmail() {
public void setShopperEmail(String shopperEmail) {
this.shopperEmail = shopperEmail;
}

public String getClickToPayLocale() {
return clickToPayLocale;
}

public void setClickToPayLocale(String clickToPayLocale) {
this.clickToPayLocale = clickToPayLocale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ public CheckoutConfigDTOBuilder setShopperEmail(String shopperEmail) {
return this;
}

public CheckoutConfigDTOBuilder setClickToPayLocale(String clickToPayLocale) {
checkoutConfigDTO.setClickToPayLocale(clickToPayLocale);
return this;
}

public CheckoutConfigDTO build() {
return checkoutConfigDTO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,17 @@
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -225,7 +235,7 @@ public class DefaultAdyenCheckoutFacade implements AdyenCheckoutFacade {
public static final String MODEL_CONNECTED_TERMINAL_LIST = "connectedTerminalList";
public static final String MODEL_ENVIRONMENT_MODE = "environmentMode";
public static final String MODEL_AMOUNT = "amount";
public static final String MODEL_AMOUNT_DECIMAL= "amountDecimal";
public static final String MODEL_AMOUNT_DECIMAL = "amountDecimal";
public static final String MODEL_IMMEDIATE_CAPTURE = "immediateCapture";
public static final String MODEL_PAYPAL_MERCHANT_ID = "paypalMerchantId";
public static final String MODEL_COUNTRY_CODE = "countryCode";
Expand Down Expand Up @@ -433,7 +443,7 @@ public OrderData authorisePayment(final HttpServletRequest request, final CartDa
RequestInfo requestInfo = new RequestInfo(request);
requestInfo.setShopperLocale(getShopperLocale());

PaymentResponse paymentResponse = getAdyenPaymentService().processPaymentRequest(cartData,null, requestInfo, customer);
PaymentResponse paymentResponse = getAdyenPaymentService().processPaymentRequest(cartData, null, requestInfo, customer);
PaymentResponse.ResultCodeEnum resultCode = paymentResponse.getResultCode();
PaymentResponseAction action = paymentResponse.getAction();

Expand Down Expand Up @@ -765,7 +775,7 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException {

CheckoutConfigDTOBuilder checkoutConfigDTOBuilder = new CheckoutConfigDTOBuilder();

checkoutConfigDTOBuilder
checkoutConfigDTOBuilder
.setPaymentMethods(paymentMethods)
.setConnectedTerminalList(connectedTerminalList)
.setStoredPaymentMethodList(storedPaymentMethodList)
Expand All @@ -789,7 +799,8 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException {
.setCardHolderNameRequired(getHolderNameRequired())
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue())
.setMerchantDisplayName(baseStore.getName())
.setShopperEmail(customerModel.getContactEmail());
.setShopperEmail(customerModel.getContactEmail())
.setClickToPayLocale(baseStore.getClickToPayLocale());

ExpressPaymentConfigModel expressPaymentConfigModel = baseStore.getExpressPaymentConfig();
if (expressPaymentConfigModel != null) {
Expand Down Expand Up @@ -935,7 +946,8 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException {
.setSepaDirectDebit(sepaDirectDebit)
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue())
.setMerchantDisplayName(baseStore.getName())
.setShopperEmail(customerModel.getContactEmail());
.setShopperEmail(customerModel.getContactEmail())
.setClickToPayLocale(baseStore.getClickToPayLocale());

ExpressPaymentConfigModel expressPaymentConfigModel = baseStore.getExpressPaymentConfig();
if (expressPaymentConfigModel != null) {
Expand Down Expand Up @@ -1031,7 +1043,7 @@ protected Map<String, String> getApplePayConfigFromPaymentMethods(List<PaymentMe
protected CreateCheckoutSessionResponse getAdyenSessionData(final boolean storePaymentMethod) throws ApiException {
try {
final CartData cartData = getCheckoutFacade().getCheckoutCart();
return getAdyenPaymentService().getPaymentSessionData(cartData,storePaymentMethod);
return getAdyenPaymentService().getPaymentSessionData(cartData, storePaymentMethod);
} catch (JsonProcessingException e) {
LOGGER.error("Processing json failed. ", e);
return null;
Expand Down Expand Up @@ -1142,7 +1154,7 @@ protected void initializeApplePayExpressDataInternal(BigDecimal amountValue, Str
model.addAttribute(MODEL_AMOUNT_DECIMAL, amountValue);
model.addAttribute(MODEL_DF_URL, getAdyenPaymentService().getDeviceFingerprintUrl());
model.addAttribute(MODEL_CHECKOUT_SHOPPER_HOST, getCheckoutShopperHost());
if(baseStore.getExpressPaymentConfig()!=null) {
if (baseStore.getExpressPaymentConfig() != null) {
model.addAttribute(EXPRESS_PAYMENT_CONFIG, getExpressPaymentConfigDto(baseStore.getExpressPaymentConfig()));
}
}
Expand Down Expand Up @@ -1636,7 +1648,7 @@ public void restoreCartFromOrderOCC(String orderCode) throws CalculationExceptio
restoreCartFromOrderInternal(orderModel);
}

protected void restoreCartFromOrderInternal(final OrderModel orderModel) throws CalculationException, InvalidCartException{
protected void restoreCartFromOrderInternal(final OrderModel orderModel) throws CalculationException, InvalidCartException {

// Get cart from session
CartModel cartModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static String extractPaymentMethodType(PlaceOrderRequest placeOrderReque
}
}

private void preHandleAndValidateRequest(PlaceOrderRequest placeOrderRequest, String adyenPaymentMethod) {
protected void preHandleAndValidateRequest(PlaceOrderRequest placeOrderRequest, String adyenPaymentMethod) {
final BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(placeOrderRequest, "placeOrderRequest");

boolean showRememberDetails = getAdyenCheckoutApiFacade().showRememberDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ public void validate(Object o, Errors errors) {
if (StringUtils.isEmpty(cardDetails.getEncryptedSecurityCode())) {
errors.reject("checkout.error.paymentmethod.cse.missing");
}
} else if (StringUtils.isEmpty(cardDetails.getEncryptedCardNumber())
|| StringUtils.isEmpty(cardDetails.getEncryptedExpiryMonth())
|| StringUtils.isEmpty(cardDetails.getEncryptedExpiryYear())
|| (cardHolderNameRequired && StringUtils.isEmpty(cardDetails.getHolderName()))) {
errors.reject("checkout.error.paymentmethod.cse.missing");
} else if(StringUtils.isNotEmpty(cardDetails.getSrcScheme())){
if (StringUtils.isEmpty(cardDetails.getSrcCorrelationId()) || StringUtils.isEmpty(cardDetails.getSrcDigitalCardId())) {
errors.reject("checkout.error.paymentmethod.cse.missing");
}

} else if(StringUtils.isNotEmpty(cardDetails.getEncryptedCardNumber())) {
if (StringUtils.isEmpty(cardDetails.getEncryptedExpiryMonth())
|| StringUtils.isEmpty(cardDetails.getEncryptedExpiryYear())
|| (cardHolderNameRequired && StringUtils.isEmpty(cardDetails.getHolderName()))) {
errors.reject("checkout.error.paymentmethod.cse.missing");
}
}

//Check remember these details
Expand Down Expand Up @@ -86,9 +92,9 @@ public void validate(Object o, Errors errors) {
protected void validateCountrySpecificFields(Errors errors) {
String countryIso = (String) errors.getFieldValue("billingAddress.countryIso");
if (countryIso != null) {
switch (countryIso){
switch (countryIso) {
case "US", "CA", "JP", "CN":
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.regionIso","address.regionIso.invalid");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.regionIso", "address.regionIso.invalid");
break;
default:
break;
Expand Down

0 comments on commit 2465cd4

Please sign in to comment.