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);
}
}
}
}
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations