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 CRM_Financial_DAO_PaymentProcessor */ function create() { $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor(); $paymentParams = array('name' => 'Authorize', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type' => 'AuthNet', 'is_active' => 1, 'is_default' => 0, 'is_test' => 1, 'user_name' => '4y5BfuW7jm', 'password' => '4cAmW927n8uLf5J8', 'url_site' => 'https://test.authorize.net/gateway/transact.dll', 'url_recur' => 'https://apitest.authorize.net/xml/v1/request.api', 'class_name' => 'Payment_AuthorizeNet', 'billing_mode' => 1); $paymentProcessor->copyValues($paymentParams); $paymentProcessor->save(); return $paymentProcessor; }
/** * Helper function to create * a payment processor of type Paypal Pro * * @return int $paymentProcessor id of created payment processor@todo this appears not to be working but because it doesn't extend the test class * callAPISuccess won't work * I have duplicated this on the main test class as a work around */ static function create() { $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor(); $paymentParams = array('name' => 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type' => 'PayPal', 'is_active' => 1, 'is_default' => 0, 'is_test' => 1, 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in', 'password' => '1183377788', 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH', 'url_site' => 'https://www.sandbox.paypal.com/', 'url_api' => 'https://api-3t.sandbox.paypal.com/', 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', 'class_name' => 'Payment_PayPalImpl', 'billing_mode' => 3, 'financial_type_id' => 1); $paymentProcessor->copyValues($paymentParams); $paymentProcessor->save(); return $paymentProcessor->id; }
/** * Save a payment processor. * * @param $values * @param int $domainID * @param $test * * @return void */ public function updatePaymentProcessor(&$values, $domainID, $test) { $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, 'financial_account_id' => $values['financial_account_id']); CRM_Financial_BAO_FinancialTypeAccount::add($params); }