static function create($params) { // FIXME Reconcile with CRM_Admin_Form_PaymentProcessor::updatePaymentProcessor $processor = new CRM_Financial_DAO_PaymentProcessor(); $processor->copyValues($params); $ppTypeDAO = new CRM_Financial_DAO_PaymentProcessorType(); $ppTypeDAO->id = $params['payment_processor_type_id']; if (!$ppTypeDAO->find(TRUE)) { CRM_Core_Error::fatal(ts('Could not find payment processor meta information')); } // also copy meta fields from the info DAO $processor->is_recur = $ppTypeDAO->is_recur; $processor->billing_mode = $ppTypeDAO->billing_mode; $processor->class_name = $ppTypeDAO->class_name; $processor->payment_type = $ppTypeDAO->payment_type; $processor->save(); // CRM-11826, add entry in civicrm_entity_financial_account // if financial_account_id is not NULL if (CRM_Utils_Array::value('financial_account_id', $params)) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); $values = array('entity_table' => 'civicrm_payment_processor', 'entity_id' => $processor->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id']); CRM_Financial_BAO_FinancialTypeAccount::add($values); } return $processor; }
/** * @param $attr * * @return array */ private static function getAllPaymentProcessorTypes($attr) { $ppt = array(); $dao = new CRM_Financial_DAO_PaymentProcessorType(); $dao->find(); while ($dao->fetch()) { $ppt[$dao->{$attr}] = $dao->id; } return $ppt; }
/** * Process the form submission. */ public function postProcess() { CRM_Utils_System::flushCache('CRM_Financial_DAO_PaymentProcessorType'); if ($this->_action & CRM_Core_Action::DELETE) { CRM_Financial_BAO_PaymentProcessorType::del($this->_id); return; } $values = $this->controller->exportValues($this->_name); if (!empty($values['is_default'])) { $query = "\nUPDATE civicrm_payment_processor SET is_default = 0"; CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); } $dao = new CRM_Financial_DAO_PaymentProcessorType(); $dao->id = $this->_id; $dao->is_default = CRM_Utils_Array::value('is_default', $values, 0); $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0); $dao->is_recur = CRM_Utils_Array::value('is_recur', $values, 0); $dao->name = $values['name']; $dao->description = $values['description']; foreach ($this->_fields as $field) { $dao->{$field['name']} = trim($values[$field['name']]); if (empty($dao->{$field['name']})) { $dao->{$field['name']} = 'null'; } } $dao->save(); }
/** * Returns the list of fields that can be exported * * @param bool $prefix * * @return array */ static function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields = self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['payment_processor_type'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }