Search in sources :

Example 11 with CustomerPayment

use of org.broadleafcommerce.profile.core.domain.CustomerPayment in project BroadleafCommerce by BroadleafCommerce.

the class CustomerVariableExpression method getCustomerPayments.

public List<CustomerPayment> getCustomerPayments() {
    Customer customer = CustomerState.getCustomer();
    List<CustomerPayment> customerPayments = new ArrayList<>();
    if (savedPaymentsAreEnabled()) {
        customerPayments = customerPaymentService.readCustomerPaymentsByCustomerId(customer.getId());
        sortCustomerPaymentsByDefault(customerPayments);
    }
    return customerPayments;
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment) ArrayList(java.util.ArrayList)

Example 12 with CustomerPayment

use of org.broadleafcommerce.profile.core.domain.CustomerPayment in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafManageCustomerPaymentsController method makeDefaultCustomerPayment.

public String makeDefaultCustomerPayment(HttpServletRequest request, Model model, Long customerPaymentId) {
    CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(customerPaymentId);
    if (customerPayment == null) {
        throw new IllegalArgumentException("Requested customer payment does not exist.");
    }
    customerPaymentService.setAsDefaultPayment(customerPayment);
    return getCustomerPaymentView();
}
Also used : CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Example 13 with CustomerPayment

use of org.broadleafcommerce.profile.core.domain.CustomerPayment in project BroadleafCommerce by BroadleafCommerce.

the class CheckoutFormServiceImpl method prePopulatePaymentInfoForm.

@Override
public PaymentInfoForm prePopulatePaymentInfoForm(PaymentInfoForm paymentInfoForm, ShippingInfoForm shippingInfoForm, Order cart) {
    Customer customer = CustomerState.getCustomer();
    String emailAddress = getKnownEmailAddress(cart, customer);
    paymentInfoForm.setEmailAddress(emailAddress);
    Address billingAddress = getBillingAddress(cart);
    if (billingAddress != null) {
        paymentInfoForm.setAddress(billingAddress);
    }
    CustomerPayment customerPaymentUsedForOrder = getCustomerPaymentUsedForOrder();
    Long customerPaymentId = (customerPaymentUsedForOrder == null) ? null : customerPaymentUsedForOrder.getId();
    paymentInfoForm.setCustomerPaymentId(customerPaymentId);
    boolean shouldUseCustomerPaymentDefaultValue = getShouldUseCustomerPaymentDefaultValue(customerPaymentUsedForOrder);
    paymentInfoForm.setShouldUseCustomerPayment(shouldUseCustomerPaymentDefaultValue);
    boolean shouldUseShippingAddressDefaultValue = getShouldUseShippingAddressDefaultValue(customerPaymentUsedForOrder, paymentInfoForm, shippingInfoForm);
    paymentInfoForm.setShouldUseShippingAddress(shouldUseShippingAddressDefaultValue);
    boolean shouldSaveNewPaymentDefaultValue = getShouldSaveNewPaymentDefaultValue();
    paymentInfoForm.setShouldSaveNewPayment(shouldSaveNewPaymentDefaultValue);
    return paymentInfoForm;
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Aggregations

CustomerPayment (org.broadleafcommerce.profile.core.domain.CustomerPayment)13 Customer (org.broadleafcommerce.profile.core.domain.Customer)5 Transactional (org.springframework.transaction.annotation.Transactional)3 Order (org.broadleafcommerce.core.order.domain.Order)2 Address (org.broadleafcommerce.profile.core.domain.Address)2 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 Query (javax.persistence.Query)1 OperationType (org.broadleafcommerce.common.presentation.client.OperationType)1 OrderPayment (org.broadleafcommerce.core.payment.domain.OrderPayment)1 DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)1 Entity (org.broadleafcommerce.openadmin.dto.Entity)1 Property (org.broadleafcommerce.openadmin.dto.Property)1 PersistenceModule (org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule)1 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)1