From: eileenmcnaugton Date: Thu, 17 Dec 2015 23:59:54 +0000 (+1300) Subject: CRM-17728 enotices on payment processor form X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b7e7f9434ecf39b2a86d36c47667703ba257a671;p=civicrm-core.git CRM-17728 enotices on payment processor form --- diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index 2884833fb1..c14991c9f8 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -200,6 +200,14 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { array('' => ts('- select -')) + $financialAccount, TRUE ); + $this->addSelect('payment_instrument_id', + array( + 'entity' => 'contribution', + 'label' => ts('Payment Method'), + 'placeholder' => NULL, + ) + ); + // is this processor active ? $this->add('checkbox', 'is_active', ts('Is this Payment Processor active?')); $this->add('checkbox', 'is_default', ts('Is this Payment Processor the default?')); @@ -298,6 +306,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $defaults['test_url_api'] = $this->_ppDAO->url_api_test_default; $defaults['test_url_recur'] = $this->_ppDAO->url_recur_test_default; $defaults['test_url_button'] = $this->_ppDAO->url_button_test_default; + $defaults['payment_instrument_id'] = $this->_ppDAO->payment_instrument_id; // When user changes payment processor type, it is passed in via $this->_ppType so update defaults array. if ($this->_ppType) { $defaults['payment_processor_type_id'] = $this->_ppType; @@ -341,7 +350,6 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { * Process the form submission. */ public function postProcess() { - CRM_Utils_System::flushCache('CRM_Financial_DAO_PaymentProcessor'); if ($this->_action & CRM_Core_Action::DELETE) { CRM_Financial_BAO_PaymentProcessor::del($this->_id); @@ -370,46 +378,21 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { * @param bool $test */ public function updatePaymentProcessor(&$values, $domainID, $test) { - // @todo remove this function (some or all) in favour or CRM_Financial_BAO_PaymentProcessor::create. - $dao = new CRM_Financial_DAO_PaymentProcessor(); - - $dao->id = $test ? $this->_testID : $this->_id; - $dao->domain_id = $domainID; - $dao->is_test = $test; - $dao->is_default = CRM_Utils_Array::value('is_default', $values, 0); - - $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0); - - $dao->name = $values['name']; - $dao->description = $values['description']; - $dao->payment_processor_type_id = $values['payment_processor_type_id']; - - foreach ($this->_fields as $field) { - $fieldName = $test ? "test_{$field['name']}" : $field['name']; - $dao->{$field['name']} = trim(CRM_Utils_Array::value($fieldName, $values)); - if (empty($dao->{$field['name']})) { - $dao->{$field['name']} = 'null'; - } - } - - // also copy meta fields from the info DAO - $dao->is_recur = $this->_ppDAO->is_recur; - $dao->billing_mode = $this->_ppDAO->billing_mode; - $dao->class_name = $this->_ppDAO->class_name; - $dao->payment_type = $this->_ppDAO->payment_type; - - $dao->save(); - - //CRM-11515 - - $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); - $params = array( - 'entity_table' => 'civicrm_payment_processor', - 'entity_id' => $dao->id, - 'account_relationship' => $relationTypeId, + $params = array_merge(array( + 'id' => $test ? $this->_testID : $this->_id, + 'domain_id' => $domainID, + 'is_test' => $test, + 'is_active' => 0, + 'is_default' => 0, + 'is_recur' => $this->_ppDAO->is_recur, + 'billing_mode' => $this->_ppDAO->billing_mode, + 'class_name' => $this->_ppDAO->class_name, + 'payment_type' => $this->_ppDAO->payment_type, + 'payment_instrument_id' => $this->_ppDAO->payment_instrument_id, 'financial_account_id' => $values['financial_account_id'], - ); - CRM_Financial_BAO_FinancialTypeAccount::add($params); + ), $values); + + civicrm_api3('PaymentProcessor', 'create', $params); } } diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index db6a77f1e9..77bbeaf93b 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -1200,8 +1200,7 @@ abstract class CRM_Core_Payment { break; } - $session = CRM_Core_Session::singleton(); - $userId = $session->get('userID'); + $userId = CRM_Core_Session::singleton()->get('userID'); $contactID = 0; $checksumValue = ''; $entityArg = ''; diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 5ff3237b17..cc5c804421 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -50,7 +50,6 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * @throws Exception */ public static function create($params) { - // FIXME Reconcile with CRM_Admin_Form_PaymentProcessor::updatePaymentProcessor $processor = new CRM_Financial_DAO_PaymentProcessor(); $processor->copyValues($params); @@ -79,6 +78,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces ); CRM_Financial_BAO_FinancialTypeAccount::add($values); } + Civi\Payment\System::singleton()->flushProcessors(); return $processor; } diff --git a/templates/CRM/Admin/Form/PaymentProcessor.tpl b/templates/CRM/Admin/Form/PaymentProcessor.tpl index a4a3fb14bb..98822b18c9 100644 --- a/templates/CRM/Admin/Form/PaymentProcessor.tpl +++ b/templates/CRM/Admin/Form/PaymentProcessor.tpl @@ -56,6 +56,9 @@ {/if} + + {$form.payment_instrument_id.label}{$form.payment_instrument_id.html} + {$form.is_active.html} {$form.is_active.label}