Search in sources :

Example 1 with GatewayAccountCredentialState

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);
}
Also used : GatewayAccountCredentialState(uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialState) GatewayAccountCredentials(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountCredentials) GatewayAccountCredentialsEntity(uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntity) Transactional(com.google.inject.persist.Transactional)

Aggregations

Transactional (com.google.inject.persist.Transactional)1 GatewayAccountCredentials (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountCredentials)1 GatewayAccountCredentialState (uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialState)1 GatewayAccountCredentialsEntity (uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntity)1