use of uk.gov.pay.adminusers.exception.ServiceNotFoundException in project pay-adminusers by alphagov.
the class StripeAgreementService method doCreate.
public void doCreate(String serviceExternalId, InetAddress ipAddress) {
ServiceEntity serviceEntity = serviceDao.findByExternalId(serviceExternalId).orElseThrow(() -> new ServiceNotFoundException(serviceExternalId));
if (stripeAgreementDao.findByServiceExternalId(serviceExternalId).isPresent()) {
throw new StripeAgreementExistsException();
}
logger.info(format("Creating stripe agreement for service %s", serviceExternalId));
ZonedDateTime agreementTime = ZonedDateTime.now(ZoneId.of("UTC"));
stripeAgreementDao.persist(new StripeAgreementEntity(serviceEntity, ipAddress.getHostAddress(), agreementTime));
}
Aggregations