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; }
/** * @return array */ public function setDefaultValues() { $defaults = array(); if (!$this->_id) { $defaults['is_active'] = $defaults['is_default'] = 1; $defaults['user_name_label'] = ts('User Name'); $defaults['password_label'] = ts('Password'); $defaults['signature_label'] = ts('Signature'); $defaults['subject_label'] = ts('Subject'); return $defaults; } $dao = new CRM_Financial_DAO_PaymentProcessorType(); $dao->id = $this->_id; if (!$dao->find(TRUE)) { return $defaults; } CRM_Core_DAO::storeValues($dao, $defaults); return $defaults; }
/** * @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; }