Search in sources :

Example 1 with CustomerPayment

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

the class CustomerPaymentDaoImpl method readCustomerPaymentByToken.

@Override
public CustomerPayment readCustomerPaymentByToken(String token) {
    Query query = em.createNamedQuery("BC_READ_CUSTOMER_PAYMENT_BY_TOKEN");
    query.setParameter("token", token);
    CustomerPayment payment = null;
    try {
        payment = (CustomerPayment) query.getSingleResult();
    } catch (NoResultException e) {
    // do nothing
    }
    return payment;
}
Also used : Query(javax.persistence.Query) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment) NoResultException(javax.persistence.NoResultException)

Example 2 with CustomerPayment

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

the class CheckoutFormServiceImpl method getCustomerPaymentUsedForOrder.

protected CustomerPayment getCustomerPaymentUsedForOrder() {
    Customer customer = CustomerState.getCustomer();
    List<CustomerPayment> customerPayments = customerPaymentService.readCustomerPaymentsByCustomerId(customer.getId());
    for (CustomerPayment customerPayment : customerPayments) {
        if (cartStateService.cartHasCreditCardPaymentWithSameToken(customerPayment.getPaymentToken())) {
            return customerPayment;
        }
    }
    return null;
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Example 3 with CustomerPayment

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

the class DefaultCustomerPaymentGatewayService method createCustomerPaymentFromResponseDTO.

@Override
public Long createCustomerPaymentFromResponseDTO(PaymentResponseDTO responseDTO, PaymentGatewayConfiguration config) throws IllegalArgumentException {
    validateResponseAndConfig(responseDTO, config);
    Long customerId = Long.parseLong(responseDTO.getCustomer().getCustomerId());
    Customer customer = customerService.readCustomerById(customerId);
    if (customer != null) {
        if (isNewDefaultPaymentMethod(responseDTO)) {
            customerPaymentService.clearDefaultPaymentStatus(customer);
        }
        CustomerPayment customerPayment = customerPaymentService.create();
        populateCustomerPayment(customerPayment, responseDTO, config);
        customerPayment.setCustomer(customer);
        customerPayment = customerPaymentService.saveCustomerPayment(customerPayment);
        customer.getCustomerPayments().add(customerPayment);
        return customerPayment.getId();
    }
    return null;
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Example 4 with CustomerPayment

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

the class DefaultCustomerPaymentGatewayService method updateCustomerPaymentFromResponseDTO.

@Override
public Long updateCustomerPaymentFromResponseDTO(PaymentResponseDTO responseDTO, PaymentGatewayConfiguration config) throws IllegalArgumentException {
    validateResponseAndConfig(responseDTO, config);
    String paymentToken = responseDTO.getPaymentToken();
    CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentByToken(paymentToken);
    if (customerPayment != null) {
        populateCustomerPayment(customerPayment, responseDTO, config);
        customerPayment = customerPaymentService.saveCustomerPayment(customerPayment);
        return customerPayment.getId();
    }
    return null;
}
Also used : CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Example 5 with CustomerPayment

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

the class OrderPaymentServiceImpl method createCustomerPaymentFromPaymentTransaction.

@Override
@Transactional(value = TransactionUtils.DEFAULT_TRANSACTION_MANAGER)
public CustomerPayment createCustomerPaymentFromPaymentTransaction(PaymentTransaction transaction) {
    CustomerPayment customerPayment = customerPaymentService.create();
    customerPayment.setCustomer(transaction.getOrderPayment().getOrder().getCustomer());
    customerPayment.setBillingAddress(addressService.copyAddress(transaction.getOrderPayment().getBillingAddress()));
    customerPayment.setPaymentType(transaction.getOrderPayment().getType());
    customerPayment.setPaymentGatewayType(transaction.getOrderPayment().getGatewayType());
    customerPayment.setAdditionalFields(transaction.getAdditionalFields());
    populateCustomerPaymentToken(customerPayment, transaction);
    return customerPaymentService.saveCustomerPayment(customerPayment);
}
Also used : CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment) Transactional(org.springframework.transaction.annotation.Transactional)

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