Exemplo n.º 1
0
 /**
  * @return array
  *   Array of valid processors. The array resembles the DB table but also has 'object' as a key
  * @throws Exception
  */
 public function getValidProcessors()
 {
     $defaultID = NULL;
     $capabilities = array('BackOffice');
     if ($this->_mode) {
         $capabilities[] = ucfirst($this->_mode) . 'Mode';
     }
     $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors($capabilities);
     return $processors;
 }
Exemplo n.º 2
0
 /**
  * This if a front end form function for setting the payment processor.
  *
  * It would be good to sync it with the back-end function on abstractEditPayment & use one everywhere.
  *
  * @throws \CRM_Core_Exception
  */
 protected function assignPaymentProcessor()
 {
     $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(array(ucfirst($this->_mode) . 'Mode'), $this->_paymentProcessorIDs);
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $paymentProcessorID => $paymentProcessorDetail) {
             if (empty($this->_paymentProcessor) && $paymentProcessorDetail['is_default'] == 1 || count($this->_paymentProcessors) == 1) {
                 $this->_paymentProcessor = $paymentProcessorDetail;
                 $this->assign('paymentProcessor', $this->_paymentProcessor);
                 // Setting this is a bit of a legacy overhang.
                 $this->_paymentObject = $paymentProcessorDetail['object'];
             }
         }
         // It's not clear why we set this on the form.
         $this->set('paymentProcessors', $this->_paymentProcessors);
     } else {
         throw new CRM_Core_Exception(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
     }
 }
 /**
  * called when action is browse.
  *
  */
 public function browse()
 {
     // add annual contribution
     $annual = array();
     list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId);
     $this->assign('annual', $annual);
     $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action, FALSE, FALSE, TRUE);
     $controller->setEmbedded(TRUE);
     $controller->reset();
     $controller->set('cid', $this->_contactId);
     $controller->set('crid', $this->_crid);
     $controller->set('context', 'contribution');
     $controller->set('limit', 50);
     $controller->process();
     $controller->run();
     // add recurring block
     $action = array_sum(array_keys($this->recurLinks()));
     $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId);
     // Get all backoffice payment processors
     $backOfficePaymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(array('BackOffice'));
     if (!empty($params)) {
         foreach ($params as $ids => $recur) {
             $action = array_sum(array_keys($this->recurLinks($ids)));
             // no action allowed if it's not active
             $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3;
             // Get payment processor name
             $paymentProcessorDetails = CRM_Financial_BAO_PaymentProcessor::getPayment($params[$ids]['payment_processor_id'], 'live');
             $params[$ids]['payment_processor_name'] = $paymentProcessorDetails['name'];
             $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur');
             $hideUpdate = $details->membership_id & $details->auto_renew;
             if ($hideUpdate) {
                 $action -= CRM_Core_Action::UPDATE;
             }
             $links = self::recurLinks($ids);
             // Disable Edit/Delete link if no back office support
             if (!array_key_exists($recur['payment_processor_id'], $backOfficePaymentProcessors)) {
                 unset($links[2]);
                 unset($links[8]);
             }
             // Remove cancel link for already cancelled recurring records
             if ($recur['contribution_status_id'] == 3) {
                 unset($links[64]);
             }
             $params[$ids]['action'] = CRM_Core_Action::formLink($links, $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.selector.recurring', 'Contribution', $ids);
         }
         // assign vars to templates
         $this->assign('action', $this->_action);
         $this->assign('recurRows', $params);
         $this->assign('recur', TRUE);
     }
     //enable/disable soft credit records for test contribution
     $isTest = 0;
     if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
         $isTest = 1;
     }
     $this->assign('isTest', $isTest);
     $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest);
     if (!empty($softCreditList)) {
         $softCreditTotals = array();
         list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
         $this->assign('softCredit', TRUE);
         $this->assign('softCreditRows', $softCreditList);
         $this->assign('softCreditTotals', $softCreditTotals);
     }
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         $this->ajaxResponse['tabCount'] = CRM_Contribute_BAO_ContributionRecur::contributionRecurCount($this->_contactId);
     }
 }