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(); }
public String removeCustomerPayment(HttpServletRequest request, Model model, Long customerPaymentId) { customerPaymentService.deleteCustomerPaymentById(customerPaymentId); return getCustomerPaymentView(); }
@Override public void deleteCustomerPaymentFromResponseDTO(PaymentResponseDTO responseDTO, PaymentGatewayConfiguration config) throws IllegalArgumentException { validateResponseAndConfig(responseDTO, config); String paymentToken = responseDTO.getPaymentToken(); customerPaymentService.deleteCustomerPaymentByToken(paymentToken); }
@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; }
protected void copyCustomerPaymentAddressToBillingAddress(PaymentInfoForm paymentForm) { CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(paymentForm.getCustomerPaymentId()); if (customerPayment != null) { Address address = customerPayment.getBillingAddress(); if (address != null) { paymentForm.setAddress(addressService.copyAddress(address)); } } }
@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; }
public List<CustomerPayment> getCustomerPayments() { Customer customer = CustomerState.getCustomer(); List<CustomerPayment> customerPayments = new ArrayList<>(); if (savedPaymentsAreEnabled()) { customerPayments = customerPaymentService.readCustomerPaymentsByCustomerId(customer.getId()); sortCustomerPaymentsByDefault(customerPayments); } return customerPayments; }
@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); }
@Override public DynamicResultSet fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException { OperationType fetchType = persistencePackage.getPersistencePerspective().getOperationTypes().getFetchType(); PersistenceModule persistenceModule = helper.getCompatibleModule(fetchType); DynamicResultSet drs = persistenceModule.fetch(persistencePackage, cto); for (Entity entity : drs.getRecords()) { Property customerPaymentId = entity.findProperty("id"); if (customerPaymentId != null) { CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(Long.parseLong(customerPaymentId.getValue())); if (customerPayment != null) { String savedPaymentDisplayValue = buildSavedPaymentDisplayValue(customerPayment); Property derivedLabel = new Property(); derivedLabel.setName(SAVED_PAYMENT_INFO); derivedLabel.setValue(savedPaymentDisplayValue); entity.addProperty(derivedLabel); } } } return drs; }
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; }
CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(paymentForm.getCustomerPaymentId());
customerPayment = customerPaymentService.readCustomerPaymentById(billingForm.getCustomerPaymentId());