/** * Check method del() */ public function testDel() { $params = array('name' => 'Test_Del_Payment_Processor', 'title' => 'Test Del Payment Processor', 'billing_mode' => 1, 'is_active' => 1); $defaults = array(); $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params); CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessor->id); $params = array('id' => $paymentProcessor->id); $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults); $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.'); }
/** * 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(); }
/** * {@inheritdoc} */ public function onPreUninstall(CRM_Extension_Info $info) { $paymentProcessorTypes = $this->_getAllPaymentProcessorTypes('class_name'); if (!array_key_exists($info->key, $paymentProcessorTypes)) { CRM_Core_Error::fatal('This payment processor type is not registered.'); } $dao = new CRM_Financial_DAO_PaymentProcessor(); $dao->payment_processor_type_id = $paymentProcessorTypes[$info->key]; $dao->find(); while ($dao->fetch()) { throw new CRM_Extension_Exception_DependencyException('payment'); } $this->_runPaymentHook($info, 'uninstall'); return CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessorTypes[$info->key]); }
/** * Delete a payment_processor type delete * * @param id of payment_processor type $id * * @return array API Result Array * {@getfields PaymentProcessorType_delete} * @static void * @access public */ function civicrm_api3_payment_processor_type_delete($params) { if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) { return civicrm_api3_create_error('Invalid value for payment processor type ID'); } $payProcTypeBAO = new CRM_Financial_BAO_PaymentProcessorType(); $result = $payProcTypeBAO->del($params['id']); if (!$result) { return civicrm_api3_create_error('Could not delete payment processor type'); } return civicrm_api3_create_success($result, $params, 'payment_processor_type', 'delete', $payProcTypeBAO); }