Source:
public GatewayResponse<BaseRefundResponse> refund(RefundGatewayRequest request) { String url = stripeGatewayConfig.getUrl() + "/v1/refunds"; GatewayAccountEntity gatewayAccount = request.getGatewayAccount(); GatewayResponse.GatewayResponseBuilder<BaseResponse> responseBuilder = GatewayResponse.GatewayResponseBuilder.responseBuilder(); try { String payload = URLEncodedUtils.format(buildPayload(request.getTransactionId(), request.getAmount()), UTF_8); final Response response = client.postRequest( URI.create(url), payload, ImmutableMap.of(AUTHORIZATION, getAuthHeaderValue(stripeGatewayConfig)), APPLICATION_FORM_URLENCODED_TYPE, format("gateway-operations.%s.%s.cancel", gatewayAccount.getGatewayName(), gatewayAccount.getType())); return responseBuilder.withResponse(StripeRefundResponse.of(response)).build(); } catch (GatewayClientException e) { Response response = e.getResponse(); StripeErrorResponse stripeErrorResponse = response.readEntity(StripeErrorResponse.class); String errorId = UUID.randomUUID().toString(); logger.error("Refund 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("Refund 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(); } }

Target:
public GatewayResponse<BaseRefundResponse> refund(RefundGatewayRequest request) { String url = stripeGatewayConfig.getUrl() + "/v1/refunds"; GatewayAccountEntity gatewayAccount = request.getGatewayAccount(); GatewayResponse.GatewayResponseBuilder<BaseResponse> responseBuilder = GatewayResponse.GatewayResponseBuilder.responseBuilder(); try { String payload = URLEncodedUtils.format(buildPayload(request.getTransactionId(), request.getAmount()), UTF_8); final Response response = client.postRequest( URI.create(url), payload, ImmutableMap.of(AUTHORIZATION, getAuthHeaderValue(stripeGatewayConfig)), APPLICATION_FORM_URLENCODED_TYPE, format("gateway-operations.%s.%s.refund", gatewayAccount.getGatewayName(), gatewayAccount.getType())); return responseBuilder.withResponse(StripeRefundResponse.of(response)).build(); } catch (GatewayClientException e) { Response response = e.getResponse(); StripeErrorResponse stripeErrorResponse = response.readEntity(StripeErrorResponse.class); String errorId = UUID.randomUUID().toString(); logger.error("Refund 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("Refund 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(); } }