Search in sources :

Example 1 with Worldpay3dsRequiredParams

use of uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams in project pay-connector by alphagov.

the class Card3dsResponseAuthServiceTest method process3DSecureAuthorisation_shouldSetStatusToAuthorisationRejectedIfMaxAttemptsExceeded.

@Test
public void process3DSecureAuthorisation_shouldSetStatusToAuthorisationRejectedIfMaxAttemptsExceeded() {
    Auth3dsResult auth3dsResult = AuthUtils.buildAuth3dsResult();
    ArgumentCaptor<Auth3dsResponseGatewayRequest> argumentCaptor = ArgumentCaptor.forClass(Auth3dsResponseGatewayRequest.class);
    when(mockedChargeDao.findByExternalId(charge.getExternalId())).thenReturn(Optional.of(charge));
    when(mockAuthorisation3dsConfig.getMaximumNumberOfTimesToAllowUserToAttempt3ds()).thenReturn(3);
    when(mockedChargeDao.count3dsRequiredEventsForChargeExternalId(charge.getExternalId())).thenReturn(3);
    Gateway3dsRequiredParams gateway3dsRequiredParams = new Worldpay3dsRequiredParams(REQUIRES_3DS_ISSUER_URL, REQUIRES_3DS_PA_REQUEST);
    setupMockExecutorServiceMock();
    setupPaymentProviderMock(charge.getGatewayTransactionId(), AuthoriseStatus.REQUIRES_3DS, gateway3dsRequiredParams, ProviderSessionIdentifier.of("provider-session-identifier"), argumentCaptor);
    when(mockedProviders.byName(charge.getPaymentGatewayName())).thenReturn(mockedPaymentProvider);
    Gateway3DSAuthorisationResponse response = card3dsResponseAuthService.process3DSecureAuthorisation(charge.getExternalId(), auth3dsResult);
    assertThat(response.isSuccessful(), is(false));
    assertThat(charge.getStatus(), is(AUTHORISATION_REJECTED.getValue()));
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) Worldpay3dsRequiredParams(uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams) Gateway3dsRequiredParams(uk.gov.pay.connector.gateway.model.Gateway3dsRequiredParams) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) Test(org.junit.Test)

Example 2 with Worldpay3dsRequiredParams

use of uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams in project pay-connector by alphagov.

the class Card3dsResponseAuthServiceTest method process3DSecureAuthorisation_shouldSetStatusToAuthorisation3dsRequiredIfMaxAttemptsNotExceeded.

@Test
public void process3DSecureAuthorisation_shouldSetStatusToAuthorisation3dsRequiredIfMaxAttemptsNotExceeded() {
    Auth3dsResult auth3dsResult = AuthUtils.buildAuth3dsResult();
    ArgumentCaptor<Auth3dsResponseGatewayRequest> argumentCaptor = ArgumentCaptor.forClass(Auth3dsResponseGatewayRequest.class);
    when(mockedChargeDao.findByExternalId(charge.getExternalId())).thenReturn(Optional.of(charge));
    when(mockAuthorisation3dsConfig.getMaximumNumberOfTimesToAllowUserToAttempt3ds()).thenReturn(3);
    when(mockedChargeDao.count3dsRequiredEventsForChargeExternalId(charge.getExternalId())).thenReturn(2);
    Gateway3dsRequiredParams gateway3dsRequiredParams = new Worldpay3dsRequiredParams(REQUIRES_3DS_ISSUER_URL, REQUIRES_3DS_PA_REQUEST);
    setupMockExecutorServiceMock();
    setupPaymentProviderMock(charge.getGatewayTransactionId(), AuthoriseStatus.REQUIRES_3DS, gateway3dsRequiredParams, ProviderSessionIdentifier.of("provider-session-identifier"), argumentCaptor);
    when(mockedProviders.byName(charge.getPaymentGatewayName())).thenReturn(mockedPaymentProvider);
    Gateway3DSAuthorisationResponse response = card3dsResponseAuthService.process3DSecureAuthorisation(charge.getExternalId(), auth3dsResult);
    assertThat(response.isSuccessful(), is(false));
    assertThat(charge.getStatus(), is(AUTHORISATION_3DS_REQUIRED.getValue()));
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) Worldpay3dsRequiredParams(uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams) Gateway3dsRequiredParams(uk.gov.pay.connector.gateway.model.Gateway3dsRequiredParams) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) Test(org.junit.Test)

Example 3 with Worldpay3dsRequiredParams

use of uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams in project pay-connector by alphagov.

the class Card3dsResponseAuthServiceTest method process3DSecureAuthorisation_shouldStoreWorldpay3dsRequiredParams.

@Test
public void process3DSecureAuthorisation_shouldStoreWorldpay3dsRequiredParams() {
    Auth3dsResult auth3dsResult = AuthUtils.buildAuth3dsResult();
    ArgumentCaptor<Auth3dsResponseGatewayRequest> argumentCaptor = ArgumentCaptor.forClass(Auth3dsResponseGatewayRequest.class);
    when(mockedChargeDao.findByExternalId(charge.getExternalId())).thenReturn(Optional.of(charge));
    when(mockAuthorisation3dsConfig.getMaximumNumberOfTimesToAllowUserToAttempt3ds()).thenReturn(3);
    Gateway3dsRequiredParams gateway3dsRequiredParams = new Worldpay3dsRequiredParams(REQUIRES_3DS_ISSUER_URL, REQUIRES_3DS_PA_REQUEST);
    setupMockExecutorServiceMock();
    setupPaymentProviderMock(charge.getGatewayTransactionId(), AuthoriseStatus.REQUIRES_3DS, gateway3dsRequiredParams, ProviderSessionIdentifier.of("provider-session-identifier"), argumentCaptor);
    when(mockedProviders.byName(charge.getPaymentGatewayName())).thenReturn(mockedPaymentProvider);
    Gateway3DSAuthorisationResponse response = card3dsResponseAuthService.process3DSecureAuthorisation(charge.getExternalId(), auth3dsResult);
    assertThat(response.isSuccessful(), is(false));
    assertThat(charge.getStatus(), is(AUTHORISATION_3DS_REQUIRED.getValue()));
    assertThat(charge.getGatewayTransactionId(), is(GENERATED_TRANSACTION_ID));
    assertThat(charge.get3dsRequiredDetails().getIssuerUrl(), is(REQUIRES_3DS_ISSUER_URL));
    assertThat(charge.get3dsRequiredDetails().getPaRequest(), is(REQUIRES_3DS_PA_REQUEST));
    assertThat(charge.getProviderSessionId(), is("provider-session-identifier"));
    assertTrue(argumentCaptor.getValue().getTransactionId().isPresent());
    assertThat(argumentCaptor.getValue().getTransactionId().get(), is(GENERATED_TRANSACTION_ID));
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) Worldpay3dsRequiredParams(uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams) Gateway3dsRequiredParams(uk.gov.pay.connector.gateway.model.Gateway3dsRequiredParams) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Auth3dsResult (uk.gov.pay.connector.gateway.model.Auth3dsResult)3 Gateway3dsRequiredParams (uk.gov.pay.connector.gateway.model.Gateway3dsRequiredParams)3 Auth3dsResponseGatewayRequest (uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest)3 Gateway3DSAuthorisationResponse (uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse)3 Worldpay3dsRequiredParams (uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams)3