Skip to content

Commit

Permalink
Merge pull request #474 from Adyen/feature/AD-336
Browse files Browse the repository at this point in the history
AD-336: Google Express Payments
  • Loading branch information
kpieloch authored Oct 31, 2024
2 parents a80c3da + ec63646 commit 3bbe662
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
11 changes: 10 additions & 1 deletion adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.adyen.model.checkout.CreateCheckoutSessionResponse;
import com.adyen.model.checkout.PaymentMethod;
import com.adyen.model.checkout.StoredPaymentMethod;
import com.adyen.v6.enums.AdyenCardTypeEnum;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -40,6 +40,7 @@ public class CheckoutConfigDTO {
private String countryCode;
private boolean cardHolderNameRequired;
private boolean sepaDirectDebit;
private BigDecimal amountDecimal;


public List<PaymentMethod> getAlternativePaymentMethods() {
Expand Down Expand Up @@ -249,4 +250,12 @@ public List<PaymentMethod> getPaymentMethods() {
public void setPaymentMethods(List<PaymentMethod> paymentMethods) {
this.paymentMethods = paymentMethods;
}

public BigDecimal getAmountDecimal() {
return amountDecimal;
}

public void setAmountDecimal(BigDecimal amountDecimal) {
this.amountDecimal = amountDecimal;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.adyen.model.checkout.StoredPaymentMethod;
import com.adyen.v6.enums.AdyenCardTypeEnum;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -149,6 +150,11 @@ public CheckoutConfigDTOBuilder setSepaDirectDebit(boolean sepaDirectDebit) {
return this;
}

public CheckoutConfigDTOBuilder setAmountDecimal(BigDecimal amountDecimal) {
checkoutConfigDTO.setAmountDecimal(amountDecimal);
return this;
}

public CheckoutConfigDTO build() {
return checkoutConfigDTO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,9 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException {
.setShowComboCard(showComboCard())
.setShowPos(showPos())
.setImmediateCapture(isImmediateCapture())
.setCountryCode(cartData.getDeliveryAddress().getCountry().getIsocode())
.setCountryCode(cartData != null && cartData.getDeliveryAddress() != null && cartData.getDeliveryAddress().getCountry() != null ? cartData.getDeliveryAddress().getCountry().getIsocode() : "")
.setCardHolderNameRequired(getHolderNameRequired())
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue())
.build();
}

Expand Down Expand Up @@ -904,6 +905,7 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException {
.setCountryCode(cartData.getDeliveryAddress().getCountry().getIsocode())
.setCardHolderNameRequired(getHolderNameRequired())
.setSepaDirectDebit(sepaDirectDebit)
.setAmountDecimal(cartData.getTotalPriceWithTax().getValue())
.build();
}

Expand Down Expand Up @@ -958,11 +960,16 @@ protected PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyen
}

protected PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPaymentService, CartData cartData, CustomerModel customerModel, List<String> excludedPaymentMethods) throws IOException, ApiException {
return adyenPaymentService.getPaymentMethodsResponse(cartData.getTotalPriceWithTax().getValue(),
cartData.getTotalPriceWithTax().getCurrencyIso(),
cartData.getDeliveryAddress().getCountry().getIsocode(),
getShopperLocale(),
customerModel.getCustomerID(), excludedPaymentMethods);
if (adyenPaymentService == null || cartData == null || customerModel == null) {
throw new IllegalArgumentException("Required parameters cannot be null");
}

BigDecimal totalPrice = cartData.getTotalPriceWithTax() != null ? cartData.getTotalPriceWithTax().getValue() : BigDecimal.ZERO;
String currencyIso = cartData.getTotalPriceWithTax() != null ? cartData.getTotalPriceWithTax().getCurrencyIso() : StringUtils.EMPTY;
String countryIso = cartData.getDeliveryAddress() != null && cartData.getDeliveryAddress().getCountry() != null ? cartData.getDeliveryAddress().getCountry().getIsocode() : StringUtils.EMPTY;
String customerID = customerModel.getCustomerID() != null ? customerModel.getCustomerID() : StringUtils.EMPTY;

return adyenPaymentService.getPaymentMethodsResponse(totalPrice, currencyIso, countryIso, getShopperLocale(), customerID, excludedPaymentMethods);
}


Expand Down Expand Up @@ -1219,7 +1226,15 @@ public boolean showRememberDetails() {
public boolean showSocialSecurityNumber() {
Boolean showSocialSecurityNumber = false;
CartData cart = getCheckoutFacade().getCheckoutCart();
if (cart == null) {
return showSocialSecurityNumber;
}

final AddressData deliveryAddress = cart.getDeliveryAddress();
if (deliveryAddress == null || deliveryAddress.getCountry() == null) {
return showSocialSecurityNumber;
}

String countryCode = deliveryAddress.getCountry().getIsocode();
if (PAYMENT_METHODS_ALLOW_SOCIAL_SECURITY_NUMBER.contains(cart.getAdyenPaymentMethod()) && OPENINVOICE_METHODS_ALLOW_SOCIAL_SECURITY_NUMBER.contains(countryCode)) {
showSocialSecurityNumber = true;
Expand Down

0 comments on commit 3bbe662

Please sign in to comment.