use of io.lumeer.api.model.Payment in project engine by Lumeer.
the class PaymentFacade method createPayment.
public Payment createPayment(final Organization organization, final Payment payment, final String notifyUrl, final String returnUrl) {
checkManagePermissions(organization);
final Payment establishedPayment = paymentGateway.createPayment(payment, returnUrl, notifyUrl);
return paymentDao.createPayment(organization, establishedPayment);
}
use of io.lumeer.api.model.Payment in project engine by Lumeer.
the class PaymentFacade method getCurrentServiceLimits.
public ServiceLimits getCurrentServiceLimits(final Organization organization) {
checkReadPermissions(organization);
final Payment payment = getCurrentPayment(organization);
if (payment != null) {
workspaceKeeper.setServiceLevel(organization, payment.getServiceLevel());
if (payment.getServiceLevel() == Payment.ServiceLevel.BASIC) {
return new ServiceLimits(Payment.ServiceLevel.BASIC, Math.min(ServiceLimits.BASIC_LIMITS.getUsers(), payment.getUsers()), ServiceLimits.BASIC_LIMITS.getProjects(), ServiceLimits.BASIC_LIMITS.getFiles(), ServiceLimits.BASIC_LIMITS.getDocuments(), ServiceLimits.BASIC_LIMITS.getDbSizeMb(), payment.getValidUntil());
}
}
return ServiceLimits.FREE_LIMITS;
}
use of io.lumeer.api.model.Payment in project engine by Lumeer.
the class PaymentFacade method getCurrentPayment.
private Payment getCurrentPayment(final Organization organization) {
if (currentPayment == null) {
final Date now = new Date();
final Payment latestPayment = getPaymentAt(organization, now);
// is the payment active? be tolerant to dates/time around the interval border
if (latestPayment != null) {
currentPayment = latestPayment;
}
}
return currentPayment;
}
use of io.lumeer.api.model.Payment in project engine by Lumeer.
the class PaymentFacade method updatePayment.
public Payment updatePayment(final Organization organization, final String paymentId) {
checkManagePermissions(organization);
currentPayment = null;
workspaceKeeper.clearServiceLevel(organization);
final Payment payment = paymentDao.getPayment(organization, paymentId);
payment.setState(paymentGateway.getPaymentStatus(paymentId));
return paymentDao.updatePayment(organization, payment);
}
use of io.lumeer.api.model.Payment in project engine by Lumeer.
the class PaymentFacade method getCurrentServiceLevel.
public Payment.ServiceLevel getCurrentServiceLevel(final Organization organization) {
checkReadPermissions(organization);
Payment.ServiceLevel serviceLevel = Payment.ServiceLevel.FREE;
if (workspaceKeeper.getServiceLevel(organization) == null) {
final Payment payment = getCurrentPayment(organization);
if (payment != null) {
serviceLevel = payment.getServiceLevel();
}
workspaceKeeper.setServiceLevel(organization, serviceLevel);
} else {
serviceLevel = workspaceKeeper.getServiceLevel(organization);
}
return serviceLevel;
}
Aggregations