Search in sources :

Example 6 with Payment

use of io.lumeer.api.model.Payment in project engine by Lumeer.

the class PaymentCodec method convertFromDocument.

public static Payment convertFromDocument(Document bson) {
    String id = bson.get(ID) != null ? bson.getObjectId(ID).toHexString() : null;
    Date date = bson.getDate(Payment.DATE);
    long amount = bson.getLong(Payment.AMOUNT);
    String paymentId = bson.getString(Payment.PAYMENT_ID);
    Date start = bson.getDate(Payment.START);
    Date validUntil = bson.getDate(Payment.VALID_UNTIL);
    Payment.PaymentState state = Payment.PaymentState.fromInt(bson.getInteger(Payment.STATE));
    Payment.ServiceLevel serviceLevel = Payment.ServiceLevel.fromInt(bson.getInteger(Payment.SERVICE_LEVEL));
    int users = bson.getInteger(Payment.USERS);
    String language = bson.getString(Payment.LANGUAGE);
    String currency = bson.getString(Payment.CURRENCY);
    String gwUrl = bson.getString(Payment.GW_URL);
    return new Payment(id, date, amount, paymentId, start, validUntil, state, serviceLevel, users, language, currency, gwUrl);
}
Also used : Payment(io.lumeer.api.model.Payment) Date(java.util.Date)

Example 7 with Payment

use of io.lumeer.api.model.Payment in project engine by Lumeer.

the class PaymentFacadeIT method createPayment.

private String createPayment(final String from, final String until, final boolean paid) {
    Payment payment = new Payment(null, new Date(), 1770, "", getDate(from), getDate(until), Payment.PaymentState.CREATED, Payment.ServiceLevel.BASIC, 10, "cz", "CZK", null);
    final String paymentId = paymentFacade.createPayment(organization, payment, "", "").getPaymentId();
    if (paid) {
        // this switches it to PAID in dry run mode
        paymentFacade.updatePayment(organization, paymentId);
    }
    return paymentId;
}
Also used : Payment(io.lumeer.api.model.Payment) Date(java.util.Date)

Example 8 with Payment

use of io.lumeer.api.model.Payment in project engine by Lumeer.

the class PaymentFacade method getServiceLimitsAt.

public ServiceLimits getServiceLimitsAt(final Organization organization, final Date date) {
    checkManagePermissions(organization);
    final Payment payment = getPaymentAt(organization, date);
    if (payment != null) {
        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 9 with Payment

use of io.lumeer.api.model.Payment in project engine by Lumeer.

the class OrganizationServiceIT method testPaymentsAssessments.

@Test
public void testPaymentsAssessments() {
    paymentGatewayFacade.setDryRun(true);
    createOrganization(CODE1);
    createOrganization(CODE2);
    Payment payment = new Payment(null, new Date(), 1770, "1234", Date.from(ZonedDateTime.ofLocal(LocalDateTime.of(2018, 4, 1, 12, 0), ZoneId.systemDefault(), null).toInstant()), Date.from(ZonedDateTime.ofLocal(LocalDateTime.of(2019, 4, 1, 12, 0), ZoneId.systemDefault(), null).toInstant()), Payment.PaymentState.CREATED, Payment.ServiceLevel.BASIC, 10, "cz", "CZK", "");
    payment = createPayment(CODE1, payment);
    ServiceLimits serviceLimits = getServiceLimits(CODE1);
    assertThat(serviceLimits.getServiceLevel()).isEqualTo(Payment.ServiceLevel.FREE);
// todo call updateService once we know the message format
}
Also used : Payment(io.lumeer.api.model.Payment) ServiceLimits(io.lumeer.api.model.ServiceLimits) Date(java.util.Date) Test(org.junit.Test)

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