-
Notifications
You must be signed in to change notification settings - Fork 33
Feature/ad 368 #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/ad 368 #579
Conversation
# Conflicts: # adyenv6core/resources/adyenv6core-beans.xml
| } | ||
|
|
||
| @Override | ||
| public void updatePaymentRequest(PaymentRequest paymentRequest, CartData cartData, RecurringContractMode recurringContractMode, CustomerModel customerModel, Boolean is3DS2Allowed, Boolean guestUserTokenizationEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CardSubscriptionHandler.java, IdealSubscriptionHandler.java, KlarnaSubscriptionHandler.java, PayPalSubscriptionHandler.java
These four files share almost identical logic in updatePaymentRequest. Did you consider a generalisation of this code ? For example:
PaymentMethodHandler {
protected abstract T getPaymentMethodDetails(PaymentRequest request);
protected abstract T createNewPaymentMethodDetails();
@Override
public void updatePaymentRequest(PaymentRequest paymentRequest, CartData cartData, ...) {
if (StringUtils.isNotEmpty(cartData.getAdyenSelectedReference())) {
T details = getPaymentMethodDetails(paymentRequest);
if (details == null) {
details = createNewPaymentMethodDetails();
}
details.setStoredPaymentMethodId(cartData.getAdyenSelectedReference());
CheckoutPaymentMethod checkoutPaymentMethod = new CheckoutPaymentMethod();
checkoutPaymentMethod.setActualInstance(details);
paymentRequest.setPaymentMethod(checkoutPaymentMethod);
paymentRequest.setRecurringProcessingModel(PaymentRequest.RecurringProcessingModelEnum.SUBSCRIPTION);
paymentRequest.setShopperInteraction(PaymentRequest.ShopperInteractionEnum.CONTAUTH);
}
}
}
| paymentInfo.setAdyenSelectedReference(data.getStoredPaymentMethodId()); | ||
| modelService.save(paymentInfo); | ||
| } else { | ||
| throw new NotImplementedException("TokenizationWebhookEventListener not implemented for type " + data.getEventType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing NotImplementedException inside an Event Listener is risky. If the event system retries.
| throw new NotImplementedException("TokenizationWebhookEventListener not implemented for type " + data.getEventType()); | |
| LOG.warn("Received Tokenization event of type [" + data.getEventType() + "] which is not currently handled."); |
| validationResult &= order.getStore().getAdyenMerchantAccount().equals(tokenWebhookRequestData.getMerchantAccount()); | ||
|
|
||
| validationResult &= (order.getStore().getAdyenTestMode() && "test".equals(tokenWebhookRequestData.getEnvironment())) || | ||
| (!order.getStore().getAdyenTestMode() && "live".equals(tokenWebhookRequestData.getEnvironment())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strings "test" and "live" are hardcoded in the cross-check logic.
Move these to constants in AdyenConstants or a similar configuration class to ensure consistency across the codebase.
| typeService.getComposedTypeForClass(CartEntryModel.class), subscriptionOrder, (String) keyGenerator.generate()); | ||
| cart.setSubscriptionOrder(Boolean.TRUE); | ||
| //TODO in refactoring | ||
| cart.setParent(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this cannot be refactored now, the comment should be more descriptive explaining why it is set to null (likely to detach the cloned cart from the original order context for the CronJob) and link to a Jira ticket/backlog item.
|
|
||
| protected boolean tokenizeForSubscriptionProducts(CartData cartData) { | ||
| return !cartData.getSubscriptionOrder() && cartData.getEntries().stream() | ||
| .anyMatch(entry -> Objects.nonNull(entry.getProduct().getSubscriptionTerm())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic assumes that cartData.getSubscriptionOrder() is false for the initial checkout and true only for the subsequent recurring runs. This might throw a NullPointerException (unless it's a primitive boolean, but the bean definition showed java.lang.Boolean).
| { | ||
| objectMapper = new ObjectMapper(); | ||
| objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initialization block is an instance initializer, but the variable is static. This means objectMapper is re-initialized every time the controller is instantiated (which is fine for Singleton beans, but technically incorrect Java semantics for static variables).
| } | |
| private static final ObjectMapper objectMapper = new ObjectMapper() | |
| .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
Description
Tested scenarios
Fixed issue: