Search in sources :

Example 1 with Auth3dsResult

use of uk.gov.pay.connector.gateway.model.Auth3dsResult in project pay-connector by alphagov.

the class EpdqPaymentProviderTest method buildQueryRequest.

private static Auth3dsResponseGatewayRequest buildQueryRequest(ChargeEntity chargeEntity, String auth3DResult) {
    Auth3dsResult auth3DsResult = new Auth3dsResult();
    auth3DsResult.setAuth3dsResult(auth3DResult);
    return new Auth3dsResponseGatewayRequest(chargeEntity, auth3DsResult);
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult)

Example 2 with Auth3dsResult

use of uk.gov.pay.connector.gateway.model.Auth3dsResult in project pay-connector by alphagov.

the class StripeNotificationService method executePost3DSAuthorisation.

private void executePost3DSAuthorisation(ChargeEntity charge, String notificationEventType, StripePaymentIntent paymentIntent) {
    try {
        final StripeNotificationType type = byType(notificationEventType);
        Auth3dsResult auth3DsResult = new Auth3dsResult();
        auth3DsResult.setAuth3dsResult(getMappedAuth3dsResult(type));
        Optional<StripeCharge> optionalStripeCharge = paymentIntent.getCharge();
        optionalStripeCharge.ifPresent(stripeCharge -> {
            if (stripeCharge.getPaymentMethodDetails() != null && stripeCharge.getPaymentMethodDetails().getCard() != null && stripeCharge.getPaymentMethodDetails().getCard().getThreeDSecure() != null) {
                auth3DsResult.setThreeDsVersion(stripeCharge.getPaymentMethodDetails().getCard().getThreeDSecure().getVersion());
            }
        });
        delayFor3dsReady(charge);
        card3dsResponseAuthService.process3DSecureAuthorisationWithoutLocking(charge.getExternalId(), auth3DsResult);
    } catch (OperationAlreadyInProgressRuntimeException e) {
    // CardExecutorService is asynchronous and sends back 'OperationAlreadyInProgressRuntimeException'
    // exception while the charge is being authorised. Catch this exception to send a response with
    // http status 200 instead of depending on the status returned by Exception
    }
}
Also used : Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) StripeCharge(uk.gov.pay.connector.gateway.stripe.json.StripeCharge) OperationAlreadyInProgressRuntimeException(uk.gov.pay.connector.common.exception.OperationAlreadyInProgressRuntimeException)

Example 3 with Auth3dsResult

use of uk.gov.pay.connector.gateway.model.Auth3dsResult in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method get3dsResponseGatewayRequest.

private Auth3dsResponseGatewayRequest get3dsResponseGatewayRequest(ChargeEntity chargeEntity) {
    Auth3dsResult auth3dsResult = new Auth3dsResult();
    auth3dsResult.setPaResponse("I am an opaque 3D Secure PA response from the card issuer");
    return new Auth3dsResponseGatewayRequest(chargeEntity, auth3dsResult);
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult)

Example 4 with Auth3dsResult

use of uk.gov.pay.connector.gateway.model.Auth3dsResult in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method should_construct_gateway_3DS_authorisation_response_with_paRequest_issuerUrl_and_machine_cookie_if_worldpay_asks_us_to_do_3ds_again.

@Test
void should_construct_gateway_3DS_authorisation_response_with_paRequest_issuerUrl_and_machine_cookie_if_worldpay_asks_us_to_do_3ds_again() throws Exception {
    ChargeEntity chargeEntity = chargeEntityFixture.withProviderSessionId("original-machine-cookie").build();
    when(response.getEntity()).thenReturn(load(WORLDPAY_3DS_RESPONSE));
    when(response.getResponseCookies()).thenReturn(Map.of(WORLDPAY_MACHINE_COOKIE_NAME, "new-machine-cookie-value"));
    when(authoriseClient.postRequestFor(eq(WORLDPAY_URL), eq(WORLDPAY), eq("test"), any(GatewayOrder.class), eq(List.of(new HttpCookie(WORLDPAY_MACHINE_COOKIE_NAME, "original-machine-cookie"))), anyMap())).thenReturn(response);
    var auth3dsResult = new Auth3dsResult();
    auth3dsResult.setPaResponse("pa-response");
    var auth3dsResponseGatewayRequest = new Auth3dsResponseGatewayRequest(chargeEntity, auth3dsResult);
    Gateway3DSAuthorisationResponse result = worldpayPaymentProvider.authorise3dsResponse(auth3dsResponseGatewayRequest);
    assertThat(result.getGateway3dsRequiredParams().isPresent(), is(true));
    assertThat(result.getGateway3dsRequiredParams().get().toAuth3dsRequiredEntity().getPaRequest(), is("eJxVUsFuwjAM/ZWK80aSUgpFJogNpHEo2hjTzl"));
    assertThat(result.getGateway3dsRequiredParams().get().toAuth3dsRequiredEntity().getIssuerUrl(), is("https://secure-test.worldpay.com/jsp/test/shopper/ThreeDResponseSimulator.jsp"));
    assertThat(result.getProviderSessionIdentifier().isPresent(), is(true));
    assertThat(result.getProviderSessionIdentifier().get(), is(ProviderSessionIdentifier.of("new-machine-cookie-value")));
}
Also used : ChargeEntityFixture.aValidChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity) ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) HttpCookie(java.net.HttpCookie) GatewayOrder(uk.gov.pay.connector.gateway.GatewayOrder) Test(org.junit.jupiter.api.Test)

