Source:
<code>public GatewayResponse<WorldpayOrderStatusResponse> authorise(CardAuthorisationGatewayRequest request) { GatewayResponse<WorldpayOrderStatusResponse> response = worldpayAuthoriseHandler.authorise(request); <START> if (response.getBaseResponse().isPresent()) { <END> var worldpayOrderResponse = response.getBaseResponse().get(); if (worldpayOrderResponse.getLastEvent().isPresent() && worldpayOrderResponse.getLastEvent().get().equals("REFUSED") && worldpayOrderResponse.getExemptionResponseResult().isPresent() && SOFT_DECLINE_EXEMPTION_RESPONSE_RESULTS.contains(worldpayOrderResponse.getExemptionResponseResult().get())) { var authorisationRequestSummary = generateAuthorisationRequestSummary(request.getCharge(), request.getAuthCardDetails()); Optional<String> transactionId = authorisationService.extractTransactionId(request.getCharge().getExternalId(), response); var logMessage = String.format(Locale.UK, "Authorisation%s for %s (%s %s) for %s (%s) - %s .'. %s -> %s", authorisationRequestSummaryStringifier.stringify(authorisationRequestSummary), request.getCharge().getExternalId(), request.getCharge().getPaymentGatewayName().getName(), transactionId.orElse("missing transaction ID"), request.getCharge().getGatewayAccount().getAnalyticsId(), request.getCharge().getGatewayAccount().getId(), response, ChargeStatus.fromString(request.getCharge().getStatus()), request.getCharge().getStatus()); var structuredLoggingArguments = ArrayUtils.addAll( request.getCharge().getStructuredLoggingArgs(), authorisationRequestSummaryStructuredLogging.createArgs(authorisationRequestSummary)); LOGGER.info(logMessage, structuredLoggingArguments); return worldpayAuthoriseHandler.authorise(request, true); } } return response; }</code><technical_language>Is yank 30 lines a separate method or, better, a separate class? Ideally, want this: java GatewayResponse<WorldpayOrderStatusResponse> response = worldpayAuthoriseHandler.authoriseWithPossibleExemption(request); if (worldpayExemptionResponseFigurerOuterer.isSoftDecline()) { // Some logging stuff here? response = worldpayAuthoriseHandler.authoriseWithoutExemption(request); } return response;</technical_language>

Target:
public GatewayResponse<WorldpayOrderStatusResponse> authorise(CardAuthorisationGatewayRequest request) { GatewayResponse<WorldpayOrderStatusResponse> response = worldpayAuthoriseHandler.authorise(request); if (response.getBaseResponse().map(WorldpayOrderStatusResponse::isSoftDecline).orElse(false)) { var authorisationRequestSummary = generateAuthorisationRequestSummary(request.getCharge(), request.getAuthCardDetails()); Optional<String> transactionId = authorisationService.extractTransactionId(request.getCharge().getExternalId(), response); var logMessage = String.format(Locale.UK, "Authorisation%s for %s (%s %s) for %s (%s) - %s .'. %s -> %s", authorisationRequestSummaryStringifier.stringify(authorisationRequestSummary), request.getCharge().getExternalId(), request.getCharge().getPaymentGatewayName().getName(), transactionId.orElse("missing transaction ID"), request.getCharge().getGatewayAccount().getAnalyticsId(), request.getCharge().getGatewayAccount().getId(), response, ChargeStatus.fromString(request.getCharge().getStatus()), request.getCharge().getStatus()); var structuredLoggingArguments = ArrayUtils.addAll( request.getCharge().getStructuredLoggingArgs(), authorisationRequestSummaryStructuredLogging.createArgs(authorisationRequestSummary)); LOGGER.info(logMessage, structuredLoggingArguments); return worldpayAuthoriseHandler.authorise(request, true); } return response; }