use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.
the class Worldpay3dsRequiredParams method toAuth3dsRequiredEntity.
@Override
public Auth3dsRequiredEntity toAuth3dsRequiredEntity() {
Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
auth3dsRequiredEntity.setPaRequest(paRequest);
auth3dsRequiredEntity.setIssuerUrl(issuerUrl);
return auth3dsRequiredEntity;
}
use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.
the class Stripe3dsRequiredParams method toAuth3dsRequiredEntity.
@Override
public Auth3dsRequiredEntity toAuth3dsRequiredEntity() {
Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
auth3dsRequiredEntity.setIssuerUrl(issuerUrl);
auth3dsRequiredEntity.setThreeDsVersion(threeDsVersion);
return auth3dsRequiredEntity;
}
use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.
the class Gateway3dsInfoObtainedTest method serializesEventDetailsWithVersion3ds.
@Test
void serializesEventDetailsWithVersion3ds() throws JsonProcessingException {
Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
auth3dsRequiredEntity.setThreeDsVersion("2.1.0");
var chargeEntity = ChargeEntityFixture.aValidChargeEntity().withAuth3dsDetailsEntity(auth3dsRequiredEntity).build();
var eventDate = ZonedDateTime.now(UTC);
String actual = Gateway3dsInfoObtained.from(chargeEntity, eventDate).toJsonString();
assertThat(actual, hasJsonPath("$.timestamp", equalTo(eventDate.toString())));
assertThat(actual, hasJsonPath("$.event_type", equalTo("GATEWAY_3DS_INFO_OBTAINED")));
assertThat(actual, hasJsonPath("$.resource_type", equalTo("payment")));
assertThat(actual, hasJsonPath("$.resource_external_id", equalTo(chargeEntity.getExternalId())));
assertThat(actual, hasJsonPath("$.event_details.version_3ds", equalTo(chargeEntity.get3dsRequiredDetails().getThreeDsVersion())));
}
use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.
the class GatewayRequires3dsAuthorisationTest method serializesEventDetailsGivenChargeEvent.
@Test
public void serializesEventDetailsGivenChargeEvent() throws JsonProcessingException {
ZonedDateTime updated = ZonedDateTime.parse("2018-03-12T16:25:02.123456Z");
Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
auth3dsRequiredEntity.setThreeDsVersion("2.1.0");
chargeEntity.withAuth3dsDetailsEntity(auth3dsRequiredEntity);
ChargeEventEntity chargeEvent = mock(ChargeEventEntity.class);
when(chargeEvent.getChargeEntity()).thenReturn(chargeEntity.build());
when(chargeEvent.getUpdated()).thenReturn(updated);
String actual = GatewayRequires3dsAuthorisation.from(chargeEvent).toJsonString();
assertThat(actual, hasJsonPath("$.event_type", equalTo("GATEWAY_REQUIRES_3DS_AUTHORISATION")));
assertThat(actual, hasJsonPath("$.resource_type", equalTo("payment")));
assertThat(actual, hasJsonPath("$.resource_external_id", equalTo(chargeEvent.getChargeEntity().getExternalId())));
assertThat(actual, hasJsonPath("$.event_details.requires_3ds", equalTo(true)));
assertThat(actual, hasJsonPath("$.event_details.version_3ds", equalTo("2.1.0")));
}
use of uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity in project pay-connector by alphagov.
the class WalletAuthoriseService method doAuthorise.
public GatewayResponse<BaseAuthoriseResponse> doAuthorise(String chargeId, WalletAuthorisationData walletAuthorisationData) {
return authorisationService.executeAuthorise(chargeId, () -> {
final ChargeEntity charge = prepareChargeForAuthorisation(chargeId);
GatewayResponse<BaseAuthoriseResponse> operationResponse;
ChargeStatus chargeStatus = null;
String requestStatus = "failure";
try {
operationResponse = authorise(charge, walletAuthorisationData);
if (operationResponse.getBaseResponse().isPresent()) {
requestStatus = "success";
chargeStatus = operationResponse.getBaseResponse().get().authoriseStatus().getMappedChargeStatus();
} else {
operationResponse.throwGatewayError();
}
} catch (GatewayException e) {
LOGGER.error("Error occurred authorising charge. Charge external id: {}; message: {}", charge.getExternalId(), e.getMessage());
if (e instanceof GatewayErrorException) {
LOGGER.error("Response from gateway: {}", ((GatewayErrorException) e).getResponseFromGateway());
}
chargeStatus = AuthorisationService.mapFromGatewayErrorException(e);
operationResponse = GatewayResponse.GatewayResponseBuilder.responseBuilder().withGatewayError(e.toGatewayError()).build();
}
Optional<String> transactionId = authorisationService.extractTransactionId(charge.getExternalId(), operationResponse);
Optional<ProviderSessionIdentifier> sessionIdentifier = operationResponse.getSessionIdentifier();
Optional<Auth3dsRequiredEntity> auth3dsDetailsEntity = operationResponse.getBaseResponse().flatMap(BaseAuthoriseResponse::extractAuth3dsRequiredDetails);
logMetrics(charge, operationResponse, requestStatus, walletAuthorisationData.getWalletType());
processGatewayAuthorisationResponse(charge.getExternalId(), walletAuthorisationData, transactionId.orElse(null), sessionIdentifier.orElse(null), chargeStatus, auth3dsDetailsEntity);
authorisationLogger.logChargeAuthorisation(LOGGER, charge, transactionId.orElse("missing transaction ID"), operationResponse, charge.getChargeStatus(), chargeStatus);
return operationResponse;
});
}
Aggregations