/**
  * Assign $this->processors, $this->recurPaymentProcessors, and related Smarty variables
  */
 public function assignProcessors()
 {
     //ensure that processor has a valid config
     //only valid processors get display to user
     if ($this->_mode) {
         $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('supportsFutureRecurStartDate')));
         $this->_paymentProcessors = $this->getValidProcessors();
         if (!isset($this->_paymentProcessor['id'])) {
             // if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default
             $this->_paymentProcessor = reset($this->_paymentProcessors);
         }
         if (empty($this->_paymentProcessors)) {
             throw new CRM_Core_Exception(ts('You will need to configure the %1 settings for your Payment Processor before you can submit a credit card transactions.', array(1 => $this->_mode)));
         }
         $this->_processors = array();
         foreach ($this->_paymentProcessors as $id => $processor) {
             $this->_processors[$id] = ts($processor['name']);
             if (!empty($processor['description'])) {
                 $this->_processors[$id] .= ' : ' . ts($processor['description']);
             }
         }
         //get the valid recurring processors.
         $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
         $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
         $this->_recurPaymentProcessors = array_intersect_key($this->_processors, $recurring);
     }
     $this->assign('recurringPaymentProcessorIds', empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors)));
     // this required to show billing block
     // @todo remove this assignment the billing block is now designed to be always included but will not show fieldsets unless those sets of fields are assigned
     $this->assign_by_ref('paymentProcessor', $processor);
 }
Example #2
0
 /**
  * Is back office credit card processing enabled for this site - ie are there any installed processors that support
  * it?
  * This function is used for determining whether to show the submit credit card link, not for determining which processors to show, hence
  * it is a config var
  * @return bool
  */
 public static function isEnabledBackOfficeCreditCardPayments()
 {
     return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('BackOffice'));
 }
 /**
  * Assign $this->processors, $this->recurPaymentProcessors, and related Smarty variables
  */
 public function assignProcessors()
 {
     //ensure that processor has a valid config
     //only valid processors get display to user
     if ($this->_mode) {
         $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('FutureRecurStartDate')));
         $this->_paymentProcessors = $this->getValidProcessors();
         if (!isset($this->_paymentProcessor['id'])) {
             // if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default
             $this->_paymentProcessor = reset($this->_paymentProcessors);
         }
         if (empty($this->_paymentProcessors)) {
             throw new CRM_Core_Exception(ts('You will need to configure the %1 settings for your Payment Processor before you can submit a credit card transactions.', array(1 => $this->_mode)));
         }
         $this->_processors = array();
         foreach ($this->_paymentProcessors as $id => $processor) {
             // @todo review this. The inclusion of this IF was to address test processors being incorrectly loaded.
             // However the function $this->getValidProcessors() is expected to only return the processors relevant
             // to the mode (using the actual id - ie. the id of the test processor for the test processor).
             // for some reason there was a need to filter here per commit history - but this indicates a problem
             // somewhere else.
             if ($processor['is_test'] == ($this->_mode == 'test')) {
                 $this->_processors[$id] = ts($processor['name']);
                 if (!empty($processor['description'])) {
                     $this->_processors[$id] .= ' : ' . ts($processor['description']);
                 }
                 if ($processor['is_recur']) {
                     $this->_recurPaymentProcessors[$id] = $this->_processors[$id];
                 }
             }
         }
         CRM_Financial_Form_Payment::addCreditCardJs();
     }
     $this->assign('recurringPaymentProcessorIds', empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors)));
     // this required to show billing block
     // @todo remove this assignment the billing block is now designed to be always included but will not show fieldsets unless those sets of fields are assigned
     $this->assign_by_ref('paymentProcessor', $processor);
 }