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