use of uk.gov.pay.connector.gateway.epdq.model.response.EpdqQueryResponse in project pay-connector by alphagov.
the class EpdqPaymentProvider method queryPaymentStatus.
public ChargeQueryResponse queryPaymentStatus(ChargeQueryGatewayRequest chargeQueryGatewayRequest) throws GatewayException {
URI url = URI.create(String.format("%s/%s", gatewayUrlMap.get(chargeQueryGatewayRequest.getGatewayAccount().getType()), ROUTE_FOR_QUERY_ORDER));
GatewayClient.Response response = authoriseClient.postRequestFor(url, EPDQ, chargeQueryGatewayRequest.getGatewayAccount().getType(), buildQueryOrderRequestFor(chargeQueryGatewayRequest), getGatewayAccountCredentialsAsAuthHeader(chargeQueryGatewayRequest.getGatewayCredentials()));
GatewayResponse<EpdqQueryResponse> epdqGatewayResponse = getUninterpretedEpdqGatewayResponse(response, EpdqQueryResponse.class);
return epdqGatewayResponse.getBaseResponse().map(epdqQueryResponse -> {
ChargeStatus mappedStatus = EpdqStatusMapper.map(epdqQueryResponse.getStatus());
return new ChargeQueryResponse(mappedStatus, epdqQueryResponse);
}).orElseThrow(() -> new WebApplicationException(String.format("Unable to query charge %s - an error occurred: %s", chargeQueryGatewayRequest.getChargeExternalId(), epdqGatewayResponse)));
}
Aggregations