Search in sources :

Example 26 with OrderPayment

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

the class BroadleafShippingInfoController method copyBillingAddressToShippingAddress.

/**
 * This method will copy the billing address of any CREDIT CARD order payment on the order
 * to the shipping address on the ShippingInfoForm that is passed in.
 */
protected void copyBillingAddressToShippingAddress(Order order, ShippingInfoForm shippingInfoForm) {
    if (order.getPayments() != null) {
        for (OrderPayment payment : order.getPayments()) {
            if (payment.isActive() && PaymentType.CREDIT_CARD.equals(payment.getType())) {
                Address billing = payment.getBillingAddress();
                if (billing != null) {
                    Address shipping = addressService.copyAddress(billing);
                    shippingInfoForm.setAddress(shipping);
                }
            }
        }
    }
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment)

Example 27 with OrderPayment

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

the class CheckoutFormServiceImpl method getAddressFromCCOrderPayment.

protected Address getAddressFromCCOrderPayment(Order cart) {
    List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart);
    for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) {
        boolean isCreditCardPaymentType = PaymentType.CREDIT_CARD.equals(payment.getType());
        boolean paymentHasBillingAddress = (payment.getBillingAddress() != null);
        if (payment.isActive() && isCreditCardPaymentType && paymentHasBillingAddress) {
            return payment.getBillingAddress();
        }
    }
    return null;
}
Also used : OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment)

Example 28 with OrderPayment

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

the class OrderServiceImpl method removePaymentFromOrder.

@Override
@Transactional("blTransactionManager")
public void removePaymentFromOrder(Order order, OrderPayment payment) {
    OrderPayment paymentToRemove = null;
    for (OrderPayment info : order.getPayments()) {
        if (info.equals(payment)) {
            paymentToRemove = info;
        }
    }
    if (paymentToRemove != null) {
        try {
            securePaymentInfoService.findAndRemoveSecurePaymentInfo(paymentToRemove.getReferenceNumber(), payment.getType());
        } catch (WorkflowException e) {
            // do nothing--this is an acceptable condition
            LOG.debug("No secure payment is associated with the OrderPayment", e);
        }
        order.getPayments().remove(paymentToRemove);
        payment = paymentDao.readPaymentById(paymentToRemove.getId());
        paymentDao.delete(payment);
    }
}
Also used : WorkflowException(org.broadleafcommerce.core.workflow.WorkflowException) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment) Transactional(org.springframework.transaction.annotation.Transactional)

Example 29 with OrderPayment

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

the class OrderServiceImpl method removePaymentsFromOrder.

@Override
@Transactional("blTransactionManager")
public void removePaymentsFromOrder(Order order, PaymentType paymentInfoType) {
    List<OrderPayment> infos = new ArrayList<OrderPayment>();
    for (OrderPayment paymentInfo : order.getPayments()) {
        if (paymentInfoType == null || paymentInfoType.equals(paymentInfo.getType())) {
            infos.add(paymentInfo);
        }
    }
    order.getPayments().removeAll(infos);
    for (OrderPayment paymentInfo : infos) {
        try {
            securePaymentInfoService.findAndRemoveSecurePaymentInfo(paymentInfo.getReferenceNumber(), paymentInfo.getType());
        } catch (WorkflowException e) {
            // do nothing--this is an acceptable condition
            LOG.debug("No secure payment is associated with the OrderPayment", e);
        }
        order.getPayments().remove(paymentInfo);
        paymentInfo = paymentDao.readPaymentById(paymentInfo.getId());
        paymentDao.delete(paymentInfo);
    }
}
Also used : WorkflowException(org.broadleafcommerce.core.workflow.WorkflowException) ArrayList(java.util.ArrayList) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with OrderPayment

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

the class CartStateServiceImpl method cartHasThirdPartyPayment.

@Override
public boolean cartHasThirdPartyPayment() {
    Order cart = CartState.getCart();
    List<OrderPayment> orderPayments = orderPaymentService.readPaymentsForOrder(cart);
    for (OrderPayment payment : CollectionUtils.emptyIfNull(orderPayments)) {
        if (payment.isActive() && PaymentType.THIRD_PARTY_ACCOUNT.equals(payment.getType())) {
            return true;
        }
    }
    return false;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) 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