/** * Function to add the payment-processor type in the db * * @param array $params (reference ) an assoc array of name/value pairs * @param array $ids the array that holds all the db ids * * @return object CRM_Core_DAO_PaymentProcessorType * @access public * @static * */ static function create(&$params) { $paymentProcessorType = new CRM_Core_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(CRM_Core_PseudoConstant::billingMode()); if (array_key_exists($paymentProcessorType->billing_mode, $billingModes)) { $paymentProcessorType->billing_mode = $billingModes[$paymentProcessorType->billing_mode]; } } if (!array_key_exists($paymentProcessorType->billing_mode, CRM_Core_PseudoConstant::billingMode())) { 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(); }
/** * Get all payment-processor billing modes * * @access public * @static * * @return array ($id => $name) */ public static function billingMode() { if (!self::$billingMode) { self::$billingMode = array(CRM_Core_Payment::BILLING_MODE_FORM => 'form', CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify'); } return self::$billingMode; }