Search in sources :

Example 1 with GatewayAccountCredentials

use of uk.gov.pay.connector.gatewayaccount.model.GatewayAccountCredentials in project pay-connector by alphagov.

the class GatewayAccountCredentialsService method updateGatewayAccountCredentials.

@Transactional
public GatewayAccountCredentials updateGatewayAccountCredentials(GatewayAccountCredentialsEntity gatewayAccountCredentialsEntity, Iterable<JsonPatchRequest> updateRequests) {
    for (JsonPatchRequest updateRequest : updateRequests) {
        if (JsonPatchOp.REPLACE == updateRequest.getOp()) {
            updateGatewayAccountCredentialField(updateRequest, gatewayAccountCredentialsEntity);
        }
    }
    gatewayAccountCredentialsDao.merge(gatewayAccountCredentialsEntity);
    GatewayAccountEntity gatewayAccountEntity = gatewayAccountCredentialsEntity.getGatewayAccountEntity();
    LOGGER.info("Updated credentials for gateway account [id={}]", gatewayAccountEntity.getId(), kv(GATEWAY_ACCOUNT_ID, gatewayAccountEntity.getId()), kv(GATEWAY_ACCOUNT_TYPE, gatewayAccountEntity.getType()), kv(PROVIDER, gatewayAccountCredentialsEntity.getPaymentProvider()), kv("state", gatewayAccountCredentialsEntity.getState()), kv(USER_EXTERNAL_ID, gatewayAccountCredentialsEntity.getLastUpdatedByUserExternalId()));
    return new GatewayAccountCredentials(gatewayAccountCredentialsEntity);
}
Also used : JsonPatchRequest(uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest) GatewayAccountEntity(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity) GatewayAccountCredentials(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountCredentials) Transactional(com.google.inject.persist.Transactional)

Example 2 with GatewayAccountCredentials

use of uk.gov.pay.connector.gatewayaccount.model.GatewayAccountCredentials 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)2 GatewayAccountCredentials (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountCredentials)2 GatewayAccountEntity (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity)1 GatewayAccountCredentialState (uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialState)1 GatewayAccountCredentialsEntity (uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntity)1 JsonPatchRequest (uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest)1