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