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