Skip to content

Commit

Permalink
Merge pull request #479 from Adyen/feature/AD-321
Browse files Browse the repository at this point in the history
AD-321: Implement Configuration for Enabling Express Payments
  • Loading branch information
kpieloch authored Nov 26, 2024
2 parents a7c9f04 + 1281b07 commit f0d2ed8
Show file tree
Hide file tree
Showing 11 changed files with 256 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
id: '${sessionData.id}',
sessionData: '${sessionData.sessionData}'
},
countryCode: 'US'
countryCode: 'US',
googlePayExpressEnabledOnCart: ${expressPaymentConfig.googlePayExpressEnabledOnCart},
applePayExpressEnabledOnCart: ${expressPaymentConfig.applePayExpressEnabledOnCart},
googlePayExpressEnabledOnProduct: ${expressPaymentConfig.googlePayExpressEnabledOnProduct},
applePayExpressEnabledOnProduct: ${expressPaymentConfig.applePayExpressEnabledOnProduct},
}
window.onload = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ var AdyenExpressCheckoutHybris = (function () {
initExpressCheckout: async function (params, config) {
var checkoutPromise = this.initiateCheckout(config);
checkoutPromise.then((checkout) => {
this.initiateGooglePayExpress(checkout, params)
this.initiateApplePayExpress(checkout, params)
if(params.pageType === 'cart' && config.googlePayExpressEnabledOnCart || params.pageType === 'PDP' && config.googlePayExpressEnabledOnProduct) {
this.initiateGooglePayExpress(checkout, params)
}
if(params.pageType=== 'cart' && config.applePayExpressEnabledOnCart || params.pageType === 'PDP' && config.applePayExpressEnabledOnProduct) {
this.initiateApplePayExpress(checkout, params)
}
});
},
initiateApplePayExpress: async function (checkout, params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
<editorArea:attribute qualifier="adyenNotificationPassword" editor="com.hybris.cockpitng.editor.defaultpassword"/>
<editorArea:attribute qualifier="adyenNotificationHMACKey"/>
</editorArea:section>
<editorArea:section name="hmc.adyen.expressPayments">
<editorArea:attribute qualifier="expressPaymentConfig.googlePayExpressEnabledOnCart" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<editorArea:attribute qualifier="expressPaymentConfig.applePayExpressEnabledOnCart" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<editorArea:attribute qualifier="expressPaymentConfig.paypalExpressEnabledOnCart" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<editorArea:attribute qualifier="expressPaymentConfig.amazonPayExpressEnabledOnCart" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<editorArea:attribute qualifier="expressPaymentConfig.googlePayExpressEnabledOnProduct" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<editorArea:attribute qualifier="expressPaymentConfig.applePayExpressEnabledOnProduct" editor="com.hybris.cockpitng.editor.defaultboolean"/>
<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.amazonpay">
<editorArea:attribute qualifier="amazonpayPublicKey"/>
<editorArea:attribute qualifier="amazonpayEnvironment"/>
Expand Down
50 changes: 50 additions & 0 deletions adyenv6core/resources/adyenv6core-items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,56 @@
<defaultvalue>Boolean.FALSE</defaultvalue>
<modifiers optional="false"/>
</attribute>
<attribute qualifier="expressPaymentConfig" type="ExpressPaymentConfig">
<description>Configuration for express payment methods</description>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>

<itemtype code="ExpressPaymentConfig" generate="true" autocreate="true">
<deployment table="ExpressPaymentConfig" typecode="22939"/>
<attributes>
<attribute qualifier="googlePayExpressEnabledOnCart" type="java.lang.boolean">
<description>Enable Google Pay Express on Cart Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="applePayExpressEnabledOnCart" type="java.lang.boolean">
<description>Enable Apple Pay Express on Cart Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="paypalExpressEnabledOnCart" type="java.lang.boolean">
<description>Enable PayPal Express on Cart Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="amazonPayExpressEnabledOnCart" type="java.lang.boolean">
<description>Enable Amazon Pay Express on Cart Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="googlePayExpressEnabledOnProduct" type="java.lang.boolean">
<description>Enable Google Pay Express on Product Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="applePayExpressEnabledOnProduct" type="java.lang.boolean">
<description>Enable Apple Pay Express on Product Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="paypalExpressEnabledOnProduct" type="java.lang.boolean">
<description>Enable PayPal Express on Product Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
<attribute qualifier="amazonPayExpressEnabledOnProduct" type="java.lang.boolean">
<description>Enable Amazon Pay Express on Product Page</description>
<persistence type="property"/>
<defaultvalue>Boolean.FALSE</defaultvalue>
</attribute>
</attributes>
</itemtype>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ type.basestore.adyenMerchantConfig.description=List of merchants that can be use
type.basestore.l2L3ESDEnabled.name=L2/L3 Enhanced Data Support
type.BaseStore.l2L3ESDEnabled.description=Enable or disable L2/L3 EDS for US MasterCard and Visa transactions (only for US merchants)


type.ExpressPaymentConfig.name=Express Payment Config
type.ExpressPaymentConfig.description=Configuration for Express Payment
type.ExpressPaymentConfig.googlePayExpressEnabledOnCart.name=Google Pay Express Enabled On Cart
type.ExpressPaymentConfig.googlePayExpressEnabledOnCart.description=Enable Google Pay Express on Cart
type.ExpressPaymentConfig.googlePayExpressEnabledOnProduct.name=Google Pay Express Enabled On Product
type.ExpressPaymentConfig.googlePayExpressEnabledOnProduct.description=Enable Google Pay Express on Product
type.ExpressPaymentConfig.applePayExpressEnabledOnCart.name=Apple Pay Express Enabled On Cart
type.ExpressPaymentConfig.applePayExpressEnabledOnCart.description=Enable Apple Pay Express on Cart
type.ExpressPaymentConfig.applePayExpressEnabledOnProduct.name=Apple Pay Express Enabled On Product
type.ExpressPaymentConfig.applePayExpressEnabledOnProduct.description=Enable Apple Pay Express on Product
type.ExpressPaymentConfig.paypalExpressEnabledOnCart.name=PayPal Express Enabled On Cart
type.ExpressPaymentConfig.paypalExpressEnabledOnCart.description=Enable PayPal Express on Cart
type.ExpressPaymentConfig.paypalExpressEnabledOnProduct.name=PayPal Express Enabled On Product
type.ExpressPaymentConfig.paypalExpressEnabledOnProduct.description=Enable PayPal Express on Product
type.ExpressPaymentConfig.amazonPayExpressEnabledOnCart.name=Amazon Pay Express Enabled On Cart
type.ExpressPaymentConfig.amazonPayExpressEnabledOnCart.description=Enable Amazon Pay Express on Cart
type.ExpressPaymentConfig.amazonPayExpressEnabledOnProduct.name=Amazon Pay Express Enabled On Product
type.ExpressPaymentConfig.amazonPayExpressEnabledOnProduct.description=Enable Amazon Pay Express on Product


type.paymentinfo.adyenPaymentMethod.name=Payment Method
type.paymentinfo.adyenIssuerId.name=Issuer ID
type.paymentinfo.adyenAvsResult.name=AVS Result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public final class Adyenv6coreConstants extends GeneratedAdyenv6coreConstants {
public static final String CLEARPAY = "clearpay";
public static final String SHOPPER_LOCALE = "shopperLocale";

public static final String EXPRESS_PAYMENT_CONFIG = "expressPaymentConfig";

private Adyenv6coreConstants() {
//empty to avoid instantiating this constant class
}
Expand Down
12 changes: 12 additions & 0 deletions adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public class CheckoutConfigDTO {
private boolean cardHolderNameRequired;
private boolean sepaDirectDebit;
private BigDecimal amountDecimal;
private ExpressPaymentConfigDto expressPaymentConfig;

// Getters and setters for the new field
public ExpressPaymentConfigDto getExpressPaymentConfig() {
return expressPaymentConfig;
}

public void setExpressPaymentConfig(ExpressPaymentConfigDto expressPaymentConfigDto) {
this.expressPaymentConfig = expressPaymentConfigDto;
}




public List<PaymentMethod> getAlternativePaymentMethods() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public CheckoutConfigDTOBuilder setAmountDecimal(BigDecimal amountDecimal) {
return this;
}

public CheckoutConfigDTOBuilder setExpressPaymentConfig(ExpressPaymentConfigDto expressPaymentConfigDto) {
checkoutConfigDTO.setExpressPaymentConfig(expressPaymentConfigDto);
return this;
}

public CheckoutConfigDTO build() {
return checkoutConfigDTO;
}
Expand Down
77 changes: 77 additions & 0 deletions adyenv6core/src/com/adyen/v6/dto/ExpressPaymentConfigDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.adyen.v6.dto;

public class ExpressPaymentConfigDto {
private boolean googlePayExpressEnabledOnCart;
private boolean applePayExpressEnabledOnCart;
private boolean paypalExpressEnabledOnCart;
private boolean amazonPayExpressEnabledOnCart;
private boolean googlePayExpressEnabledOnProduct;
private boolean applePayExpressEnabledOnProduct;
private boolean paypalExpressEnabledOnProduct;
private boolean amazonPayExpressEnabledOnProduct;


public boolean isGooglePayExpressEnabledOnCart() {
return googlePayExpressEnabledOnCart;
}

public void setGooglePayExpressEnabledOnCart(boolean googlePayExpressEnabledOnCart) {
this.googlePayExpressEnabledOnCart = googlePayExpressEnabledOnCart;
}

public boolean isApplePayExpressEnabledOnCart() {
return applePayExpressEnabledOnCart;
}

public void setApplePayExpressEnabledOnCart(boolean applePayExpressEnabledOnCart) {
this.applePayExpressEnabledOnCart = applePayExpressEnabledOnCart;
}

public boolean isPaypalExpressEnabledOnCart() {
return paypalExpressEnabledOnCart;
}

public void setPaypalExpressEnabledOnCart(boolean paypalExpressEnabledOnCart) {
this.paypalExpressEnabledOnCart = paypalExpressEnabledOnCart;
}

public boolean isAmazonPayExpressEnabledOnCart() {
return amazonPayExpressEnabledOnCart;
}

public void setAmazonPayExpressEnabledOnCart(boolean amazonPayExpressEnabledOnCart) {
this.amazonPayExpressEnabledOnCart = amazonPayExpressEnabledOnCart;
}

public boolean isGooglePayExpressEnabledOnProduct() {
return googlePayExpressEnabledOnProduct;
}

public void setGooglePayExpressEnabledOnProduct(boolean googlePayExpressEnabledOnProduct) {
this.googlePayExpressEnabledOnProduct = googlePayExpressEnabledOnProduct;
}

public boolean isApplePayExpressEnabledOnProduct() {
return applePayExpressEnabledOnProduct;
}

public void setApplePayExpressEnabledOnProduct(boolean applePayExpressEnabledOnProduct) {
this.applePayExpressEnabledOnProduct = applePayExpressEnabledOnProduct;
}

public boolean isPaypalExpressEnabledOnProduct() {
return paypalExpressEnabledOnProduct;
}

public void setPaypalExpressEnabledOnProduct(boolean paypalExpressEnabledOnProduct) {
this.paypalExpressEnabledOnProduct = paypalExpressEnabledOnProduct;
}

public boolean isAmazonPayExpressEnabledOnProduct() {
return amazonPayExpressEnabledOnProduct;
}

public void setAmazonPayExpressEnabledOnProduct(boolean amazonPayExpressEnabledOnProduct) {
this.amazonPayExpressEnabledOnProduct = amazonPayExpressEnabledOnProduct;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.adyen.v6.converters.PosPaymentResponseConverter;
import com.adyen.v6.dto.CheckoutConfigDTO;
import com.adyen.v6.dto.CheckoutConfigDTOBuilder;
import com.adyen.v6.dto.ExpressPaymentConfigDto;
import com.adyen.v6.enums.AdyenCardTypeEnum;
import com.adyen.v6.enums.AdyenRegions;
import com.adyen.v6.enums.RecurringContractMode;
Expand All @@ -54,6 +55,7 @@
import com.adyen.v6.forms.AddressForm;
import com.adyen.v6.forms.AdyenPaymentForm;
import com.adyen.v6.forms.validation.AdyenPaymentFormValidator;
import com.adyen.v6.model.ExpressPaymentConfigModel;
import com.adyen.v6.model.RequestInfo;
import com.adyen.v6.repository.OrderRepository;
import com.adyen.v6.service.AdyenBusinessProcessService;
Expand Down Expand Up @@ -156,6 +158,7 @@ public class DefaultAdyenCheckoutFacade implements AdyenCheckoutFacade {
private static final String US = "US";
private static final String RECURRING_RECURRING_DETAIL_REFERENCE = "recurring.recurringDetailReference";
private static final String EXCLUDED_PAYMENT_METHODS_CONFIG = "adyen.payment-methods.excluded";
public static final String EXPRESS_PAYMENT_CONFIG = "expressPaymentConfig";

private BaseStoreService baseStoreService;
private SessionService sessionService;
Expand Down Expand Up @@ -687,6 +690,7 @@ public void initializeCheckoutData(Model model) throws ApiException {
model.addAttribute(MODEL_COUNTRY_CODE, checkoutConfigDTO.getCountryCode());
model.addAttribute(MODEL_CARD_HOLDER_NAME_REQUIRED, checkoutConfigDTO.isCardHolderNameRequired());
model.addAttribute(PAYMENT_METHOD_SEPA_DIRECTDEBIT, checkoutConfigDTO.isSepaDirectDebit());

}

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

CheckoutConfigDTOBuilder checkoutConfigDTOBuilder = new CheckoutConfigDTOBuilder();

return checkoutConfigDTOBuilder
checkoutConfigDTOBuilder
.setPaymentMethods(paymentMethods)
.setConnectedTerminalList(connectedTerminalList)
.setStoredPaymentMethodList(storedPaymentMethodList)
Expand All @@ -782,8 +786,29 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException {
.setImmediateCapture(isImmediateCapture())
.setCountryCode(cartData != null && cartData.getDeliveryAddress() != null && cartData.getDeliveryAddress().getCountry() != null ? cartData.getDeliveryAddress().getCountry().getIsocode() : "")
.setCardHolderNameRequired(getHolderNameRequired())
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue())
.build();
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue());

ExpressPaymentConfigModel expressPaymentConfigModel = baseStore.getExpressPaymentConfig();
if (expressPaymentConfigModel != null) {
ExpressPaymentConfigDto expressPaymentConfigDto = getExpressPaymentConfigDto(expressPaymentConfigModel);

checkoutConfigDTOBuilder.setExpressPaymentConfig(expressPaymentConfigDto);
}

return checkoutConfigDTOBuilder.build();
}

private static ExpressPaymentConfigDto getExpressPaymentConfigDto(ExpressPaymentConfigModel expressPaymentConfigModel) {
ExpressPaymentConfigDto expressPaymentConfigDto = new ExpressPaymentConfigDto();
expressPaymentConfigDto.setGooglePayExpressEnabledOnCart(expressPaymentConfigModel.getGooglePayExpressEnabledOnCart());
expressPaymentConfigDto.setApplePayExpressEnabledOnCart(expressPaymentConfigModel.getApplePayExpressEnabledOnCart());
expressPaymentConfigDto.setPaypalExpressEnabledOnCart(expressPaymentConfigModel.getPaypalExpressEnabledOnCart());
expressPaymentConfigDto.setAmazonPayExpressEnabledOnCart(expressPaymentConfigModel.getAmazonPayExpressEnabledOnCart());
expressPaymentConfigDto.setGooglePayExpressEnabledOnProduct(expressPaymentConfigModel.getGooglePayExpressEnabledOnProduct());
expressPaymentConfigDto.setApplePayExpressEnabledOnProduct(expressPaymentConfigModel.getApplePayExpressEnabledOnProduct());
expressPaymentConfigDto.setPaypalExpressEnabledOnProduct(expressPaymentConfigModel.getPaypalExpressEnabledOnProduct());
expressPaymentConfigDto.setAmazonPayExpressEnabledOnProduct(expressPaymentConfigModel.getAmazonPayExpressEnabledOnProduct());
return expressPaymentConfigDto;
}

protected List<String> getExcludedPaymentMethodsFromConfiguration() {
Expand Down Expand Up @@ -880,7 +905,7 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException {

CheckoutConfigDTOBuilder checkoutConfigDTOBuilder = new CheckoutConfigDTOBuilder();

return checkoutConfigDTOBuilder.setAlternativePaymentMethods(alternativePaymentMethods)
checkoutConfigDTOBuilder.setAlternativePaymentMethods(alternativePaymentMethods)
.setConnectedTerminalList(connectedTerminalList)
.setStoredPaymentMethodList(storedPaymentMethodList)
.setIssuerLists(issuerLists)
Expand All @@ -905,8 +930,16 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException {
.setCountryCode(cartData.getDeliveryAddress().getCountry().getIsocode())
.setCardHolderNameRequired(getHolderNameRequired())
.setSepaDirectDebit(sepaDirectDebit)
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue())
.build();
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue());

ExpressPaymentConfigModel expressPaymentConfigModel = baseStore.getExpressPaymentConfig();
if (expressPaymentConfigModel != null) {
ExpressPaymentConfigDto expressPaymentConfigDto = getExpressPaymentConfigDto(expressPaymentConfigModel);

checkoutConfigDTOBuilder.setExpressPaymentConfig(expressPaymentConfigDto);
}

return checkoutConfigDTOBuilder.build();
}

@Deprecated
Expand Down Expand Up @@ -1104,6 +1137,9 @@ 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) {
model.addAttribute(EXPRESS_PAYMENT_CONFIG, getExpressPaymentConfigDto(baseStore.getExpressPaymentConfig()));
}
}

protected BigDecimal getExpressDeliveryModeValue(final String currencyIso) {
Expand Down
Loading

0 comments on commit f0d2ed8

Please sign in to comment.