/** * Handle Payment Processor switching for contribution and event registration forms. * * This function is shared between contribution & event forms & this is their common class. * * However, this should be seen as an in-progress refactor, the end goal being to also align the * backoffice forms that action payments. * * This function overlaps assignPaymentProcessor, in a bad way. */ protected function preProcessPaymentOptions() { $this->_paymentProcessorID = NULL; if ($this->_paymentProcessors) { if (!empty($this->_submitValues)) { $this->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $this->_submitValues); $this->_paymentProcessor = CRM_Utils_Array::value($this->_paymentProcessorID, $this->_paymentProcessors); $this->set('type', $this->_paymentProcessorID); $this->set('mode', $this->_mode); $this->set('paymentProcessor', $this->_paymentProcessor); } else { foreach ($this->_paymentProcessors as $values) { if (!empty($values['is_default']) || count($this->_paymentProcessors) == 1) { $this->_paymentProcessorID = $values['id']; break; } } } if ($this->_paymentProcessorID) { CRM_Core_Payment_ProcessorForm::preProcess($this); } else { $this->_paymentProcessor = array(); } CRM_Financial_Form_Payment::addCreditCardJs(); } $this->assign('paymentProcessorID', $this->_paymentProcessorID); }
/** * Handle Payment Processor switching for contribution and event registration forms. * * @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register $form * @param bool $noFees */ public static function preProcessPaymentOptions(&$form, $noFees = FALSE) { $form->_snippet = CRM_Utils_Array::value('snippet', $_GET); $form->_paymentProcessors = $noFees ? array() : $form->get('paymentProcessors'); $form->_paymentProcessorID = NULL; if ($form->_paymentProcessors) { if (!empty($form->_submitValues)) { $form->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $form->_submitValues); $form->_paymentProcessor = CRM_Utils_Array::value($form->_paymentProcessorID, $form->_paymentProcessors); $form->set('type', $form->_paymentProcessorID); $form->set('mode', $form->_mode); $form->set('paymentProcessor', $form->_paymentProcessor); } else { foreach ($form->_paymentProcessors as $values) { if (!empty($values['is_default']) || count($form->_paymentProcessors) == 1) { $form->_paymentProcessorID = $values['id']; break; } } } if ($form->_paymentProcessorID) { CRM_Core_Payment_ProcessorForm::preProcess($form); } else { $form->_paymentProcessor = array(); } CRM_Financial_Form_Payment::addCreditCardJs(); } $form->assign('paymentProcessorID', $form->_paymentProcessorID); }
/** * Handle Payment Processor switching for contribution and event registration forms. * * This function is shared between contribution & event forms & this is their common class. * * However, this should be seen as an in-progress refactor, the end goal being to also align the * backoffice forms that action payments. * * This function overlaps assignPaymentProcessor, in a bad way. */ protected function preProcessPaymentOptions() { $this->_paymentProcessorID = NULL; if ($this->_paymentProcessors) { if (!empty($this->_submitValues)) { $this->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $this->_submitValues); $this->_paymentProcessor = CRM_Utils_Array::value($this->_paymentProcessorID, $this->_paymentProcessors); $this->set('type', $this->_paymentProcessorID); $this->set('mode', $this->_mode); $this->set('paymentProcessor', $this->_paymentProcessor); } else { foreach ($this->_paymentProcessors as $values) { if (!empty($values['is_default']) || count($this->_paymentProcessors) == 1) { $this->_paymentProcessorID = $values['id']; break; } } } if ($this->_paymentProcessorID || isset($this->_submitValues['payment_processor_id']) && $this->_submitValues['payment_processor_id'] == 0) { CRM_Core_Payment_ProcessorForm::preProcess($this); } else { $this->_paymentProcessor = array(); } CRM_Financial_Form_Payment::addCreditCardJs(); } $this->assign('paymentProcessorID', $this->_paymentProcessorID); // We save the fact that the profile 'billing' is required on the payment form. // Currently pay-later is the only 'processor' that takes notice of this - but ideally // 1) it would be possible to select the minimum_billing_profile_id for the contribution form // 2) that profile_id would be set on the payment processor // 3) the payment processor would return a billing form that combines these user-configured // minimums with the payment processor minimums. This would lead to fields like 'postal_code' // only being on the form if either the admin has configured it as wanted or the processor // requires it. $this->assign('billing_profile_id', CRM_Utils_Array::value('is_billing_required', $this->_values) ? 'billing' : ''); }
/** * Set variables up before form is built. */ public function preProcess() { // Check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } // @todo - if anyone ever figures out what this _cdType subroutine is about // (or even if it still applies) please add comments!!!!!!!!!! $this->_cdType = CRM_Utils_Array::value('type', $_GET); $this->assign('cdType', FALSE); if ($this->_cdType) { $this->assign('cdType', TRUE); CRM_Custom_Form_CustomData::preProcess($this); return; } parent::preProcess(); $this->_formType = CRM_Utils_Array::value('formType', $_GET); // Get price set id. $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); // Get the pledge payment id $this->_ppID = CRM_Utils_Request::retrieve('ppid', 'Positive', $this); $this->assign('action', $this->_action); // Get the contribution id if update $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if (!empty($this->_id)) { $this->assign('contribID', $this->_id); } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this); $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this); //set the contribution mode. $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->assign('contributionMode', $this->_mode); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->assign('showCheckNumber', TRUE); $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); $this->assignPaymentRelatedVariables(); if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) { $this->preProcessPledge(); } if ($this->_id) { $this->showRecordLinkMesssage($this->_id); } $this->_values = array(); // Current contribution id. if ($this->_id) { $this->assignPremiumProduct($this->_id); $this->buildValuesAndAssignOnline_Note_Type($this->_id, $this->_values); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id); } $this->_lineItems = array(); if ($this->_id) { if (!empty($this->_compId) && $this->_compContext == 'participant') { $this->assign('compId', $this->_compId); $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_compId); } else { $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1, TRUE, TRUE); } empty($lineItem) ? NULL : ($this->_lineItems[] = $lineItem); } $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems); // Set title if ($this->_mode) { CRM_Financial_Form_Payment::addCreditCardJs(); $this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution')); } else { $this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution')); } if ($this->_id) { CRM_Contribute_Form_SoftCredit::preprocess($this); } }
/** * 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); }
/** * 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) { $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); }