use of uk.gov.pay.connector.gateway.worldpay.Worldpay3dsFlexRequiredParams in project pay-connector by alphagov.
the class Card3dsResponseAuthServiceTest method process3DSecureAuthorisation_shouldStoreWorldpay3dsFlexRequiredParams.
@Test
public void process3DSecureAuthorisation_shouldStoreWorldpay3dsFlexRequiredParams() {
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 Worldpay3dsFlexRequiredParams(REQUIRES_3DS_WORLDPAY_3DS_FLEX_CHALLENGE_ACS_URL, REQUIRES_3DS_WORLDPAY_3DS_FLEX_CHALLENGE_TRANSACTION_ID, REQUIRES_3DS_WORLDPAY_3DS_FLEX_CHALLENGE_PAYLOAD, REQUIRES_3DS_WORLDPAY_3DS_FLEX_3DS_VERSION);
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().getWorldpayChallengeAcsUrl(), is(REQUIRES_3DS_WORLDPAY_3DS_FLEX_CHALLENGE_ACS_URL));
assertThat(charge.get3dsRequiredDetails().getWorldpayChallengeTransactionId(), is(REQUIRES_3DS_WORLDPAY_3DS_FLEX_CHALLENGE_TRANSACTION_ID));
assertThat(charge.get3dsRequiredDetails().getWorldpayChallengePayload(), is(REQUIRES_3DS_WORLDPAY_3DS_FLEX_CHALLENGE_PAYLOAD));
assertThat(charge.get3dsRequiredDetails().getThreeDsVersion(), is(REQUIRES_3DS_WORLDPAY_3DS_FLEX_3DS_VERSION));
assertThat(charge.getProviderSessionId(), is("provider-session-identifier"));
assertTrue(argumentCaptor.getValue().getTransactionId().isPresent());
assertThat(argumentCaptor.getValue().getTransactionId().get(), is(GENERATED_TRANSACTION_ID));
}
Aggregations