Search in sources :

Example 1 with Worldpay3dsFlexRequiredParams

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));
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) Gateway3dsRequiredParams(uk.gov.pay.connector.gateway.model.Gateway3dsRequiredParams) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) Worldpay3dsFlexRequiredParams(uk.gov.pay.connector.gateway.worldpay.Worldpay3dsFlexRequiredParams) Test(org.junit.Test)

Aggregations

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