Search in sources :

Example 31 with OrderPayment

use of org.broadleafcommerce.core.payment.domain.OrderPayment in project BroadleafCommerce by BroadleafCommerce.

the class CartStateServiceImpl method cartHasTemporaryCreditCard.

@Override
public boolean cartHasTemporaryCreditCard() {
    Order cart = CartState.getCart();
    List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart);
    for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) {
        boolean isCreditCartPayment = PaymentType.CREDIT_CARD.equals(payment.getType());
        boolean isTemporaryPaymentGateway = PaymentGatewayType.TEMPORARY.equals(payment.getGatewayType());
        if (payment.isActive() && isCreditCartPayment && isTemporaryPaymentGateway) {
            return true;
        }
    }
    return false;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment)

Example 32 with OrderPayment

use of org.broadleafcommerce.core.payment.domain.OrderPayment in project BroadleafCommerce by BroadleafCommerce.

the class CartStateServiceImpl method cartHasCreditCardPaymentWithSameToken.

@Override
public boolean cartHasCreditCardPaymentWithSameToken(String paymentToken) {
    Order cart = CartState.getCart();
    List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart);
    for (OrderPayment orderPayment : orderPayments) {
        if (orderPayment.isActive() && PaymentType.CREDIT_CARD.equals(orderPayment.getType())) {
            List<PaymentTransaction> transactions = orderPayment.getTransactions();
            for (PaymentTransaction transaction : transactions) {
                String orderPaymentToken = transaction.getAdditionalFields().get(PaymentAdditionalFieldType.TOKEN.getType());
                if (ObjectUtils.equals(orderPaymentToken, paymentToken)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) PaymentTransaction(org.broadleafcommerce.core.payment.domain.PaymentTransaction) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment)

Example 33 with OrderPayment

use of org.broadleafcommerce.core.payment.domain.OrderPayment in project BroadleafCommerce by BroadleafCommerce.

the class PaymentMethodVariableExpression method orderContainsPaymentOfType.

protected boolean orderContainsPaymentOfType(Order order, PaymentType paymentType) {
    List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(order);
    for (OrderPayment payment : orderPayments) {
        boolean isActive = payment.isActive();
        boolean isOfCorrectType = paymentType.equals(payment.getType());
        if (isActive && isOfCorrectType) {
            return true;
        }
    }
    return false;
}
Also used : OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment)

Aggregations

OrderPayment (org.broadleafcommerce.core.payment.domain.OrderPayment)33 Order (org.broadleafcommerce.core.order.domain.Order)16 PaymentTransaction (org.broadleafcommerce.core.payment.domain.PaymentTransaction)11 Money (org.broadleafcommerce.common.money.Money)7 ArrayList (java.util.ArrayList)6 Transactional (org.springframework.transaction.annotation.Transactional)6 PaymentResponseDTO (org.broadleafcommerce.common.payment.dto.PaymentResponseDTO)5 Address (org.broadleafcommerce.profile.core.domain.Address)5 HashMap (java.util.HashMap)4 CheckoutException (org.broadleafcommerce.core.checkout.service.exception.CheckoutException)3 Customer (org.broadleafcommerce.profile.core.domain.Customer)3 Test (org.testng.annotations.Test)3 PaymentGatewayType (org.broadleafcommerce.common.payment.PaymentGatewayType)2 PaymentRequestDTO (org.broadleafcommerce.common.payment.dto.PaymentRequestDTO)2 PaymentGatewayConfigurationService (org.broadleafcommerce.common.payment.service.PaymentGatewayConfigurationService)2 AdminPresentationMergeOverride (org.broadleafcommerce.common.presentation.override.AdminPresentationMergeOverride)2 OrderPaymentImpl (org.broadleafcommerce.core.payment.domain.OrderPaymentImpl)2 WorkflowException (org.broadleafcommerce.core.workflow.WorkflowException)2 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)2 Collection (java.util.Collection)1