/** * Set variables up before form is built. * * @return void */ public function preProcess() { parent::preProcess(); $this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE); $this->assignBillingType(); // @todo - round about way to load it - just load as an object using civi\payment\system::getByProcessor $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID, 'unused'); CRM_Core_Payment_ProcessorForm::preProcess($this); self::addCreditCardJs(); $this->assign('paymentProcessorID', $this->_paymentProcessorID); }
/** * Set variables up before form is built. */ public function preProcess() { parent::preProcess(); $this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE); $this->assignBillingType(); $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID); CRM_Core_Payment_ProcessorForm::preProcess($this); self::addCreditCardJs(); $this->assign('paymentProcessorID', $this->_paymentProcessorID); $this->assign('suppressForm', TRUE); }
/** * Set variables up before form is built. */ public function preProcess() { parent::preProcess(); $this->_values['custom_pre_id'] = CRM_Utils_Request::retrieve('pre_profile_id', 'Integer', $this); $this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE); $this->currency = CRM_Utils_Request::retrieve('currency', 'String', CRM_Core_DAO::$_nullObject, TRUE); $this->assignBillingType(); $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID); CRM_Core_Payment_ProcessorForm::preProcess($this); self::addCreditCardJs(); $this->assign('paymentProcessorID', $this->_paymentProcessorID); $this->assign('currency', $this->currency); $this->assign('suppressForm', TRUE); $this->controller->_generateQFKey = FALSE; }
/** * 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' : ''); }
/** * Handle Payment Processor switching * For contribution and event registration forms */ static function preProcessPaymentOptions(&$form, $noFees = FALSE) { $form->_snippet = CRM_Utils_Array::value('snippet', $_GET); $form->assign('snippet', $form->_snippet); $form->_paymentProcessors = $noFees ? array() : $form->get('paymentProcessors'); $form->_ppType = NULL; if ($form->_paymentProcessors) { // Fetch type during ajax request if (isset($_GET['type']) && $form->_snippet) { $form->_ppType = $_GET['type']; } elseif (!empty($form->_submitValues)) { $form->_ppType = CRM_Utils_Array::value('payment_processor', $form->_submitValues); $form->_paymentProcessor = CRM_Utils_Array::value($form->_ppType, $form->_paymentProcessors); $form->set('type', $form->_ppType); $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->_ppType = $values['id']; break; } } } if ($form->_ppType) { CRM_Core_Payment_ProcessorForm::preProcess($form); } //get payPal express id and make it available to template foreach ($form->_paymentProcessors as $ppId => $values) { $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0; $form->assign('payPalExpressId', $payPalExpressId); if ($payPalExpressId) { break; } } if (!$form->_snippet) { // Add JS to show icons for the accepted credit cards $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames(); CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';'); } } $form->assign('ppType', $form->_ppType); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { parent::preProcess(); $this->_ppType = CRM_Utils_Array::value('type', $_GET); $this->assign('ppType', FALSE); if ($this->_ppType) { $this->assign('ppType', TRUE); return CRM_Core_Payment_ProcessorForm::preProcess($this); } //get payPal express id and make it available to template $paymentProcessors = $this->get('paymentProcessors'); $this->assign('payPalExpressId', 0); if (!empty($paymentProcessors)) { foreach ($paymentProcessors as $ppId => $values) { $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0; $this->assign('payPalExpressId', $payPalExpressId); if ($payPalExpressId) { break; } } } //CRM-4320. //here we can't use parent $this->_allowWaitlist as user might //walk back and we maight set this value in this postProcess. //(we set when spaces < group count and want to allow become part of waiting ) $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event'])); $this->_allowWaitlist = FALSE; if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) { $this->_allowWaitlist = TRUE; $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']); if (!$this->_waitlistMsg) { $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.'); } } $this->set('allowWaitlist', $this->_allowWaitlist); //To check if the user is already registered for the event(CRM-2426) if (!$this->_skipDupeRegistrationCheck) { self::checkRegistration(NULL, $this); } $this->assign('availableRegistrations', $this->_availableRegistrations); // get the participant values from EventFees.php, CRM-4320 if ($this->_allowConfirmation) { CRM_Event_Form_EventFees::preProcess($this); } if (CRM_Utils_Array::value('hidden_processor', $_POST)) { $this->set('type', CRM_Utils_Array::value('payment_processor', $_POST)); $this->set('mode', $this->_mode); $this->set('paymentProcessor', $this->_paymentProcessor); CRM_Core_Payment_ProcessorForm::preProcess($this); CRM_Core_Payment_ProcessorForm::buildQuickForm($this); } }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { parent::preProcess(); $this->_ppType = CRM_Utils_Array::value('type', $_GET); $this->assign('ppType', FALSE); if ($this->_ppType) { $this->assign('ppType', TRUE); return CRM_Core_Payment_ProcessorForm::preProcess($this); } //get payPal express id and make it available to template $paymentProcessors = $this->get('paymentProcessors'); if (!empty($paymentProcessors)) { foreach ($paymentProcessors as $ppId => $values) { $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0; $this->assign('payPalExpressId', $payPalExpressId); if ($payPalExpressId) { break; } } } // Make the contributionPageID avilable to the template $this->assign('contributionPageID', $this->_id); $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values)); $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values)); // make sure we have right permission to edit this user $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, $this->_userID); $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject); if ($csContactID != $this->_userID) { if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) { $session = CRM_Core_Session::singleton(); $session->set('userID', $csContactID); $this->_userID = $csContactID; } } if ($reset) { $this->assign('reset', $reset); } if ($mainDisplay) { $this->assign('mainDisplay', $mainDisplay); } $this->_onbehalf = FALSE; if (CRM_Utils_Array::value('is_for_organization', $this->_values)) { $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}"; $this->assign('urlParams', $urlParams); $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET); CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this); if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && (CRM_Utils_Array::value('is_for_organization', $_POST) || CRM_Utils_Array::value('is_for_organization', $this->_values) == 2)) { CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this); } } if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) { $this->assign('intro_text', $this->_pcpInfo['intro_text']); } elseif (CRM_Utils_Array::value('intro_text', $this->_values)) { $this->assign('intro_text', $this->_values['intro_text']); } $qParams = "reset=1&id={$this->_id}"; if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) { $qParams .= "&pcpId={$pcpId}"; } $this->assign('qParams', $qParams); if (CRM_Utils_Array::value('footer_text', $this->_values)) { $this->assign('footer_text', $this->_values['footer_text']); } //CRM-5001 if (CRM_Utils_Array::value('is_for_organization', $this->_values)) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) { $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID); foreach (array('Individual', 'Organization', 'Household') as $contactType) { if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) { CRM_Core_Error::fatal($msg); } } } if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) { $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID); foreach (array('Individual', 'Organization', 'Household') as $contactType) { if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) { CRM_Core_Error::fatal($msg); } } } } if (CRM_Utils_Array::value('hidden_processor', $_POST)) { $this->set('type', CRM_Utils_Array::value('payment_processor', $_POST)); $this->set('mode', $this->_mode); $this->set('paymentProcessor', $this->_paymentProcessor); CRM_Core_Payment_ProcessorForm::preProcess($this); CRM_Core_Payment_ProcessorForm::buildQuickForm($this); } }