/** * Function to add the payment-processor type in the db * * @param array $params (reference ) an assoc array of name/value pairs * * @throws Exception * @internal param array $ids the array that holds all the db ids * * @return object CRM_Financial_DAO_PaymentProcessorType * @access public * @static */ static function create(&$params) { $paymentProcessorType = new CRM_Financial_DAO_PaymentProcessorType(); $paymentProcessorType->copyValues($params); /* // adapted from CRM_Core_Extensions_Payment::install foreach (array( 'class_name', 'title', 'name', 'description', 'user_name_label', 'password_label', 'signature_label', 'subject_label', 'url_site_default', 'url_api_default', 'url_recur_default', 'url_site_test_default', 'url_api_test_default', 'url_recur_test_default', 'url_button_default', 'url_button_test_default', 'billing_mode', 'is_recur', 'payment_type' ) as $trimmable) { if (isset($paymentProcessorType->{$trimmable})) { $paymentProcessorType->{$trimmable} = trim($paymentProcessorType->{$trimmable}); } } */ if (isset($paymentProcessorType->billing_mode)) { // ugh unidirectional manipulation if (!is_numeric($paymentProcessorType->billing_mode)) { $billingModes = array_flip(self::buildOptions('billing_mode')); if (array_key_exists($paymentProcessorType->billing_mode, $billingModes)) { $paymentProcessorType->billing_mode = $billingModes[$paymentProcessorType->billing_mode]; } } if (!array_key_exists($paymentProcessorType->billing_mode, self::buildOptions('billing_mode'))) { throw new Exception("Unrecognized billing_mode"); } } // FIXME handle is_default if (!empty($paymentProcessorType->id)) { $ppByName = self::getAllPaymentProcessorTypes('name'); if (array_key_exists($paymentProcessorType->name, $ppByName)) { if ($ppByName[$paymentProcessorType->name] != $paymentProcessorType->id) { CRM_Core_Error::fatal('This payment processor type already exists.'); } } } return $paymentProcessorType->save(); }