Source:
public GatewayResponse capture(CaptureGatewayRequest request) { String url = stripeGatewayConfig.getUrl() + "/v1/charges/" + request.getTransactionId() + "/capture"; GatewayAccountEntity gatewayAccount = request.getGatewayAccount(); GatewayResponse.GatewayResponseBuilder<BaseResponse> responseBuilder = GatewayResponse.GatewayResponseBuilder.responseBuilder(); try { Response captureResponse = client.postRequest( URI.create(url), StringUtils.EMPTY, ImmutableMap.of(AUTHORIZATION, StripeAuthUtil.getAuthHeaderValue(stripeGatewayConfig)), APPLICATION_FORM_URLENCODED_TYPE, format("gateway-operations.%s.%s.capture", gatewayAccount.getGatewayName(), gatewayAccount.getType())); return responseBuilder.withResponse(StripeCaptureResponse.of(captureResponse)).build(); } catch (GatewayClientException e) { Response response = e.getResponse(); StripeErrorResponse stripeErrorResponse = response.readEntity(StripeErrorResponse.class); String errorId = UUID.randomUUID().toString(); logger.error("Capture failed for transaction id {}. Failure code from Stripe: {}, failure message from Stripe: {}. ErrorId: {}. Response code from Stripe: {}", request.getTransactionId(), stripeErrorResponse.getError().getCode(), stripeErrorResponse.getError().getMessage(), errorId, response.getStatus()); GatewayError gatewayError = new GatewayError(stripeErrorResponse.getError().getMessage(), GENERIC_GATEWAY_ERROR); return responseBuilder.withGatewayError(gatewayError).build(); } catch (GatewayException e) { return responseBuilder.withGatewayError(GatewayError.of(e)).build(); } catch (DownstreamException e) { String errorId = UUID.randomUUID().toString(); logger.error("Capture failed for transaction id {}. Reason: {}. ErrorId: {}", request.getTransactionId(), e.getMessage(), errorId); GatewayError gatewayError = new GatewayError("An internal server error occurred. ErrorId: " + errorId, UNEXPECTED_HTTP_STATUS_CODE_FROM_GATEWAY); return responseBuilder.withGatewayError(gatewayError).build(); } }

Target:
public GatewayResponse capture(CaptureGatewayRequest request) { String url = stripeGatewayConfig.getUrl() + "/v1/charges/" + request.getTransactionId() + "/capture"; GatewayAccountEntity gatewayAccount = request.getGatewayAccount(); GatewayResponse.GatewayResponseBuilder<BaseResponse> responseBuilder = GatewayResponse.GatewayResponseBuilder.responseBuilder(); try { Response captureResponse = client.postRequest( URI.create(url), StringUtils.EMPTY, ImmutableMap.of(AUTHORIZATION, StripeAuthUtil.getAuthHeaderValue(stripeGatewayConfig)), APPLICATION_FORM_URLENCODED_TYPE, format("gateway-operations.%s.%s.capture", gatewayAccount.getGatewayName(), gatewayAccount.getType())); return responseBuilder.withResponse(StripeCaptureResponse.of(captureResponse)).build(); } catch (GatewayClientException e) { Response response = e.getResponse(); StripeErrorResponse stripeErrorResponse = response.readEntity(StripeErrorResponse.class); String errorId = UUID.randomUUID().toString(); logger.error("Capture failed for transaction id {}. Failure code from Stripe: {}, failure message from Stripe: {}. ErrorId: {}. Response code from Stripe: {}", request.getTransactionId(), stripeErrorResponse.getError().getCode(), stripeErrorResponse.getError().getMessage(), errorId, response.getStatus()); GatewayError gatewayError = genericGatewayError(stripeErrorResponse.getError().getMessage()); return responseBuilder.withGatewayError(gatewayError).build(); } catch (GatewayException e) { return responseBuilder.withGatewayError(GatewayError.of(e)).build(); } catch (DownstreamException e) { String errorId = UUID.randomUUID().toString(); logger.error("Capture failed for transaction id {}. Reason: {}. Status code from Stripe: {}. ErrorId: {}", request.getTransactionId(), e.getMessage(), e.getStatusCode(), errorId); GatewayError gatewayError = unexpectedStatusCodeFromGateway("An internal server error occurred. ErrorId: " + errorId); return responseBuilder.withGatewayError(gatewayError).build(); } }