Search in sources :

Example 1 with PaypalAccessMethod

use of org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod in project OpenOLAT by OpenOLAT.

the class PaypalManagerImpl method getMethodSecure.

private PaypalAccessMethod getMethodSecure(Long key) {
    PaypalAccessMethod smethod = null;
    List<PaypalAccessMethod> methods = getPaypalMethods();
    if (methods.size() > 0) {
        smethod = methods.get(0);
    } else {
        smethod = new PaypalAccessMethod();
        smethod.setCreationDate(new Date());
        smethod.setLastModified(smethod.getCreationDate());
        save(smethod);
    }
    for (PaypalAccessMethod method : methods) {
        if (key != null && key.equals(method.getKey())) {
            smethod = method;
        }
    }
    return smethod;
}
Also used : PaypalAccessMethod(org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod) Date(java.util.Date)

Example 2 with PaypalAccessMethod

use of org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod in project OpenOLAT by OpenOLAT.

the class PaypalManagerImpl method completeTransactionSucessfully.

private void completeTransactionSucessfully(PaypalTransaction trx, String trxStatus) {
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    if ("PENDING".equalsIgnoreCase(trxStatus)) {
        updateTransaction(trx, PaypalTransactionStatus.PENDING);
    } else {
        updateTransaction(trx, PaypalTransactionStatus.SUCCESS);
    }
    order = orderManager.save(order, OrderStatus.PAYED);
    PaypalAccessMethod method = getMethodSecure(trx.getMethodId());
    if (order.getKey().equals(trx.getOrderId())) {
        // make accessible
        Identity identity = order.getDelivery();
        for (OrderPart part : order.getParts()) {
            if (part.getKey().equals(trx.getOrderPartId())) {
                AccessTransaction transaction = transactionManager.createTransaction(order, part, method);
                transaction = transactionManager.save(transaction);
                for (OrderLine line : part.getOrderLines()) {
                    if (acService.allowAccesToResource(identity, line.getOffer())) {
                        log.audit("Paypal payed access granted for: " + buildLogMessage(line, method) + " to " + identity, null);
                        transaction = transactionManager.update(transaction, AccessTransactionStatus.SUCCESS);
                    } else {
                        log.error("Paypal payed access refused for: " + buildLogMessage(line, method) + " to " + identity, null);
                        transaction = transactionManager.update(transaction, AccessTransactionStatus.ERROR);
                    }
                }
            }
        }
    } else {
        log.error("Order not in sync with PaypalTransaction", null);
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) OrderPart(org.olat.resource.accesscontrol.OrderPart) Identity(org.olat.core.id.Identity) PaypalAccessMethod(org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)

Example 3 with PaypalAccessMethod

use of org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod in project openolat by klemens.

the class PaypalManagerImpl method completeDeniedTransaction.

private void completeDeniedTransaction(PaypalTransaction trx) {
    updateTransaction(trx, PaypalTransactionStatus.DENIED);
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    order = orderManager.save(order, OrderStatus.ERROR);
    PaypalAccessMethod method = getMethodSecure(trx.getMethodId());
    if (order.getKey().equals(trx.getOrderId())) {
        // make accessible
        Identity identity = order.getDelivery();
        for (OrderPart part : order.getParts()) {
            if (part.getKey().equals(trx.getOrderPartId())) {
                AccessTransaction transaction = transactionManager.createTransaction(order, part, method);
                transaction = transactionManager.update(transaction, AccessTransactionStatus.ERROR);
                for (OrderLine line : part.getOrderLines()) {
                    acService.denyAccesToResource(identity, line.getOffer());
                    log.audit("Paypal payed access revoked for: " + buildLogMessage(line, method) + " to " + identity, null);
                    ResourceReservation reservation = reservationDao.loadReservation(identity, line.getOffer().getResource());
                    if (reservation != null) {
                        acService.removeReservation(identity, identity, reservation);
                        log.audit("Remove reservation after cancellation for: " + reservation + " to " + identity, null);
                    }
                }
            }
        }
    } else {
        log.error("Order not in sync with PaypalTransaction", null);
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) OrderPart(org.olat.resource.accesscontrol.OrderPart) Identity(org.olat.core.id.Identity) PaypalAccessMethod(org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)

Example 4 with PaypalAccessMethod

use of org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod in project openolat by klemens.

the class PaypalManagerImpl method completeTransactionSucessfully.

private void completeTransactionSucessfully(PaypalTransaction trx, String trxStatus) {
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    if ("PENDING".equalsIgnoreCase(trxStatus)) {
        updateTransaction(trx, PaypalTransactionStatus.PENDING);
    } else {
        updateTransaction(trx, PaypalTransactionStatus.SUCCESS);
    }
    order = orderManager.save(order, OrderStatus.PAYED);
    PaypalAccessMethod method = getMethodSecure(trx.getMethodId());
    if (order.getKey().equals(trx.getOrderId())) {
        // make accessible
        Identity identity = order.getDelivery();
        for (OrderPart part : order.getParts()) {
            if (part.getKey().equals(trx.getOrderPartId())) {
                AccessTransaction transaction = transactionManager.createTransaction(order, part, method);
                transaction = transactionManager.save(transaction);
                for (OrderLine line : part.getOrderLines()) {
                    if (acService.allowAccesToResource(identity, line.getOffer())) {
                        log.audit("Paypal payed access granted for: " + buildLogMessage(line, method) + " to " + identity, null);
                        transaction = transactionManager.update(transaction, AccessTransactionStatus.SUCCESS);
                    } else {
                        log.error("Paypal payed access refused for: " + buildLogMessage(line, method) + " to " + identity, null);
                        transaction = transactionManager.update(transaction, AccessTransactionStatus.ERROR);
                    }
                }
            }
        }
    } else {
        log.error("Order not in sync with PaypalTransaction", null);
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) OrderPart(org.olat.resource.accesscontrol.OrderPart) Identity(org.olat.core.id.Identity) PaypalAccessMethod(org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)

Example 5 with PaypalAccessMethod

use of org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod in project OpenOLAT by OpenOLAT.

the class PaypalManagerImpl method completeDeniedTransaction.

private void completeDeniedTransaction(PaypalTransaction trx) {
    updateTransaction(trx, PaypalTransactionStatus.DENIED);
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    order = orderManager.save(order, OrderStatus.ERROR);
    PaypalAccessMethod method = getMethodSecure(trx.getMethodId());
    if (order.getKey().equals(trx.getOrderId())) {
        // make accessible
        Identity identity = order.getDelivery();
        for (OrderPart part : order.getParts()) {
            if (part.getKey().equals(trx.getOrderPartId())) {
                AccessTransaction transaction = transactionManager.createTransaction(order, part, method);
                transaction = transactionManager.update(transaction, AccessTransactionStatus.ERROR);
                for (OrderLine line : part.getOrderLines()) {
                    acService.denyAccesToResource(identity, line.getOffer());
                    log.audit("Paypal payed access revoked for: " + buildLogMessage(line, method) + " to " + identity, null);
                    ResourceReservation reservation = reservationDao.loadReservation(identity, line.getOffer().getResource());
                    if (reservation != null) {
                        acService.removeReservation(identity, identity, reservation);
                        log.audit("Remove reservation after cancellation for: " + reservation + " to " + identity, null);
                    }
                }
            }
        }
    } else {
        log.error("Order not in sync with PaypalTransaction", null);
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) OrderLine(org.olat.resource.accesscontrol.OrderLine) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) OrderPart(org.olat.resource.accesscontrol.OrderPart) Identity(org.olat.core.id.Identity) PaypalAccessMethod(org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)

Aggregations

PaypalAccessMethod (org.olat.resource.accesscontrol.provider.paypal.model.PaypalAccessMethod)6 Identity (org.olat.core.id.Identity)4 AccessTransaction (org.olat.resource.accesscontrol.AccessTransaction)4 Order (org.olat.resource.accesscontrol.Order)4 OrderLine (org.olat.resource.accesscontrol.OrderLine)4 OrderPart (org.olat.resource.accesscontrol.OrderPart)4 Date (java.util.Date)2 ResourceReservation (org.olat.resource.accesscontrol.ResourceReservation)2