@Override public <G extends CustomerPayment> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException { CreateResponse<G> createResponse = context.createOrRetrieveCopyInstance(this); if (createResponse.isAlreadyPopulated()) { return createResponse; } CustomerPayment cloned = createResponse.getClone(); // dont clone cloned.setCustomer(customer); cloned.setBillingAddress(billingAddress.createOrRetrieveCopyInstance(context).getClone()); cloned.setIsDefault(isDefault); cloned.setPaymentToken(paymentToken); for (Map.Entry<String, String> entry : additionalFields.entrySet()) { cloned.getAdditionalFields().put(entry.getKey(), entry.getValue()); } return createResponse; }
@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); }
Address billingAddress = addressService.create(); dtoToEntityService.populateAddressInfo(responseDTO.getBillTo(), billingAddress); customerPayment.setBillingAddress(billingAddress);