private String getProcessorName(Integer userId) throws PluggableTaskException { ContactBL contactLoader; String processorName = null; contactLoader = new ContactBL(); contactLoader.set(userId); UserDTO user = new UserDAS().find(userId); if (user.getCustomer() != null && user.getCustomer().getMetaFields() != null) { String metaFieldName = parameters.get(PARAM_CUSTOM_FIELD_PAYMENT_PROCESSOR.getName()); MetaFieldValue customField = user.getCustomer().getMetaField(metaFieldName); if (customField == null) { // todo: try to search by id, may be temporary (now is applied) try { Integer metaFieldNameId = Integer.valueOf(metaFieldName); customField = user.getCustomer().getMetaField(metaFieldNameId); } catch (Exception ex) { // do nothing } } if (customField == null) { LOG.warn( "Can't find Custom Field with type " + parameters.get(PARAM_CUSTOM_FIELD_PAYMENT_PROCESSOR.getName()) + " user = " + userId); processorName = null; } else { processorName = (String) customField.getValue(); } } return processorName; }
private void addAVSFields(Integer userId, Map<String, Object> data) { try { ContactBL contact = new ContactBL(); contact.set(userId); ContactDTO entity = contact.getEntity(); data.put("city", entity.getCity()); data.put("email", entity.getEmail()); data.put("customerAccountCode", userId.toString()); data.put("phone", entity.getPhoneNumber()); data.put("state", entity.getStateProvince()); data.put("street", entity.getAddress1() + " " + entity.getAddress2()); data.put("zipCode", entity.getPostalCode()); data.put("isOrganization", Boolean.FALSE); } catch (Exception e) { log.error("Exception when trying to add the AVS fields", e); } }