Example 5 with Auth3dsResult

use of uk.gov.pay.connector.gateway.model.Auth3dsResult in project pay-connector by alphagov.

the class Card3dsResponseAuthServiceTest method process3DSecureAuthorisation_shouldPopulateTheProviderSessionId.

@Test
public void process3DSecureAuthorisation_shouldPopulateTheProviderSessionId() {
    Auth3dsResult auth3dsResult = AuthUtils.buildAuth3dsResult();
    ProviderSessionIdentifier providerSessionId = ProviderSessionIdentifier.of("provider-session-id");
    charge.setProviderSessionId(providerSessionId.toString());
    ArgumentCaptor<Auth3dsResponseGatewayRequest> argumentCaptor = ArgumentCaptor.forClass(Auth3dsResponseGatewayRequest.class);
    when(mockedChargeDao.findByExternalId(charge.getExternalId())).thenReturn(Optional.of(charge));
    setupMockExecutorServiceMock();
    setupPaymentProviderMock(charge.getGatewayTransactionId(), AuthoriseStatus.AUTHORISED, null, null, argumentCaptor);
    when(mockedProviders.byName(charge.getPaymentGatewayName())).thenReturn(mockedPaymentProvider);
    card3dsResponseAuthService.process3DSecureAuthorisation(charge.getExternalId(), auth3dsResult);
    assertTrue(argumentCaptor.getValue().getProviderSessionId().isPresent());
    assertThat(argumentCaptor.getValue().getProviderSessionId().get(), is(providerSessionId));
}
Also used : Auth3dsResponseGatewayRequest(uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest) Auth3dsResult(uk.gov.pay.connector.gateway.model.Auth3dsResult) ProviderSessionIdentifier(uk.gov.pay.connector.gateway.model.ProviderSessionIdentifier) Test(org.junit.Test)

Aggregations

Auth3dsResult (uk.gov.pay.connector.gateway.model.Auth3dsResult)17 Auth3dsResponseGatewayRequest (uk.gov.pay.connector.gateway.model.request.Auth3dsResponseGatewayRequest)14 Test (org.junit.Test)8 Gateway3DSAuthorisationResponse (uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse)7 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)5 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)5 Gateway3dsRequiredParams (uk.gov.pay.connector.gateway.model.Gateway3dsRequiredParams)4 Worldpay3dsRequiredParams (uk.gov.pay.connector.gateway.worldpay.Worldpay3dsRequiredParams)3 Test (org.junit.jupiter.api.Test)2 GatewayOrder (uk.gov.pay.connector.gateway.GatewayOrder)2 HttpCookie (java.net.HttpCookie)1 URI (java.net.URI)1 OperationAlreadyInProgressRuntimeException (uk.gov.pay.connector.common.exception.OperationAlreadyInProgressRuntimeException)1 GatewayException (uk.gov.pay.connector.gateway.GatewayException)1 ProviderSessionIdentifier (uk.gov.pay.connector.gateway.model.ProviderSessionIdentifier)1 StripeCharge (uk.gov.pay.connector.gateway.stripe.json.StripeCharge)1 Worldpay3dsFlexRequiredParams (uk.gov.pay.connector.gateway.worldpay.Worldpay3dsFlexRequiredParams)1 GatewayAccountEntity (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity)1