Source:
public GatewayResponse authorise(AuthorisationGatewayRequest request) { logger.info("Calling Stripe for authorisation of charge [{}]", request.getChargeExternalId()); Response tokenResponse = client.postRequest( request.getGatewayAccount(), AUTHORISE, URI.create(stripeGatewayConfig.getUrl() + "/v1/tokens"), tokenPayload(request), getAuthHeaderValue(), APPLICATION_FORM_URLENCODED_TYPE); if (tokenResponse.getStatusInfo().getFamily() == Response.Status.Family.CLIENT_ERROR) { String reason = tokenResponse.readEntity(StripeError.class).getError().getMessage(); String errorId = UUID.randomUUID().toString(); logger.error("There was error calling /v1/tokens. Reason: {}, ErrorId: {}", reason, errorId); throw new WebApplicationException("There was an internal server error. ErrorId: " + errorId); } String token = tokenResponse.readEntity(StripeTokenResponse.class).getId(); Response sourcesResponse = client.postRequest( request.getGatewayAccount(), AUTHORISE, URI.create(stripeGatewayConfig.getUrl() + "/v1/sources"), sourcesPayload(token), getAuthHeaderValue(), APPLICATION_FORM_URLENCODED_TYPE); String tokenFromSources = sourcesResponse.readEntity(StripeSourcesResponse.class).getId(); Response authorisationResponse = client.postRequest( request.getGatewayAccount(), AUTHORISE, URI.create(stripeGatewayConfig.getUrl() + "/v1/charges"), authorisePayload(request, tokenFromSources), getAuthHeaderValue(), APPLICATION_FORM_URLENCODED_TYPE); GatewayResponse.GatewayResponseBuilder<BaseResponse> responseBuilder = GatewayResponse.GatewayResponseBuilder.responseBuilder(); return responseBuilder.withResponse(StripeAuthorisationResponse.of(authorisationResponse)).build(); }

Target:
public GatewayResponse authorise(AuthorisationGatewayRequest request) { logger.info("Calling Stripe for authorisation of charge [{}]", request.getChargeExternalId()); Response tokenResponse = client.postRequest( request.getGatewayAccount(), AUTHORISE, URI.create(stripeGatewayConfig.getUrl() + "/v1/tokens"), tokenPayload(request), getAuthHeaderValue(), APPLICATION_FORM_URLENCODED_TYPE); if (tokenResponse.getStatusInfo().getFamily() == Response.Status.Family.CLIENT_ERROR) { String reason = tokenResponse.readEntity(StripeError.class).getError().getMessage(); String errorId = UUID.randomUUID().toString(); logger.error("There was error calling /v1/tokens. Reason: {}, ErrorId: {}", reason, errorId); throw new WebApplicationException("There was an internal server error. ErrorId: " + errorId); } String token = tokenResponse.readEntity(StripeTokenResponse.class).getId(); Response sourcesResponse = client.postRequest( request.getGatewayAccount(), AUTHORISE, URI.create(stripeGatewayConfig.getUrl() + "/v1/sources"), sourcesPayload(token), getAuthHeaderValue(), APPLICATION_FORM_URLENCODED_TYPE); String sourceId = sourcesResponse.readEntity(StripeSourcesResponse.class).getId(); Response authorisationResponse = client.postRequest( request.getGatewayAccount(), AUTHORISE, URI.create(stripeGatewayConfig.getUrl() + "/v1/charges"), authorisePayload(request, sourceId), getAuthHeaderValue(), APPLICATION_FORM_URLENCODED_TYPE); GatewayResponse.GatewayResponseBuilder<BaseResponse> responseBuilder = GatewayResponse.GatewayResponseBuilder.responseBuilder(); return responseBuilder.withResponse(StripeAuthorisationResponse.of(authorisationResponse)).build(); }