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()));
}
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()));
}
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));
}
Aggregations