Search in sources :

Example 1 with EPDQ

use of uk.gov.pay.connector.gateway.PaymentGatewayName.EPDQ 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)));
}
Also used : EpdqPayloadDefinitionForCancelOrder(uk.gov.pay.connector.gateway.epdq.payload.EpdqPayloadDefinitionForCancelOrder) CREDENTIALS_SHA_IN_PASSPHRASE(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount.CREDENTIALS_SHA_IN_PASSPHRASE) LoggerFactory(org.slf4j.LoggerFactory) AUTHORISE(uk.gov.pay.connector.gateway.GatewayOperation.AUTHORISE) GatewayOrder(uk.gov.pay.connector.gateway.GatewayOrder) CREDENTIALS_MERCHANT_ID(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount.CREDENTIALS_MERCHANT_ID) PaymentProvider(uk.gov.pay.connector.gateway.PaymentProvider) Map(java.util.Map) ChargeQueryGatewayRequest(uk.gov.pay.connector.gateway.ChargeQueryGatewayRequest) EpdqCancelResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse) URI(java.net.URI) RefundGatewayRequest(uk.gov.pay.connector.gateway.model.request.RefundGatewayRequest) EPDQ(uk.gov.pay.connector.gateway.PaymentGatewayName.EPDQ) BaseResponse(uk.gov.pay.connector.gateway.model.response.BaseResponse) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) ERROR(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse.AuthoriseStatus.ERROR) ChargeQueryResponse(uk.gov.pay.connector.gateway.ChargeQueryResponse) String.format(java.lang.String.format) List(java.util.List) EpdqQueryResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqQueryResponse) BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) CANCEL(uk.gov.pay.connector.gateway.GatewayOperation.CANCEL) WebApplicationException(javax.ws.rs.WebApplicationException) Optional(java.util.Optional) ChargeStatus(uk.gov.pay.connector.charge.model.domain.ChargeStatus) EpdqAuthorisationResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqAuthorisationResponse) CAPTURE(uk.gov.pay.connector.gateway.GatewayOperation.CAPTURE) GatewayResponseUnmarshaller.unmarshallResponse(uk.gov.pay.connector.gateway.GatewayResponseUnmarshaller.unmarshallResponse) GatewayRefundResponse(uk.gov.pay.connector.gateway.model.response.GatewayRefundResponse) EpdqPayloadDefinitionForQueryOrder(uk.gov.pay.connector.gateway.epdq.payload.EpdqPayloadDefinitionForQueryOrder) GatewayClient(uk.gov.pay.connector.gateway.GatewayClient) Inject(javax.inject.Inject) Charge(uk.gov.pay.connector.charge.model.domain.Charge) Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) CaptureGatewayRequest(uk.gov.pay.connector.gateway.model.request.CaptureGatewayRequest) GenericGatewayException(uk.gov.pay.connector.gateway.GatewayException.GenericGatewayException) ExternalChargeRefundAvailability(uk.gov.pay.connector.common.model.api.ExternalChargeRefundAvailability) WalletAuthorisationGatewayRequest(uk.gov.pay.connector.wallets.WalletAuthorisationGatewayRequest) CREDENTIALS_PASSWORD(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount.CREDENTIALS_PASSWORD) Environment(io.dropwizard.setup.Environment) PaymentGatewayName(uk.gov.pay.connector.gateway.PaymentGatewayName) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) ExternalRefundAvailabilityCalculator(uk.gov.pay.connector.gateway.util.ExternalRefundAvailabilityCalculator) EpdqPayloadDefinitionForNew3dsOrder(uk.gov.pay.connector.gateway.epdq.payload.EpdqPayloadDefinitionForNew3dsOrder) AuthUtil.getGatewayAccountCredentialsAsAuthHeader(uk.gov.pay.connector.gateway.util.AuthUtil.getGatewayAccountCredentialsAsAuthHeader) BaseCancelResponse(uk.gov.pay.connector.gateway.model.response.BaseCancelResponse) CaptureResponse(uk.gov.pay.connector.gateway.CaptureResponse) REFUND(uk.gov.pay.connector.gateway.GatewayOperation.REFUND) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) EpdqExternalRefundAvailabilityCalculator(uk.gov.pay.connector.gateway.util.EpdqExternalRefundAvailabilityCalculator) CREDENTIALS_USERNAME(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount.CREDENTIALS_USERNAME) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Auth3dsResultOutcome(uk.gov.pay.connector.gateway.model.Auth3dsResult.Auth3dsResultOutcome) GatewayErrorException(uk.gov.pay.connector.gateway.GatewayException.GatewayErrorException) Refund(uk.gov.pay.connector.refund.model.domain.Refund) CancelGatewayRequest(uk.gov.pay.connector.gateway.model.request.CancelGatewayRequest) GatewayResponse(uk.gov.pay.connector.gateway.model.response.GatewayResponse) GatewayClientFactory(uk.gov.pay.connector.gateway.GatewayClientFactory) EpdqPayloadDefinitionForNew3ds2Order(uk.gov.pay.connector.gateway.epdq.payload.EpdqPayloadDefinitionForNew3ds2Order) Clock(java.time.Clock) ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) GatewayException(uk.gov.pay.connector.gateway.GatewayException) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) EpdqPayloadDefinitionForNewOrder(uk.gov.pay.connector.gateway.epdq.payload.EpdqPayloadDefinitionForNewOrder) ChargeQueryResponse(uk.gov.pay.connector.gateway.ChargeQueryResponse) EpdqQueryResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqQueryResponse) GatewayClient(uk.gov.pay.connector.gateway.GatewayClient) ChargeStatus(uk.gov.pay.connector.charge.model.domain.ChargeStatus) WebApplicationException(javax.ws.rs.WebApplicationException) URI(java.net.URI)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 Environment (io.dropwizard.setup.Environment)1 String.format (java.lang.String.format)1 URI (java.net.URI)1 Clock (java.time.Clock)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 ConnectorConfiguration (uk.gov.pay.connector.app.ConnectorConfiguration)1 Charge (uk.gov.pay.connector.charge.model.domain.Charge)1 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)1 ChargeStatus (uk.gov.pay.connector.charge.model.domain.ChargeStatus)1 ExternalChargeRefundAvailability (uk.gov.pay.connector.common.model.api.ExternalChargeRefundAvailability)1 CaptureResponse (uk.gov.pay.connector.gateway.CaptureResponse)1 ChargeQueryGatewayRequest (uk.gov.pay.connector.gateway.ChargeQueryGatewayRequest)1 ChargeQueryResponse (uk.gov.pay.connector.gateway.ChargeQueryResponse)1