Source:
public GatewayResponse<BaseAuthoriseResponse> doAuthorise(String chargeId, WalletAuthorisationData walletAuthorisationData) { return cardAuthoriseBaseService.executeAuthorise(chargeId, () -> { final ChargeEntity charge = prepareChargeForAuthorisation(chargeId); GatewayResponse<BaseAuthoriseResponse> operationResponse = null; Optional<String> transactionId = Optional.empty(); Optional<String> sessionIdentifier = Optional.empty(); ChargeStatus chargeStatus = null; String responseFromPaymentGateway = null; try { operationResponse = authorise(charge, walletAuthorisationData); Optional<BaseAuthoriseResponse> baseResponse = operationResponse.getBaseResponse(); if (baseResponse.isPresent()) { chargeStatus = baseResponse.get().authoriseStatus().getMappedChargeStatus(); transactionId = cardAuthoriseBaseService.extractTransactionId(charge.getExternalId(), operationResponse); sessionIdentifier = operationResponse.getSessionIdentifier(); responseFromPaymentGateway = baseResponse.toString(); } else operationResponse.throwGatewayError(); logger.info("Google pay authorisation success - charge_external_id={}, payment provider response={}", chargeId, operationResponse.toString()); } catch (GatewayErrorException e) { if (e instanceof GenericGatewayErrorException) chargeStatus = AUTHORISATION_ERROR; if (e instanceof GatewayConnectionTimeoutErrorException) chargeStatus = AUTHORISATION_TIMEOUT; if (e instanceof GatewayConnectionErrorException) chargeStatus = AUTHORISATION_UNEXPECTED_ERROR; responseFromPaymentGateway = e.getMessage(); operationResponse = GatewayResponse.GatewayResponseBuilder.responseBuilder().withGatewayError(e.toGatewayError()).build(); logger.info("Google pay authorisation unsuccessful - charge_external_id={}, payment provider response={}", chargeId, operationResponse.toString()); } processGatewayAuthorisationResponse( charge.getExternalId(), ChargeStatus.fromString(charge.getStatus()), walletAuthorisationData, responseFromPaymentGateway, transactionId, sessionIdentifier, chargeStatus); return operationResponse; }); }

Target:
public GatewayResponse<BaseAuthoriseResponse> doAuthorise(String chargeId, WalletAuthorisationData walletAuthorisationData) { return cardAuthoriseBaseService.executeAuthorise(chargeId, () -> { final ChargeEntity charge = prepareChargeForAuthorisation(chargeId); GatewayResponse<BaseAuthoriseResponse> operationResponse = null; Optional<String> transactionId = Optional.empty(); Optional<String> sessionIdentifier = Optional.empty(); ChargeStatus chargeStatus = null; String responseFromPaymentGateway = null; String requestStatus = "failure"; try { operationResponse = authorise(charge, walletAuthorisationData); Optional<BaseAuthoriseResponse> baseResponse = operationResponse.getBaseResponse(); if (baseResponse.isPresent()) { requestStatus = "success"; chargeStatus = baseResponse.get().authoriseStatus().getMappedChargeStatus(); transactionId = cardAuthoriseBaseService.extractTransactionId(charge.getExternalId(), operationResponse); sessionIdentifier = operationResponse.getSessionIdentifier(); responseFromPaymentGateway = baseResponse.toString(); } else { operationResponse.throwGatewayError(); } } catch (GatewayErrorException e) { chargeStatus = CardAuthoriseBaseService.mapFromGatewayErrorException(e); responseFromPaymentGateway = e.getMessage(); operationResponse = GatewayResponse.GatewayResponseBuilder.responseBuilder().withGatewayError(e.toGatewayError()).build(); } logMetrics(charge, operationResponse, requestStatus, walletAuthorisationData.getWalletType()); processGatewayAuthorisationResponse( charge.getExternalId(), ChargeStatus.fromString(charge.getStatus()), walletAuthorisationData, responseFromPaymentGateway, transactionId, sessionIdentifier, chargeStatus); return operationResponse; }); }