Search in sources :

Example 1 with Auth3dsRequiredEntity

use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.

the class Worldpay3dsRequiredParams method toAuth3dsRequiredEntity.

@Override
public Auth3dsRequiredEntity toAuth3dsRequiredEntity() {
    Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
    auth3dsRequiredEntity.setPaRequest(paRequest);
    auth3dsRequiredEntity.setIssuerUrl(issuerUrl);
    return auth3dsRequiredEntity;
}
Also used : Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)

Example 2 with Auth3dsRequiredEntity

use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.

the class Stripe3dsRequiredParams method toAuth3dsRequiredEntity.

@Override
public Auth3dsRequiredEntity toAuth3dsRequiredEntity() {
    Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
    auth3dsRequiredEntity.setIssuerUrl(issuerUrl);
    auth3dsRequiredEntity.setThreeDsVersion(threeDsVersion);
    return auth3dsRequiredEntity;
}
Also used : Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)

Example 3 with Auth3dsRequiredEntity

use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.

the class Gateway3dsInfoObtainedTest method serializesEventDetailsWithVersion3ds.

@Test
void serializesEventDetailsWithVersion3ds() throws JsonProcessingException {
    Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
    auth3dsRequiredEntity.setThreeDsVersion("2.1.0");
    var chargeEntity = ChargeEntityFixture.aValidChargeEntity().withAuth3dsDetailsEntity(auth3dsRequiredEntity).build();
    var eventDate = ZonedDateTime.now(UTC);
    String actual = Gateway3dsInfoObtained.from(chargeEntity, eventDate).toJsonString();
    assertThat(actual, hasJsonPath("$.timestamp", equalTo(eventDate.toString())));
    assertThat(actual, hasJsonPath("$.event_type", equalTo("GATEWAY_3DS_INFO_OBTAINED")));
    assertThat(actual, hasJsonPath("$.resource_type", equalTo("payment")));
    assertThat(actual, hasJsonPath("$.resource_external_id", equalTo(chargeEntity.getExternalId())));
    assertThat(actual, hasJsonPath("$.event_details.version_3ds", equalTo(chargeEntity.get3dsRequiredDetails().getThreeDsVersion())));
}
Also used : Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity) Test(org.junit.jupiter.api.Test)

Example 4 with Auth3dsRequiredEntity

use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.

the class GatewayRequires3dsAuthorisationTest method serializesEventDetailsGivenChargeEvent.

@Test
public void serializesEventDetailsGivenChargeEvent() throws JsonProcessingException {
    ZonedDateTime updated = ZonedDateTime.parse("2018-03-12T16:25:02.123456Z");
    Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
    auth3dsRequiredEntity.setThreeDsVersion("2.1.0");
    chargeEntity.withAuth3dsDetailsEntity(auth3dsRequiredEntity);
    ChargeEventEntity chargeEvent = mock(ChargeEventEntity.class);
    when(chargeEvent.getChargeEntity()).thenReturn(chargeEntity.build());
    when(chargeEvent.getUpdated()).thenReturn(updated);
    String actual = GatewayRequires3dsAuthorisation.from(chargeEvent).toJsonString();
    assertThat(actual, hasJsonPath("$.event_type", equalTo("GATEWAY_REQUIRES_3DS_AUTHORISATION")));
    assertThat(actual, hasJsonPath("$.resource_type", equalTo("payment")));
    assertThat(actual, hasJsonPath("$.resource_external_id", equalTo(chargeEvent.getChargeEntity().getExternalId())));
    assertThat(actual, hasJsonPath("$.event_details.requires_3ds", equalTo(true)));
    assertThat(actual, hasJsonPath("$.event_details.version_3ds", equalTo("2.1.0")));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity) Test(org.junit.Test)

Example 5 with Auth3dsRequiredEntity

use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.

the class WalletAuthoriseService method doAuthorise.

public GatewayResponse<BaseAuthoriseResponse> doAuthorise(String chargeId, WalletAuthorisationData walletAuthorisationData) {
    return authorisationService.executeAuthorise(chargeId, () -> {
        final ChargeEntity charge = prepareChargeForAuthorisation(chargeId);
        GatewayResponse<BaseAuthoriseResponse> operationResponse;
        ChargeStatus chargeStatus = null;
        String requestStatus = "failure";
        try {
            operationResponse = authorise(charge, walletAuthorisationData);
            if (operationResponse.getBaseResponse().isPresent()) {
                requestStatus = "success";
                chargeStatus = operationResponse.getBaseResponse().get().authoriseStatus().getMappedChargeStatus();
            } else {
                operationResponse.throwGatewayError();
            }
        } catch (GatewayException e) {
            LOGGER.error("Error occurred authorising charge. Charge external id: {}; message: {}", charge.getExternalId(), e.getMessage());
            if (e instanceof GatewayErrorException) {
                LOGGER.error("Response from gateway: {}", ((GatewayErrorException) e).getResponseFromGateway());
            }
            chargeStatus = AuthorisationService.mapFromGatewayErrorException(e);
            operationResponse = GatewayResponse.GatewayResponseBuilder.responseBuilder().withGatewayError(e.toGatewayError()).build();
        }
        Optional<String> transactionId = authorisationService.extractTransactionId(charge.getExternalId(), operationResponse);
        Optional<ProviderSessionIdentifier> sessionIdentifier = operationResponse.getSessionIdentifier();
        Optional<Auth3dsRequiredEntity> auth3dsDetailsEntity = operationResponse.getBaseResponse().flatMap(BaseAuthoriseResponse::extractAuth3dsRequiredDetails);
        logMetrics(charge, operationResponse, requestStatus, walletAuthorisationData.getWalletType());
        processGatewayAuthorisationResponse(charge.getExternalId(), walletAuthorisationData, transactionId.orElse(null), sessionIdentifier.orElse(null), chargeStatus, auth3dsDetailsEntity);
        authorisationLogger.logChargeAuthorisation(LOGGER, charge, transactionId.orElse("missing transaction ID"), operationResponse, charge.getChargeStatus(), chargeStatus);
        return operationResponse;
    });
}
Also used : ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) ChargeStatus(uk.gov.pay.connector.charge.model.domain.ChargeStatus) GatewayErrorException(uk.gov.pay.connector.gateway.GatewayException.GatewayErrorException) ProviderSessionIdentifier(uk.gov.pay.connector.gateway.model.ProviderSessionIdentifier) GatewayException(uk.gov.pay.connector.gateway.GatewayException) Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)

Aggregations

Auth3dsRequiredEntity (uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)20 Test (org.junit.Test)8 Auth3dsRequiredEntityFixture.anAuth3dsRequiredEntity (uk.gov.pay.connector.model.domain.Auth3dsRequiredEntityFixture.anAuth3dsRequiredEntity)7 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)5 ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)4 BaseAuthoriseResponse (uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse)4 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)2 ChargeStatus (uk.gov.pay.connector.charge.model.domain.ChargeStatus)2 GatewayException (uk.gov.pay.connector.gateway.GatewayException)2 PaymentProvider (uk.gov.pay.connector.gateway.PaymentProvider)2 ProviderSessionIdentifier (uk.gov.pay.connector.gateway.model.ProviderSessionIdentifier)2 CardAuthorisationGatewayRequest (uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest)2 SmartpayPaymentProvider (uk.gov.pay.connector.gateway.smartpay.SmartpayPaymentProvider)2 ChargeEventEntityFixture.aValidChargeEventEntity (uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity)2 Logger (ch.qos.logback.classic.Logger)1 ZonedDateTime (java.time.ZonedDateTime)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 Mockito.anyString (org.mockito.Mockito.anyString)1