From 5469cddcc56109c5ddd98b48e7dececbfc3c0149 Mon Sep 17 00:00:00 2001 From: PJaneta Date: Wed, 4 Sep 2024 08:10:07 +0200 Subject: [PATCH] AD-295 Refactor Private Methods to Protected for Enhanced Class Extensibility --- .../impl/DefaultAdyenCheckoutApiFacade.java | 4 +- .../order/AdyenCheckAuthorizationAction.java | 4 +- .../v6/commands/AdyenCaptureCommand.java | 4 +- .../PosPaymentResponseConverter.java | 2 +- .../impl/DefaultAdyenCheckoutFacade.java | 48 +++++++++---------- .../DefaultAdyenExpressCheckoutFacade.java | 16 +++---- .../facades/impl/DefaultAdyenOrderFacade.java | 10 ++-- .../adyen/v6/factory/AdyenRequestFactory.java | 16 +++---- ...yenNotificationAuthenticationProvider.java | 6 +-- .../DefaultAdyenNotificationService.java | 6 +-- .../v6/service/DefaultAdyenOrderService.java | 2 +- .../DefaultAdyenTransactionService.java | 18 +++---- .../DefaultAdyenNotificationV2Service.java | 8 ++-- 13 files changed, 72 insertions(+), 72 deletions(-) diff --git a/adyenv6core/src/com/adyen/commerce/facades/impl/DefaultAdyenCheckoutApiFacade.java b/adyenv6core/src/com/adyen/commerce/facades/impl/DefaultAdyenCheckoutApiFacade.java index 137dbd0af..a8c124d76 100644 --- a/adyenv6core/src/com/adyen/commerce/facades/impl/DefaultAdyenCheckoutApiFacade.java +++ b/adyenv6core/src/com/adyen/commerce/facades/impl/DefaultAdyenCheckoutApiFacade.java @@ -79,13 +79,13 @@ public void preHandlePlaceOrder(PaymentRequest paymentRequest, String adyenPayme }); } - private static void saveBrowserInfoOnPaymentInfo(BrowserInfo browserInfo, PaymentInfoModel paymentInfo) { + protected static void saveBrowserInfoOnPaymentInfo(BrowserInfo browserInfo, PaymentInfoModel paymentInfo) { if (browserInfo != null) { paymentInfo.setAdyenBrowserInfo(getBrowserInfoJson(browserInfo)); } } - private static String getBrowserInfoJson(BrowserInfo browserInfo) { + protected static String getBrowserInfoJson(BrowserInfo browserInfo) { try { return browserInfo.toJson(); } catch (JsonProcessingException e) { diff --git a/adyenv6core/src/com/adyen/v6/actions/order/AdyenCheckAuthorizationAction.java b/adyenv6core/src/com/adyen/v6/actions/order/AdyenCheckAuthorizationAction.java index a0f731107..91ace550b 100644 --- a/adyenv6core/src/com/adyen/v6/actions/order/AdyenCheckAuthorizationAction.java +++ b/adyenv6core/src/com/adyen/v6/actions/order/AdyenCheckAuthorizationAction.java @@ -74,7 +74,7 @@ public String execute(final OrderProcessModel process) { return processOrderAuthorization(process, order); } - private boolean isTransactionAuthorized(final PaymentTransactionModel paymentTransactionModel) { + protected boolean isTransactionAuthorized(final PaymentTransactionModel paymentTransactionModel) { for (final PaymentTransactionEntryModel entry : paymentTransactionModel.getEntries()) { if (entry.getType().equals(PaymentTransactionType.AUTHORIZATION) && TransactionStatus.ACCEPTED.name().equals(entry.getTransactionStatus())) { @@ -85,7 +85,7 @@ private boolean isTransactionAuthorized(final PaymentTransactionModel paymentTra return false; } - private String processOrderAuthorization(final OrderProcessModel process, final OrderModel order) { + protected String processOrderAuthorization(final OrderProcessModel process, final OrderModel order) { //No transactions means that is not authorized yet if (order.getPaymentTransactions() == null || order.getPaymentTransactions().isEmpty()) { LOG.debug("Process: " + process.getCode() + " Order Waiting"); diff --git a/adyenv6core/src/com/adyen/v6/commands/AdyenCaptureCommand.java b/adyenv6core/src/com/adyen/v6/commands/AdyenCaptureCommand.java index 823fadaa4..c91f00f4d 100644 --- a/adyenv6core/src/com/adyen/v6/commands/AdyenCaptureCommand.java +++ b/adyenv6core/src/com/adyen/v6/commands/AdyenCaptureCommand.java @@ -109,7 +109,7 @@ public CaptureResult perform(final CaptureRequest request) { return result; } - private CaptureResult createCaptureResultFromRequest(CaptureRequest request) { + protected CaptureResult createCaptureResultFromRequest(CaptureRequest request) { CaptureResult result = new CaptureResult(); result.setCurrency(request.getCurrency()); @@ -126,7 +126,7 @@ private CaptureResult createCaptureResultFromRequest(CaptureRequest request) { return result; } - private boolean supportsManualCapture(String paymentMethod) { + protected boolean supportsManualCapture(String paymentMethod) { switch (paymentMethod) { case "cup": case "cartebancaire": diff --git a/adyenv6core/src/com/adyen/v6/converters/PosPaymentResponseConverter.java b/adyenv6core/src/com/adyen/v6/converters/PosPaymentResponseConverter.java index ca56d01ee..d1bbb235d 100644 --- a/adyenv6core/src/com/adyen/v6/converters/PosPaymentResponseConverter.java +++ b/adyenv6core/src/com/adyen/v6/converters/PosPaymentResponseConverter.java @@ -79,7 +79,7 @@ public PaymentResponse convert(SaleToPOIResponse saleToPOIResponse) { /* * Parse base64 encoded additionalResponse and return as a name/value map */ - private Map parseAdditionalResponse(String additionalResponse) { + protected Map parseAdditionalResponse(String additionalResponse) { Map additionalData = new HashMap<>(); if (StringUtils.isNotEmpty(additionalResponse)) { String decodedAdditionalResponse = new String(Base64.getDecoder().decode(additionalResponse), StandardCharsets.UTF_8); diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java index 377dbb8db..3e653208b 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java @@ -314,7 +314,7 @@ public PaymentDetailsWsDTO addPaymentDetails(PaymentDetailsWsDTO paymentDetails) } - private AddressModel createBillingAddress(PaymentDetailsWsDTO paymentDetails) { + protected AddressModel createBillingAddress(PaymentDetailsWsDTO paymentDetails) { String titleCode = paymentDetails.getBillingAddress().getTitleCode(); final AddressModel billingAddress = getModelService().create(AddressModel.class); if (StringUtils.isNotBlank(titleCode)) { @@ -377,7 +377,7 @@ public PaymentDetailsResponse handleRedirectPayload(PaymentCompletionDetails det return response; } - private void updateOrderPaymentStatusAndInfo(OrderModel orderModel, PaymentDetailsResponse paymentDetailsResponse) { + protected void updateOrderPaymentStatusAndInfo(OrderModel orderModel, PaymentDetailsResponse paymentDetailsResponse) { if (PaymentDetailsResponse.ResultCodeEnum.RECEIVED != paymentDetailsResponse.getResultCode()) { //payment authorisation is finished, update payment info @@ -501,7 +501,7 @@ public PaymentDetailsResponse componentDetails(PaymentDetailsRequest detailsRequ return response; } - private void updateCartWithSessionData(CartData cartData) { + protected void updateCartWithSessionData(CartData cartData) { cartData.setAdyenCseToken(getSessionService().getAttribute(SESSION_CSE_TOKEN)); cartData.setAdyenEncryptedCardNumber(getSessionService().getAttribute(SESSION_SF_CARD_NUMBER)); cartData.setAdyenEncryptedExpiryMonth(getSessionService().getAttribute(SESSION_SF_EXPIRY_MONTH)); @@ -560,7 +560,7 @@ protected OrderData createAuthorizedOrder(final PaymentResponse paymentsResponse return createOrderFromPaymentResponse(paymentsResponse); } - private void updateAdyenSelectedReferenceIfPresent(final CartModel cartModel, final PaymentResponse paymentsResponse) { + protected void updateAdyenSelectedReferenceIfPresent(final CartModel cartModel, final PaymentResponse paymentsResponse) { Map additionalData = paymentsResponse.getAdditionalData(); if (additionalData != null) { String recurringDetailReference = additionalData.get(RECURRING_RECURRING_DETAIL_REFERENCE); @@ -573,7 +573,7 @@ private void updateAdyenSelectedReferenceIfPresent(final CartModel cartModel, fi /** * Create order */ - private OrderData createOrderFromPaymentResponse(final PaymentResponse paymentsResponse) throws InvalidCartException { + protected OrderData createOrderFromPaymentResponse(final PaymentResponse paymentsResponse) throws InvalidCartException { LOGGER.debug("Create order from paymentsResponse: " + paymentsResponse.getPspReference()); OrderData orderData = getCheckoutFacade().placeOrder(); @@ -613,7 +613,7 @@ protected OrderData placePendingOrder(String resultCode) throws InvalidCartExcep return orderData; } - private OrderData placeAuthorisedOrder(PaymentResponse.ResultCodeEnum resultCode) throws InvalidCartException { + protected OrderData placeAuthorisedOrder(PaymentResponse.ResultCodeEnum resultCode) throws InvalidCartException { CartModel cartModel = getCartService().getSessionCart(); cartModel.setStatus(OrderStatus.PAYMENT_AUTHORIZED); cartModel.setStatusInfo(resultCode.getValue()); @@ -905,20 +905,20 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException { } @Deprecated - private static boolean isSepaDirectDebit(List alternativePaymentMethods) { + protected static boolean isSepaDirectDebit(List alternativePaymentMethods) { return alternativePaymentMethods.stream(). anyMatch(paymentMethod -> !paymentMethod.getType().isEmpty() && PAYMENT_METHOD_SEPA_DIRECTDEBIT.contains(paymentMethod.getType())); } - private static void updateCartWithAmazonPay(PaymentMethod amazonPayMethod, CartModel cartModel) { + protected static void updateCartWithAmazonPay(PaymentMethod amazonPayMethod, CartModel cartModel) { Map amazonPayConfiguration = amazonPayMethod.getConfiguration(); if (!CollectionUtils.isEmpty(amazonPayConfiguration)) { cartModel.setAdyenAmazonPayConfiguration(amazonPayConfiguration); } } - private static Optional getAmazonPayMethod(List alternativePaymentMethods) { + protected static Optional getAmazonPayMethod(List alternativePaymentMethods) { return alternativePaymentMethods.stream() .filter(paymentMethod -> !paymentMethod.getType().isEmpty() && PAYMENT_METHOD_AMAZONPAY.contains(paymentMethod.getType())) @@ -926,7 +926,7 @@ private static Optional getAmazonPayMethod(List al } @Deprecated - private static void updateIssuerList(List issuerPaymentMethods, Map issuerLists) { + protected static void updateIssuerList(List issuerPaymentMethods, Map issuerLists) { if (!CollectionUtils.isEmpty(issuerPaymentMethods)) { Gson gson = new Gson(); for (PaymentMethod paymentMethod : issuerPaymentMethods) { @@ -936,7 +936,7 @@ private static void updateIssuerList(List issuerPaymentMethods, M } @Deprecated - private static List getIssuerPaymentMethods(List alternativePaymentMethods) { + protected static List getIssuerPaymentMethods(List alternativePaymentMethods) { if (alternativePaymentMethods != null) { return alternativePaymentMethods.stream() .filter(paymentMethod -> !paymentMethod.getType().isEmpty() && ISSUER_PAYMENT_METHODS.contains(paymentMethod.getType())) @@ -946,7 +946,7 @@ private static List getIssuerPaymentMethods(List a return Collections.emptyList(); } - private PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPaymentService, CartData cartData, CustomerModel customerModel) throws IOException, ApiException { + protected PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPaymentService, CartData cartData, CustomerModel customerModel) throws IOException, ApiException { return adyenPaymentService.getPaymentMethodsResponse(cartData.getTotalPriceWithTax().getValue(), cartData.getTotalPriceWithTax().getCurrencyIso(), cartData.getDeliveryAddress().getCountry().getIsocode(), @@ -954,7 +954,7 @@ private PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPa customerModel.getCustomerID()); } - private PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPaymentService, CartData cartData, CustomerModel customerModel, List excludedPaymentMethods) throws IOException, ApiException { + protected PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPaymentService, CartData cartData, CustomerModel customerModel, List excludedPaymentMethods) throws IOException, ApiException { return adyenPaymentService.getPaymentMethodsResponse(cartData.getTotalPriceWithTax().getValue(), cartData.getTotalPriceWithTax().getCurrencyIso(), cartData.getDeliveryAddress().getCountry().getIsocode(), @@ -963,7 +963,7 @@ private PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPa } - private Map getApplePayConfigFromPaymentMethods(List paymentMethods) { + protected Map getApplePayConfigFromPaymentMethods(List paymentMethods) { if (paymentMethods != null) { Optional applePayMethod = paymentMethods.stream() .filter(paymentMethod -> !paymentMethod.getType().isEmpty() @@ -980,7 +980,7 @@ private Map getApplePayConfigFromPaymentMethods(List(); } - private CreateCheckoutSessionResponse getAdyenSessionData() throws ApiException { + protected CreateCheckoutSessionResponse getAdyenSessionData() throws ApiException { try { final CartData cartData = getCheckoutFacade().getCheckoutCart(); return getAdyenPaymentService().getPaymentSessionData(cartData); @@ -993,7 +993,7 @@ private CreateCheckoutSessionResponse getAdyenSessionData() throws ApiException } } - private CreateCheckoutSessionResponse getAdyenSessionData(Amount amount) throws ApiException { + protected CreateCheckoutSessionResponse getAdyenSessionData(Amount amount) throws ApiException { try { return getAdyenPaymentService().getPaymentSessionData(amount); } catch (JsonProcessingException e) { @@ -1061,7 +1061,7 @@ public void initializeApplePayExpressPDPData(Model model, ProductData productDat initializeApplePayExpressDataInternal(amountValue, currencyIso, model); } - private void initializeApplePayExpressDataInternal(BigDecimal amountValue, String currency, Model model) throws ApiException { + protected void initializeApplePayExpressDataInternal(BigDecimal amountValue, String currency, Model model) throws ApiException { final BaseStoreModel baseStore = baseStoreService.getCurrentBaseStore(); try { @@ -1095,7 +1095,7 @@ private void initializeApplePayExpressDataInternal(BigDecimal amountValue, Strin model.addAttribute(MODEL_CHECKOUT_SHOPPER_HOST, getCheckoutShopperHost()); } - private BigDecimal getExpressDeliveryModeValue(final String currencyIso) { + protected BigDecimal getExpressDeliveryModeValue(final String currencyIso) { Optional expressDeliveryModePrice = adyenExpressCheckoutFacade.getExpressDeliveryModePrice(); BigDecimal deliveryValue = BigDecimal.ZERO; @@ -1112,7 +1112,7 @@ private BigDecimal getExpressDeliveryModeValue(final String currencyIso) { return deliveryValue; } - private String setLocale(final Map map, final String shopperLocale) { + protected String setLocale(final Map map, final String shopperLocale) { if (Objects.nonNull(map) && !map.get(REGION).isBlank() && map.get(REGION).equals(US)) { return US_LOCALE; } else { @@ -1131,7 +1131,7 @@ private String setLocale(final Map map, final String shopperLoca } } - private boolean isHiddenPaymentMethod(PaymentMethod paymentMethod) { + protected boolean isHiddenPaymentMethod(PaymentMethod paymentMethod) { String paymentMethodType = paymentMethod.getType(); if (paymentMethodType == null || paymentMethodType.isEmpty() || @@ -1148,7 +1148,7 @@ private boolean isHiddenPaymentMethod(PaymentMethod paymentMethod) { return false; } - private List getStoredOneClickPaymentMethods(PaymentMethodsResponse response) { + protected List getStoredOneClickPaymentMethods(PaymentMethodsResponse response) { List storedPaymentMethodList = null; if (response.getStoredPaymentMethods() != null) { storedPaymentMethodList = response.getStoredPaymentMethods().stream() @@ -1496,7 +1496,7 @@ public OrderData checkPosPaymentStatus(HttpServletRequest request, CartData cart throw new AdyenNonAuthorizedPaymentException(terminalApiResponse); } - private boolean isPosTimedOut(HttpServletRequest request) { + protected boolean isPosTimedOut(HttpServletRequest request) { long currentTime = System.currentTimeMillis(); long processStartTime = (long) request.getAttribute("paymentStartTime"); int totalTimeout = ((int) request.getAttribute("totalTimeout")) * 1000; @@ -1550,7 +1550,7 @@ protected OrderModel retrievePendingOrder(String orderCode) throws InvalidCartEx return orderModel; } - private void restoreCartFromOrder(String orderCode) throws CalculationException, InvalidCartException { + protected void restoreCartFromOrder(String orderCode) throws CalculationException, InvalidCartException { LOGGER.info("Restoring cart from order"); OrderModel orderModel = getOrderRepository().getOrderModel(orderCode); @@ -1606,7 +1606,7 @@ private void restoreCartFromOrder(String orderCode) throws CalculationException, getCalculationService().calculate(cartModel); } - private boolean hasUserContextChanged(OrderModel orderModel, CartModel cartModel) { + protected boolean hasUserContextChanged(OrderModel orderModel, CartModel cartModel) { return !orderModel.getUser().equals(cartModel.getUser()) || !orderModel.getStore().equals(cartModel.getStore()); } diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenExpressCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenExpressCheckoutFacade.java index 605bb3f89..4ed9bcfe3 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenExpressCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenExpressCheckoutFacade.java @@ -183,7 +183,7 @@ public void removeDeliveryModeFromSessionCart() throws CalculationException { } } - private void prepareCart(CartModel cart, DeliveryModeModel deliveryMode, AddressModel addressModel, PaymentInfoModel paymentInfo) { + protected void prepareCart(CartModel cart, DeliveryModeModel deliveryMode, AddressModel addressModel, PaymentInfoModel paymentInfo) { cart.setDeliveryMode(deliveryMode); cart.setDeliveryAddress(addressModel); cart.setPaymentAddress(addressModel); @@ -191,7 +191,7 @@ private void prepareCart(CartModel cart, DeliveryModeModel deliveryMode, Address modelService.save(cart); } - private AddressModel prepareAddressModel(AddressData addressData, CustomerModel user) { + protected AddressModel prepareAddressModel(AddressData addressData, CustomerModel user) { AddressModel addressModel = modelService.create(AddressModel.class); addressReverseConverter.convert(addressData, addressModel); validateParameterNotNull(addressModel, "Empty address"); @@ -203,7 +203,7 @@ private AddressModel prepareAddressModel(AddressData addressData, CustomerModel return addressModel; } - private void addProductToCart(String productCode, CartModel cart) { + protected void addProductToCart(String productCode, CartModel cart) { ProductModel product = productService.getProductForCode(productCode); if (product != null) { @@ -219,13 +219,13 @@ public Optional getExpressDeliveryModePrice() { return deliveryMode.getValues().stream().filter(valueModel -> valueModel.getCurrency().equals(currentCurrency)).findFirst(); } - private CustomerModel createGuestCustomer(String emailAddress) throws DuplicateUidException { + protected CustomerModel createGuestCustomer(String emailAddress) throws DuplicateUidException { Assert.isTrue(EmailValidator.getInstance().isValid(emailAddress), "Invalid email address"); return createGuestUserForAnonymousCheckout(emailAddress, USER_NAME); } - private CustomerModel createGuestUserForAnonymousCheckout(final String email, final String name) throws DuplicateUidException { + protected CustomerModel createGuestUserForAnonymousCheckout(final String email, final String name) throws DuplicateUidException { validateParameterNotNullStandardMessage("email", email); final CustomerModel guestCustomer = modelService.create(CustomerModel.class); final String guid = customerFacade.generateGUID(); @@ -242,14 +242,14 @@ private CustomerModel createGuestUserForAnonymousCheckout(final String email, fi return guestCustomer; } - private CartModel createCartForExpressCheckout(CustomerModel guestUser) { + protected CartModel createCartForExpressCheckout(CustomerModel guestUser) { CartModel cart = cartFactory.createCart(); cart.setUser(guestUser); modelService.save(cart); return cart; } - private PaymentInfoModel createPaymentInfoForCart(CustomerModel customerModel, AddressModel addressModel, CartModel cartModel, String paymentMethod, String merchantId, String merchantName) { + protected PaymentInfoModel createPaymentInfoForCart(CustomerModel customerModel, AddressModel addressModel, CartModel cartModel, String paymentMethod, String merchantId, String merchantName) { final PaymentInfoModel paymentInfo = modelService.create(PaymentInfoModel.class); paymentInfo.setUser(customerModel); paymentInfo.setCode(generateCcPaymentInfoCode(cartModel)); @@ -268,7 +268,7 @@ protected String generateCcPaymentInfoCode(final CartModel cartModel) { return cartModel.getCode() + "_" + UUID.randomUUID(); } - private boolean cartHasEntries(CartModel cartModel) { + protected boolean cartHasEntries(CartModel cartModel) { return cartModel != null && !CollectionUtils.isEmpty(cartModel.getEntries()); } diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenOrderFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenOrderFacade.java index a86a851e6..507c992c1 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenOrderFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenOrderFacade.java @@ -59,7 +59,7 @@ public String getOrderCodeForGUID(final String orderGUID, final String sessionGu return ""; } - private String getPaymentStatusForOrder(final OrderModel orderModel) { + protected String getPaymentStatusForOrder(final OrderModel orderModel) { List paymentTransactions = orderModel.getPaymentTransactions(); if (paymentTransactions.isEmpty()) { return getMessageFromStatus(TransactionStatus.REVIEW.name()); @@ -67,7 +67,7 @@ private String getPaymentStatusForOrder(final OrderModel orderModel) { return getStatus(paymentTransactions); } - private OrderModel getOrderModelForCodeOCC(String code) { + protected OrderModel getOrderModelForCodeOCC(String code) { BaseStoreModel currentBaseStore = baseStoreService.getCurrentBaseStore(); final OrderModel orderModel; @@ -84,7 +84,7 @@ private OrderModel getOrderModelForCodeOCC(String code) { return orderModel; } - private OrderModel getOrderModelForCode(final String code, final String sessionGuid) { + protected OrderModel getOrderModelForCode(final String code, final String sessionGuid) { final BaseStoreModel baseStoreModel = baseStoreService.getCurrentBaseStore(); OrderModel orderModel = null; @@ -109,7 +109,7 @@ private OrderModel getOrderModelForCode(final String code, final String sessionG return orderModel; } - private String getStatus(List paymentTransactions) { + protected String getStatus(List paymentTransactions) { Optional paymentTransactionModelList = paymentTransactions.stream() .max(Comparator.comparing(ItemModel::getCreationtime)); @@ -125,7 +125,7 @@ private String getStatus(List paymentTransactions) { throw new ModelNotFoundException("No entries in payment transaction model."); } - private String getMessageFromStatus(String transactionStatus) { + protected String getMessageFromStatus(String transactionStatus) { if (transactionStatus.equals(TransactionStatus.ACCEPTED.name())) { return "completed"; } diff --git a/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java b/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java index d8b1ae29a..d6a7981a6 100644 --- a/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java +++ b/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java @@ -540,7 +540,7 @@ protected BillingAddress convertToBillingAddress(AddressData addressData) { /** * Return Recurring object from RecurringContractMode */ - private Recurring getRecurringContractType(RecurringContractMode recurringContractMode) { + protected Recurring getRecurringContractType(RecurringContractMode recurringContractMode) { Recurring recurringContract = new Recurring(); //If recurring contract is disabled, return null @@ -559,7 +559,7 @@ private Recurring getRecurringContractType(RecurringContractMode recurringContra /** * Return the recurringContract. If the user did not want to save the card don't send it as ONECLICK */ - private Recurring getRecurringContractType(RecurringContractMode recurringContractMode, final Boolean enableOneClick) { + protected Recurring getRecurringContractType(RecurringContractMode recurringContractMode, final Boolean enableOneClick) { Recurring recurringContract = getRecurringContractType(recurringContractMode); //If recurring contract is disabled, return null @@ -590,7 +590,7 @@ private Recurring getRecurringContractType(RecurringContractMode recurringContra /** * Get shopper name and gender */ - private Name getShopperNameFromAddress(AddressData addressData) { + protected Name getShopperNameFromAddress(AddressData addressData) { Name shopperName = new Name(); shopperName.setFirstName(addressData.getFirstName()); @@ -722,7 +722,7 @@ public void setOpenInvoiceData(PaymentRequest paymentsRequest, CartData cartData paymentsRequest.setLineItems(invoiceLines); } - private Name getAfterPayShopperName(final CartData cartData) { + protected Name getAfterPayShopperName(final CartData cartData) { return new Name() .firstName(cartData.getAdyenFirstName()) .lastName(cartData.getAdyenLastName()); @@ -731,7 +731,7 @@ private Name getAfterPayShopperName(final CartData cartData) { /** * Set Boleto payment request data */ - private void setBoletoData(final PaymentRequest paymentsRequest, final CartData cartData) { + protected void setBoletoData(final PaymentRequest paymentsRequest, final CartData cartData) { paymentsRequest.setSocialSecurityNumber(cartData.getAdyenSocialSecurityNumber()); final Name shopperName = new Name() @@ -757,7 +757,7 @@ private void setBoletoData(final PaymentRequest paymentsRequest, final CartData } - private void setPixData(final PaymentRequest paymentsRequest, final CartData cartData) { + protected void setPixData(final PaymentRequest paymentsRequest, final CartData cartData) { final List invoiceLines = cartData.getEntries().stream() .filter(cartEntry -> cartEntry.getQuantity() > 0) .map(cartEntry -> @@ -778,11 +778,11 @@ private void setPixData(final PaymentRequest paymentsRequest, final CartData car paymentsRequest.setLineItems(invoiceLines); } - private String getPlatformVersion() { + protected String getPlatformVersion() { return getConfigurationService().getConfiguration().getString(PLATFORM_VERSION_PROPERTY); } - private Boolean is3DS2Allowed() { + protected Boolean is3DS2Allowed() { final Configuration configuration = getConfigurationService().getConfiguration(); if (configuration.containsKey(IS_3DS2_ALLOWED_PROPERTY)) { return configuration.getBoolean(IS_3DS2_ALLOWED_PROPERTY); diff --git a/adyenv6core/src/com/adyen/v6/security/AdyenNotificationAuthenticationProvider.java b/adyenv6core/src/com/adyen/v6/security/AdyenNotificationAuthenticationProvider.java index 00d7849e3..970ab47f2 100644 --- a/adyenv6core/src/com/adyen/v6/security/AdyenNotificationAuthenticationProvider.java +++ b/adyenv6core/src/com/adyen/v6/security/AdyenNotificationAuthenticationProvider.java @@ -77,7 +77,7 @@ public boolean authenticate(final HttpServletRequest request, NotificationReques return false; } - private boolean authenticateBasic(final HttpServletRequest request, BaseStoreModel baseStoreModel) { + protected boolean authenticateBasic(final HttpServletRequest request, BaseStoreModel baseStoreModel) { final String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.startsWith("Basic")) { String base64Credentials = authorization.substring("Basic".length()).trim(); @@ -88,7 +88,7 @@ private boolean authenticateBasic(final HttpServletRequest request, BaseStoreMod return false; } - private boolean tryToAuthenticate(String name, String password, BaseStoreModel baseStore) { + protected boolean tryToAuthenticate(String name, String password, BaseStoreModel baseStore) { String notificationUsername = baseStore.getAdyenNotificationUsername(); String notificationPassword = baseStore.getAdyenNotificationPassword(); @@ -107,7 +107,7 @@ private boolean tryToAuthenticate(String name, String password, BaseStoreModel b return false; } - private boolean checkHMAC(NotificationRequest notificationRequest, BaseStoreModel baseStore) { + protected boolean checkHMAC(NotificationRequest notificationRequest, BaseStoreModel baseStore) { String hmacKey = baseStore.getAdyenNotificationHMACKey(); if (StringUtils.isNotEmpty(hmacKey)) { diff --git a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenNotificationService.java b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenNotificationService.java index c7d63aa16..a49c70ec8 100644 --- a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenNotificationService.java +++ b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenNotificationService.java @@ -289,7 +289,7 @@ public PaymentTransactionModel processOfferClosedEvent(AdyenNotificationModel no } } - private boolean isTransactionAuthorized(final PaymentTransactionModel paymentTransactionModel) { + protected boolean isTransactionAuthorized(final PaymentTransactionModel paymentTransactionModel) { for (final PaymentTransactionEntryModel entry : paymentTransactionModel.getEntries()) { if (entry.getType().equals(PaymentTransactionType.AUTHORIZATION) && TransactionStatus.ACCEPTED.name().equals(entry.getTransactionStatus())) { @@ -300,7 +300,7 @@ private boolean isTransactionAuthorized(final PaymentTransactionModel paymentTra return false; } - private boolean isOrderAuthorized(final OrderModel order) { + protected boolean isOrderAuthorized(final OrderModel order) { if(order.getPaymentTransactions() == null || order.getPaymentTransactions().isEmpty()) { return false; } @@ -350,7 +350,7 @@ public void processNotification(NotificationItemModel notificationItemModel) { } } - private AdyenNotificationModel convertFromNotificationItem(NotificationItemModel notificationItemModel){ + protected AdyenNotificationModel convertFromNotificationItem(NotificationItemModel notificationItemModel){ AdyenNotificationModel adyenNotificationInfo = new AdyenNotificationModel(); adyenNotificationInfo.setAdditionalData(notificationItemModel.getAdditionalData()); adyenNotificationInfo.setAmountCurrency(notificationItemModel.getAmountCurrency()); diff --git a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenOrderService.java b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenOrderService.java index 6b74384a1..327a6339e 100644 --- a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenOrderService.java +++ b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenOrderService.java @@ -145,7 +145,7 @@ public void updatePaymentInfo(OrderModel order, String paymentMethodType, Map additionalData, String key, BiConsumer setter) { + protected void updatePaymentInfo(PaymentInfoModel paymentInfo, Map additionalData, String key, BiConsumer setter) { if (additionalData != null && additionalData.containsKey(key)) { setter.accept(paymentInfo, additionalData.get(key)); } diff --git a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenTransactionService.java b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenTransactionService.java index 0783061b0..fd08f0522 100644 --- a/adyenv6core/src/com/adyen/v6/service/DefaultAdyenTransactionService.java +++ b/adyenv6core/src/com/adyen/v6/service/DefaultAdyenTransactionService.java @@ -72,7 +72,7 @@ public PaymentTransactionEntryModel createRefundedTransactionFromNotification(fi return transactionEntryModel; } - private PaymentTransactionEntryModel createFromModificationNotification(final PaymentTransactionModel paymentTransaction, final AdyenNotificationModel notificationItemModel) { + protected PaymentTransactionEntryModel createFromModificationNotification(final PaymentTransactionModel paymentTransaction, final AdyenNotificationModel notificationItemModel) { final PaymentTransactionEntryModel transactionEntryModel = modelService.create(PaymentTransactionEntryModel.class); String code = paymentTransaction.getRequestId() + "_" + paymentTransaction.getEntries().size(); @@ -176,7 +176,7 @@ public PaymentTransactionModel storeFailedAuthorizationFromNotification(AdyenNot /** * Map notification item reason to transactionStatusDetails item */ - private TransactionStatusDetails getTransactionStatusDetailsFromReason(String reason) { + protected TransactionStatusDetails getTransactionStatusDetailsFromReason(String reason) { TransactionStatusDetails transactionStatusDetails = TransactionStatusDetails.UNKNOWN_CODE; if (reason != null) { @@ -191,7 +191,7 @@ private TransactionStatusDetails getTransactionStatusDetailsFromReason(String re return transactionStatusDetails; } - private PaymentTransactionEntryModel createAuthorizationPaymentTransactionEntryModel(final PaymentTransactionModel paymentTransaction, final String merchantCode, final AbstractOrderModel abstractOrderModel) { + protected PaymentTransactionEntryModel createAuthorizationPaymentTransactionEntryModel(final PaymentTransactionModel paymentTransaction, final String merchantCode, final AbstractOrderModel abstractOrderModel) { final PaymentTransactionEntryModel transactionEntryModel = modelService.create(PaymentTransactionEntryModel.class); String code = paymentTransaction.getRequestId() + "_" + paymentTransaction.getEntries().size(); @@ -210,13 +210,13 @@ private PaymentTransactionEntryModel createAuthorizationPaymentTransactionEntryM return transactionEntryModel; } - private PaymentTransactionEntryModel createAuthorizationPaymentTransactionEntryModel(final PaymentTransactionModel paymentTransaction, final String merchantCode, final AbstractOrderModel abstractOrderModel, final BigDecimal paymentAmount) { + protected PaymentTransactionEntryModel createAuthorizationPaymentTransactionEntryModel(final PaymentTransactionModel paymentTransaction, final String merchantCode, final AbstractOrderModel abstractOrderModel, final BigDecimal paymentAmount) { final PaymentTransactionEntryModel transactionEntryModel = createAuthorizationPaymentTransactionEntryModel(paymentTransaction, merchantCode, abstractOrderModel); transactionEntryModel.setAmount(paymentAmount); return transactionEntryModel; } - private PaymentTransactionModel createPaymentTransaction(final String merchantCode, final String pspReference, final AbstractOrderModel abstractOrderModel) { + protected PaymentTransactionModel createPaymentTransaction(final String merchantCode, final String pspReference, final AbstractOrderModel abstractOrderModel) { final PaymentTransactionModel paymentTransactionModel = modelService.create(PaymentTransactionModel.class); paymentTransactionModel.setCode(pspReference); paymentTransactionModel.setRequestId(pspReference); @@ -230,7 +230,7 @@ private PaymentTransactionModel createPaymentTransaction(final String merchantCo return paymentTransactionModel; } - private PaymentTransactionModel createPaymentTransaction(final String merchantCode, final String pspReference, final AbstractOrderModel abstractOrderModel, final BigDecimal paymentAmount) { + protected PaymentTransactionModel createPaymentTransaction(final String merchantCode, final String pspReference, final AbstractOrderModel abstractOrderModel, final BigDecimal paymentAmount) { final PaymentTransactionModel paymentTransactionModel = createPaymentTransaction(merchantCode, pspReference, abstractOrderModel); paymentTransactionModel.setPlannedAmount(paymentAmount); return paymentTransactionModel; @@ -278,7 +278,7 @@ public PaymentTransactionModel createPaymentTransactionFromResultCode(final Abst }); } - private PaymentTransactionEntryModel createPaymentTransactionEntryModelFromResultCode(final PaymentTransactionModel paymentTransaction, final String merchantCode, final AbstractOrderModel abstractOrderModel, final PaymentDetailsResponse.ResultCodeEnum resultCode) { + protected PaymentTransactionEntryModel createPaymentTransactionEntryModelFromResultCode(final PaymentTransactionModel paymentTransaction, final String merchantCode, final AbstractOrderModel abstractOrderModel, final PaymentDetailsResponse.ResultCodeEnum resultCode) { final PaymentTransactionEntryModel transactionEntryModel = modelService.create(PaymentTransactionEntryModel.class); String code = paymentTransaction.getRequestId() + "_" + paymentTransaction.getEntries().size(); @@ -297,7 +297,7 @@ private PaymentTransactionEntryModel createPaymentTransactionEntryModelFromResul return transactionEntryModel; } - private String getTransactionStatusForResultCode(PaymentDetailsResponse.ResultCodeEnum resultCode) { + protected String getTransactionStatusForResultCode(PaymentDetailsResponse.ResultCodeEnum resultCode) { switch (resultCode) { case AUTHORISED: case RECEIVED: @@ -313,7 +313,7 @@ private String getTransactionStatusForResultCode(PaymentDetailsResponse.ResultCo } } - private boolean isPartialPayment(AdyenNotificationModel notificationItemModel, AbstractOrderModel abstractOrderModel) { + protected boolean isPartialPayment(AdyenNotificationModel notificationItemModel, AbstractOrderModel abstractOrderModel) { BigDecimal totalOrderAmount = getAdyenPaymentService().calculateAmountWithTaxes(abstractOrderModel); BigDecimal notificationAmount = notificationItemModel.getAmountValue(); if (notificationAmount == null) { diff --git a/adyenv6notificationv2/src/com/adyen/v6/service/DefaultAdyenNotificationV2Service.java b/adyenv6notificationv2/src/com/adyen/v6/service/DefaultAdyenNotificationV2Service.java index ec3e6d0ad..24d4199a4 100644 --- a/adyenv6notificationv2/src/com/adyen/v6/service/DefaultAdyenNotificationV2Service.java +++ b/adyenv6notificationv2/src/com/adyen/v6/service/DefaultAdyenNotificationV2Service.java @@ -44,13 +44,13 @@ public void onRequest(final NotificationRequest notificationRequest) { } } - private AdyenNotificationModel save(NotificationRequestItem notificationRequestItem) { + protected AdyenNotificationModel save(NotificationRequestItem notificationRequestItem) { AdyenNotificationModel adyenNotificationModel = populate(notificationRequestItem); modelService.save(adyenNotificationModel); return adyenNotificationModel; } - private AdyenNotificationModel populate(NotificationRequestItem source) { + protected AdyenNotificationModel populate(NotificationRequestItem source) { AdyenNotificationModel target = new AdyenNotificationModel(); Gson gson = new Gson(); @@ -78,7 +78,7 @@ private AdyenNotificationModel populate(NotificationRequestItem source) { return target; } - private Optional createEvent(AdyenNotificationModel adyenNotificationModel) { + protected Optional createEvent(AdyenNotificationModel adyenNotificationModel) { if (StringUtils.isNotEmpty(adyenNotificationModel.getEventCode())) { AbstractNotificationEventBuilder eventTemplate = eventTemplateMap.get(adyenNotificationModel.getEventCode()); if (eventTemplate == null) { @@ -94,7 +94,7 @@ private Optional createEvent(AdyenNotificationModel a } - private void publish(AbstractNotificationEvent event) { + protected void publish(AbstractNotificationEvent event) { getEventService().publishEvent(event); }