Search in sources :

Example 1 with Payment

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);
}
Also used : Payment(io.lumeer.api.model.Payment)

Example 2 with Payment

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;
}
Also used : Payment(io.lumeer.api.model.Payment) ServiceLimits(io.lumeer.api.model.ServiceLimits)

Example 3 with Payment

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;
}
Also used : Payment(io.lumeer.api.model.Payment) Date(java.util.Date)

Example 4 with Payment

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);
}
Also used : Payment(io.lumeer.api.model.Payment)

Example 5 with 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;
}
Also used : Payment(io.lumeer.api.model.Payment)

Aggregations

Payment (io.lumeer.api.model.Payment)9 Date (java.util.Date)4 ServiceLimits (io.lumeer.api.model.ServiceLimits)3 Test (org.junit.Test)1