use of uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialState in project pay-connector by alphagov.
the class GatewayAccountCredentialsService method createGatewayAccountCredentials.
@Transactional
public GatewayAccountCredentials createGatewayAccountCredentials(GatewayAccountEntity gatewayAccountEntity, String paymentProvider, Map<String, String> credentials) {
GatewayAccountCredentialState state = calculateStateForNewCredentials(gatewayAccountEntity, paymentProvider, credentials);
GatewayAccountCredentialsEntity gatewayAccountCredentialsEntity = new GatewayAccountCredentialsEntity(gatewayAccountEntity, paymentProvider, credentials, state);
if (state == ACTIVE) {
gatewayAccountCredentialsEntity.setActiveStartDate(Instant.now());
}
gatewayAccountCredentialsEntity.setExternalId(randomUuid());
gatewayAccountCredentialsDao.persist(gatewayAccountCredentialsEntity);
return new GatewayAccountCredentials(gatewayAccountCredentialsEntity);
}
Aggregations