/** * retrieve the default payment processor * * @param NULL * * @return object The default payment processor object on success, * null otherwise * @static * @access public */ static function &getDefault() { if (self::$_defaultPaymentProcessorType == NULL) { $params = array('is_default' => 1); $defaults = array(); self::$_defaultPaymentProcessorType = self::retrieve($params, $defaults); } return self::$_defaultPaymentProcessorType; }
/** * 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 onPreEnable(CRM_Extension_Info $info) { $paymentProcessorTypes = $this->_getAllPaymentProcessorTypes('class_name'); CRM_Financial_BAO_PaymentProcessorType::setIsActive($paymentProcessorTypes[$info->key], 1); }
/** * 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); }