3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
35 * This class generates form components for processing a Contribution.
37 class CRM_Contribute_Form_Contribution_Main
extends CRM_Contribute_Form_ContributionBase
{
40 * Define default MembershipType Id.
42 public $_defaultMemTypeId;
44 public $_paymentProcessors;
46 public $_membershipTypeValues;
48 public $_useForMember;
51 * Array of payment related fields to potentially display on this form (generally credit card or debit card fields). This is rendered via billingBlock.tpl
54 public $_paymentFields = array();
56 protected $_paymentProcessorID;
60 * Set variables up before form is built.
62 public function preProcess() {
65 $this->_paymentProcessors
= $this->get('paymentProcessors');
66 $this->preProcessPaymentOptions();
68 // Make the contributionPageID available to the template
69 $this->assign('contributionPageID', $this->_id
);
70 $this->assign('isShare', CRM_Utils_Array
::value('is_share', $this->_values
));
71 $this->assign('isConfirmEnabled', CRM_Utils_Array
::value('is_confirm_enabled', $this->_values
));
73 $this->assign('reset', CRM_Utils_Request
::retrieve('reset', 'Boolean', CRM_Core_DAO
::$_nullObject));
74 $this->assign('mainDisplay', CRM_Utils_Request
::retrieve('_qf_Main_display', 'Boolean',
75 CRM_Core_DAO
::$_nullObject));
77 if (!empty($this->_pcpInfo
['id']) && !empty($this->_pcpInfo
['intro_text'])) {
78 $this->assign('intro_text', $this->_pcpInfo
['intro_text']);
80 elseif (!empty($this->_values
['intro_text'])) {
81 $this->assign('intro_text', $this->_values
['intro_text']);
84 $qParams = "reset=1&id={$this->_id}";
85 if ($pcpId = CRM_Utils_Array
::value('pcp_id', $this->_pcpInfo
)) {
86 $qParams .= "&pcpId={$pcpId}";
88 $this->assign('qParams', $qParams);
90 if (!empty($this->_values
['footer_text'])) {
91 $this->assign('footer_text', $this->_values
['footer_text']);
96 * Set the default values.
98 public function setDefaultValues() {
99 // check if the user is registered and we have a contact ID
100 $contactID = $this->getContactID();
102 if (!empty($contactID)) {
104 $removeCustomFieldTypes = array('Contribution', 'Membership');
105 $contribFields = CRM_Contribute_BAO_Contribution
::getContributionFields();
107 // remove component related fields
108 foreach ($this->_fields
as $name => $dontCare) {
109 //don't set custom data Used for Contribution (CRM-1344)
110 if (substr($name, 0, 7) == 'custom_') {
111 $id = substr($name, 7);
112 if (!CRM_Core_BAO_CustomGroup
::checkCustomField($id, $removeCustomFieldTypes)) {
115 // ignore component fields
117 elseif (array_key_exists($name, $contribFields) ||
(substr($name, 0, 11) == 'membership_') ||
(substr($name, 0, 13) == 'contribution_')) {
123 if (!empty($fields)) {
124 CRM_Core_BAO_UFGroup
::setProfileDefaults($contactID, $fields, $this->_defaults
);
127 $billingDefaults = $this->getProfileDefaults('Billing', $contactID);
128 $this->_defaults
= array_merge($this->_defaults
, $billingDefaults);
132 * hack to simplify credit card entry for testing
134 * $this->_defaults['credit_card_type'] = 'Visa';
135 * $this->_defaults['amount'] = 168;
136 * $this->_defaults['credit_card_number'] = '4111111111111111';
137 * $this->_defaults['cvv2'] = '000';
138 * $this->_defaults['credit_card_exp_date'] = array('Y' => date('Y')+1, 'M' => '05');
139 * // hack to simplify direct debit entry for testing
140 * $this->_defaults['account_holder'] = 'Max Müller';
141 * $this->_defaults['bank_account_number'] = '12345678';
142 * $this->_defaults['bank_identification_number'] = '12030000';
143 * $this->_defaults['bank_name'] = 'Bankname';
146 //build set default for pledge overdue payment.
147 if (!empty($this->_values
['pledge_id'])) {
148 //used to record completed pledge payment ids used later for honor default
149 $completedContributionIds = array();
150 $pledgePayments = CRM_Pledge_BAO_PledgePayment
::getPledgePayments($this->_values
['pledge_id']);
153 foreach ($pledgePayments as $payId => $value) {
154 if ($value['status'] == 'Overdue') {
155 $this->_defaults
['pledge_amount'][$payId] = 1;
157 elseif (!$duePayment && $value['status'] == 'Pending') {
158 $this->_defaults
['pledge_amount'][$payId] = 1;
161 elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
162 $completedContributionIds[] = $value['contribution_id'];
166 if (count($completedContributionIds)) {
167 $softCredit = array();
168 foreach ($completedContributionIds as $id) {
169 $softCredit = CRM_Contribute_BAO_ContributionSoft
::getSoftContribution($id);
171 if (isset($softCredit['soft_credit'])) {
172 $this->_defaults
['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
174 //since honoree profile fieldname of fields are prefixed with 'honor'
175 //we need to reformat the fieldname to append prefix during setting default values
176 CRM_Core_BAO_UFGroup
::setProfileDefaults(
177 $softCredit['soft_credit'][1]['contact_id'],
178 CRM_Core_BAO_UFGroup
::getFields($this->_honoreeProfileId
),
181 foreach ($defaults as $fieldName => $value) {
182 $this->_defaults
['honor[' . $fieldName . ']'] = $value;
187 elseif (!empty($this->_values
['pledge_block_id'])) {
188 //set default to one time contribution.
189 $this->_defaults
['is_pledge'] = 0;
192 // to process Custom data that are appended to URL
193 $getDefaults = CRM_Core_BAO_CustomGroup
::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
194 $this->_defaults
= array_merge($this->_defaults
, $getDefaults);
196 $config = CRM_Core_Config
::singleton();
197 // set default country from config if no country set
198 if (empty($this->_defaults
["billing_country_id-{$this->_bltID}"])) {
199 $this->_defaults
["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry
;
202 // set default state/province from config if no state/province set
203 if (empty($this->_defaults
["billing_state_province_id-{$this->_bltID}"])) {
204 $this->_defaults
["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince
;
207 $entityId = $memtypeID = NULL;
208 if ($this->_priceSetId
) {
209 if (($this->_useForMember
&& !empty($this->_currentMemberships
)) ||
$this->_defaultMemTypeId
) {
210 $selectedCurrentMemTypes = array();
211 foreach ($this->_priceSet
['fields'] as $key => $val) {
212 foreach ($val['options'] as $keys => $values) {
213 $opMemTypeId = CRM_Utils_Array
::value('membership_type_id', $values);
214 $priceFieldValue = CRM_Price_BAO_PriceSet
::getPriceFieldValueFromURL($this, $priceFieldName);
215 if (!empty($priceFieldValue)) {
216 CRM_Price_BAO_PriceSet
::setDefaultPriceSetField($priceFieldName, $priceFieldValue, $val['html_type'], $this->_defaults
);
217 // break here to prevent overwriting of default due to 'is_default'
218 // option configuration or setting of current membership or
219 // membership for related organization.
220 // The value sent via URL get's higher priority.
223 elseif ($opMemTypeId &&
224 in_array($opMemTypeId, $this->_currentMemberships
) &&
225 !in_array($opMemTypeId, $selectedCurrentMemTypes)
227 CRM_Price_BAO_PriceSet
::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults
);
228 $memtypeID = $selectedCurrentMemTypes[] = $values['membership_type_id'];
230 elseif (!empty($values['is_default']) &&
232 (!isset($this->_defaults
[$priceFieldName]) ||
233 ($val['html_type'] == 'CheckBox' &&
234 !isset($this->_defaults
[$priceFieldName][$keys]))
236 CRM_Price_BAO_PriceSet
::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults
);
237 $memtypeID = CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_defaults
[$priceFieldName], 'membership_type_id');
241 $entityId = CRM_Utils_Array
::value('id', CRM_Member_BAO_Membership
::getContactMembership($contactID, $memtypeID, NULL));
244 CRM_Price_BAO_PriceSet
::setDefaultPriceSet($this, $this->_defaults
);
248 //set custom field defaults set by admin if value is not set
249 if (!empty($this->_fields
)) {
250 //load default campaign from page.
251 if (array_key_exists('contribution_campaign_id', $this->_fields
)) {
252 $this->_defaults
['contribution_campaign_id'] = CRM_Utils_Array
::value('campaign_id', $this->_values
);
255 //set custom field defaults
256 foreach ($this->_fields
as $name => $field) {
257 if ($customFieldID = CRM_Core_BAO_CustomField
::getKeyID($name)) {
258 if (!isset($this->_defaults
[$name])) {
259 CRM_Core_BAO_CustomField
::setProfileDefaults($customFieldID, $name, $this->_defaults
,
260 $entityId, CRM_Profile_Form
::MODE_REGISTER
267 if (!empty($this->_paymentProcessors
)) {
268 foreach ($this->_paymentProcessors
as $pid => $value) {
269 if (!empty($value['is_default'])) {
270 $this->_defaults
['payment_processor_id'] = $pid;
275 return $this->_defaults
;
279 * Build the form object.
281 public function buildQuickForm() {
282 // build profiles first so that we can determine address fields etc
283 // and then show copy address checkbox
284 $this->buildCustom($this->_values
['custom_pre_id'], 'customPre');
285 $this->buildCustom($this->_values
['custom_post_id'], 'customPost');
287 $this->buildComponentForm($this->_id
, $this);
289 if (!empty($this->_fields
) && !empty($this->_values
['custom_pre_id'])) {
290 $profileAddressFields = array();
291 foreach ($this->_fields
as $key => $value) {
292 CRM_Core_BAO_UFField
::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $this->_values
['custom_pre_id']));
294 $this->set('profileAddressFields', $profileAddressFields);
297 // Build payment processor form
298 CRM_Core_Payment_ProcessorForm
::buildQuickForm($this);
300 $config = CRM_Core_Config
::singleton();
302 $contactID = $this->getContactID();
304 $this->assign('contact_id', $contactID);
305 $this->assign('display_name', CRM_Contact_BAO_Contact
::displayName($contactID));
308 $this->applyFilter('__ALL__', 'trim');
309 $this->add('text', "email-{$this->_bltID}",
311 array('size' => 30, 'maxlength' => 60, 'class' => 'email'),
314 $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
316 //@todo - this should be replaced by a check as to whether billing fields are set
317 $onlinePaymentProcessorEnabled = FALSE;
318 if (!empty($this->_paymentProcessors
)) {
319 foreach ($this->_paymentProcessors
as $key => $name) {
320 if ($name['billing_mode'] == 1) {
321 $onlinePaymentProcessorEnabled = TRUE;
323 $pps[$key] = $name['name'];
326 if (!empty($this->_values
['is_pay_later'])) {
327 $pps[0] = $this->_values
['pay_later_text'];
330 if (count($pps) > 1) {
331 $this->addRadio('payment_processor_id', ts('Payment Method'), $pps,
335 elseif (!empty($pps)) {
336 $key = array_keys($pps);
337 $key = array_pop($key);
338 $this->addElement('hidden', 'payment_processor_id', $key);
340 $this->assign('is_pay_later', $this->_values
['is_pay_later']);
341 $this->assign('pay_later_text', $this->_values
['pay_later_text']);
345 $contactID = $this->getContactID();
346 if ($this->getContactID() === 0) {
347 $this->addCidZeroOptions($onlinePaymentProcessorEnabled);
350 //build pledge block.
351 $this->_useForMember
= 0;
352 //don't build membership block when pledge_id is passed
353 if (empty($this->_values
['pledge_id'])) {
354 $this->_separateMembershipPayment
= FALSE;
355 if (in_array('CiviMember', $config->enableComponents
)) {
357 if ($this->_action
& CRM_Core_Action
::PREVIEW
) {
361 if ($this->_priceSetId
&&
362 (CRM_Core_Component
::getComponentID('CiviMember') == CRM_Utils_Array
::value('extends', $this->_priceSet
))
364 $this->_useForMember
= 1;
365 $this->set('useForMember', $this->_useForMember
);
368 $this->_separateMembershipPayment
= $this->buildMembershipBlock(
369 $this->_membershipContactID
,
374 $this->set('separateMembershipPayment', $this->_separateMembershipPayment
);
376 $this->assign('useForMember', $this->_useForMember
);
377 // If we configured price set for contribution page
378 // we are not allow membership signup as well as any
379 // other contribution amount field, CRM-5095
380 if (isset($this->_priceSetId
) && $this->_priceSetId
) {
381 $this->add('hidden', 'priceSetId', $this->_priceSetId
);
382 // build price set form.
383 $this->set('priceSetId', $this->_priceSetId
);
384 CRM_Price_BAO_PriceSet
::buildPriceSet($this);
385 if ($this->_values
['is_monetary'] &&
386 $this->_values
['is_recur'] && empty($this->_values
['pledge_id'])
388 self
::buildRecur($this);
392 if ($this->_priceSetId
) {
393 $is_quick_config = CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId
, 'is_quick_config');
394 if ($is_quick_config) {
395 $this->_useForMember
= 0;
396 $this->set('useForMember', $this->_useForMember
);
400 //we allow premium for pledge during pledge creation only.
401 if (empty($this->_values
['pledge_id'])) {
402 CRM_Contribute_BAO_Premium
::buildPremiumBlock($this, $this->_id
, TRUE);
405 //don't build pledge block when mid is passed
407 $config = CRM_Core_Config
::singleton();
408 if (in_array('CiviPledge', $config->enableComponents
) && !empty($this->_values
['pledge_block_id'])) {
409 CRM_Pledge_BAO_PledgeBlock
::buildPledgeBlock($this);
413 //to create an cms user
414 if (!$this->_contactID
) {
415 $createCMSUser = FALSE;
417 if ($this->_values
['custom_pre_id']) {
418 $profileID = $this->_values
['custom_pre_id'];
419 $createCMSUser = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
422 if (!$createCMSUser &&
423 $this->_values
['custom_post_id']
425 if (!is_array($this->_values
['custom_post_id'])) {
426 $profileIDs = array($this->_values
['custom_post_id']);
429 $profileIDs = $this->_values
['custom_post_id'];
431 foreach ($profileIDs as $pid) {
432 if (CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
434 $createCMSUser = TRUE;
440 if ($createCMSUser) {
441 CRM_Core_BAO_CMSUser
::buildForm($this, $profileID, TRUE);
445 if ($pcpSupporter = CRM_PCP_BAO_PCP
::displayName($this->_pcpId
)) {
446 $pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
447 // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
448 $text = CRM_PCP_BAO_PCP
::getPcpBlockStatus($this->_id
, 'contribute');
450 $pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
452 $this->assign('pcpSupporterText', $pcp_supporter_text);
454 $prms = array('id' => $this->_pcpId
);
455 CRM_Core_DAO
::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
456 if ($pcpInfo['is_honor_roll']) {
457 $this->assign('isHonor', TRUE);
458 $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL,
459 array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );")
461 $extraOption = array('onclick' => "return pcpAnonymous( );");
463 $elements[] = &$this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
464 $elements[] = &$this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
465 $this->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
467 $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
468 $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
471 if (empty($this->_values
['fee'])) {
472 CRM_Core_Error
::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
475 //we have to load confirm contribution button in template
476 //when multiple payment processor as the user
477 //can toggle with payment processor selection
478 $billingModePaymentProcessors = 0;
479 if (!empty($this->_paymentProcessors
)) {
480 foreach ($this->_paymentProcessors
as $key => $values) {
481 if ($values['billing_mode'] == CRM_Core_Payment
::BILLING_MODE_BUTTON
) {
482 $billingModePaymentProcessors++
;
487 if ($billingModePaymentProcessors && count($this->_paymentProcessors
) == $billingModePaymentProcessors) {
488 $allAreBillingModeProcessors = TRUE;
491 $allAreBillingModeProcessors = FALSE;
494 if (!($allAreBillingModeProcessors && !$this->_values
['is_pay_later'])) {
495 $submitButton = array(
497 'name' => CRM_Utils_Array
::value('is_confirm_enabled', $this->_values
) ?
ts('Confirm Contribution') : ts('Contribute'),
498 'spacing' => ' ',
501 // Add submit-once behavior when confirm page disabled
502 if (empty($this->_values
['is_confirm_enabled'])) {
503 $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name
. "','" . ts('Processing') . "');");
505 $this->addButtons(array($submitButton));
508 $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
512 * Build elements to collect information for recurring contributions.
515 * @param CRM_Core_Form $form
517 public static function buildRecur(&$form) {
518 $attributes = CRM_Core_DAO
::getAttribute('CRM_Contribute_DAO_ContributionRecur');
519 $className = get_class($form);
521 $form->assign('is_recur_interval', CRM_Utils_Array
::value('is_recur_interval', $form->_values
));
522 $form->assign('is_recur_installments', CRM_Utils_Array
::value('is_recur_installments', $form->_values
));
524 $form->add('checkbox', 'is_recur', ts('I want to contribute this amount'), NULL);
526 if (!empty($form->_values
['is_recur_interval']) ||
$className == 'CRM_Contribute_Form_Contribution') {
527 $form->add('text', 'frequency_interval', ts('Every'), $attributes['frequency_interval']);
528 $form->addRule('frequency_interval', ts('Frequency must be a whole number (EXAMPLE: Every 3 months).'), 'integer');
531 // make sure frequency_interval is submitted as 1 if given no choice to user.
532 $form->add('hidden', 'frequency_interval', 1);
535 $frUnits = CRM_Utils_Array
::value('recur_frequency_unit', $form->_values
);
536 if (empty($frUnits) &&
537 $className == 'CRM_Contribute_Form_Contribution'
539 $frUnits = implode(CRM_Core_DAO
::VALUE_SEPARATOR
,
540 CRM_Core_OptionGroup
::values('recur_frequency_units')
544 $unitVals = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $frUnits);
546 // CRM 10860, display text instead of a dropdown if there's only 1 frequency unit
547 if (count($unitVals) == 1) {
548 $form->assign('one_frequency_unit', TRUE);
549 $unit = $unitVals[0];
550 $form->add('hidden', 'frequency_unit', $unit);
551 if (!empty($form->_values
['is_recur_interval']) ||
$className == 'CRM_Contribute_Form_Contribution') {
554 $form->assign('frequency_unit', $unit);
557 $form->assign('one_frequency_unit', FALSE);
559 $frequencyUnits = CRM_Core_OptionGroup
::values('recur_frequency_units', FALSE, FALSE, TRUE);
560 foreach ($unitVals as $key => $val) {
561 if (array_key_exists($val, $frequencyUnits)) {
562 $units[$val] = $frequencyUnits[$val];
563 if (!empty($form->_values
['is_recur_interval']) ||
$className == 'CRM_Contribute_Form_Contribution') {
564 $units[$val] = "{$frequencyUnits[$val]}(s)";
568 $frequencyUnit = &$form->add('select', 'frequency_unit', NULL, $units);
571 // FIXME: Ideally we should freeze select box if there is only
572 // one option but looks there is some problem /w QF freeze.
573 //if ( count( $units ) == 1 ) {
574 //$frequencyUnit->freeze( );
577 $form->add('text', 'installments', ts('installments'),
578 $attributes['installments']
580 $form->addRule('installments', ts('Number of installments must be a whole number.'), 'integer');
586 * @param array $fields
587 * The input form values.
588 * @param array $files
589 * The uploaded files if any.
590 * @param CRM_Core_Form $self
593 * true if no errors, else array of errors
595 public static function formRule($fields, $files, $self) {
597 $amount = self
::computeAmount($fields, $self->_values
);
599 if ((!empty($fields['selectMembership']) &&
600 $fields['selectMembership'] != 'no_thanks'
602 (!empty($fields['priceSetId']) &&
606 $lifeMember = CRM_Member_BAO_Membership
::getAllContactMembership($self->_membershipContactID
, FALSE, TRUE);
608 $membershipOrgDetails = CRM_Member_BAO_MembershipType
::getMembershipTypeOrganization();
610 $unallowedOrgs = array();
611 foreach (array_keys($lifeMember) as $memTypeId) {
612 $unallowedOrgs[] = $membershipOrgDetails[$memTypeId];
616 //check for atleast one pricefields should be selected
617 if (!empty($fields['priceSetId'])) {
618 $priceField = new CRM_Price_DAO_PriceField();
619 $priceField->price_set_id
= $fields['priceSetId'];
620 $priceField->orderBy('weight');
624 $membershipIsActive = TRUE;
625 $previousId = $otherAmount = FALSE;
626 while ($priceField->fetch()) {
628 if ($self->_quickConfig
&& ($priceField->name
== 'contribution_amount' ||
$priceField->name
== 'membership_amount')) {
629 $previousId = $priceField->id
;
630 if ($priceField->name
== 'membership_amount' && !$priceField->is_active
) {
631 $membershipIsActive = FALSE;
634 if ($priceField->name
== 'other_amount') {
635 if ($self->_quickConfig
&& empty($fields["price_{$priceField->id}"]) &&
636 array_key_exists("price_{$previousId}", $fields) && isset($fields["price_{$previousId}"]) && $self->_values
['fee'][$previousId]['name'] == 'contribution_amount' && empty($fields["price_{$previousId}"])
638 $otherAmount = $priceField->id
;
640 elseif (!empty($fields["price_{$priceField->id}"])) {
641 $otherAmountVal = CRM_Utils_Rule
::cleanMoney($fields["price_{$priceField->id}"]);
642 $min = CRM_Utils_Array
::value('min_amount', $self->_values
);
643 $max = CRM_Utils_Array
::value('max_amount', $self->_values
);
644 if ($min && $otherAmountVal < $min) {
645 $errors["price_{$priceField->id}"] = ts('Contribution amount must be at least %1',
649 if ($max && $otherAmountVal > $max) {
650 $errors["price_{$priceField->id}"] = ts('Contribution amount cannot be more than %1.',
656 if (!empty($fields["price_{$priceField->id}"]) ||
($previousId == $priceField->id
&& isset($fields["price_{$previousId}"])
657 && empty($fields["price_{$previousId}"]))
659 $check[] = $priceField->id
;
663 $currentMemberships = NULL;
664 if ($membershipIsActive) {
665 $is_test = $self->_mode
!= 'live' ?
1 : 0;
666 $memContactID = $self->_membershipContactID
;
668 // For anonymous user check using dedupe rule
669 // if user has Cancelled Membership
670 if (!$memContactID) {
671 $dedupeParams = CRM_Dedupe_Finder
::formatParams($fields, 'Individual');
672 $dedupeParams['check_permission'] = FALSE;
673 $ids = CRM_Dedupe_Finder
::dupesByParams($dedupeParams, 'Individual');
674 // if we find more than one contact, use the first one
675 $memContactID = CRM_Utils_Array
::value(0, $ids);
677 $currentMemberships = CRM_Member_BAO_Membership
::getContactsCancelledMembership($memContactID,
681 $errorText = 'Your %1 membership was previously cancelled and can not be renewed online. Please contact the site administrator for assistance.';
682 foreach ($self->_values
['fee'] as $fieldKey => $fieldValue) {
683 if ($fieldValue['html_type'] != 'Text' && CRM_Utils_Array
::value('price_' . $fieldKey, $fields)) {
684 if (!is_array($fields['price_' . $fieldKey])) {
685 if (array_key_exists('membership_type_id', $fieldValue['options'][$fields['price_' . $fieldKey]])
686 && in_array($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id'], $currentMemberships)
688 $errors['price_' . $fieldKey] = ts($errorText, array(1 => CRM_Member_PseudoConstant
::membershipType($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id'])));
692 foreach ($fields['price_' . $fieldKey] as $key => $ignore) {
693 if (array_key_exists('membership_type_id', $fieldValue['options'][$key])
694 && in_array($fieldValue['options'][$key]['membership_type_id'], $currentMemberships)
696 $errors['price_' . $fieldKey] = ts($errorText, array(1 => CRM_Member_PseudoConstant
::membershipType($fieldValue['options'][$key]['membership_type_id'])));
705 if ($membershipIsActive && !$self->_membershipBlock
['is_required']
706 && $self->_values
['amount_block_is_active']
708 $membershipFieldId = $contributionFieldId = $errorKey = $otherFieldId = NULL;
709 foreach ($self->_values
['fee'] as $fieldKey => $fieldValue) {
710 // if 'No thank you' membership is selected then set $membershipFieldId
711 if ($fieldValue['name'] == 'membership_amount' && CRM_Utils_Array
::value('price_' . $fieldKey, $fields) == 0) {
712 $membershipFieldId = $fieldKey;
714 elseif ($membershipFieldId) {
715 if ($fieldValue['name'] == 'other_amount') {
716 $otherFieldId = $fieldKey;
718 elseif ($fieldValue['name'] == 'contribution_amount') {
719 $contributionFieldId = $fieldKey;
722 if (!$errorKey || CRM_Utils_Array
::value('price_' . $contributionFieldId, $fields) == '0') {
723 $errorKey = $fieldKey;
727 // $membershipFieldId is set and additional amount is 'No thank you' or NULL then throw error
728 if ($membershipFieldId && !(CRM_Utils_Array
::value('price_' . $contributionFieldId, $fields, -1) > 0) && empty($fields['price_' . $otherFieldId])) {
729 $errors["price_{$errorKey}"] = ts('Additional Contribution is required.');
733 if ($self->_useForMember
== 1 && $membershipIsActive) {
734 $errors['_qf_default'] = ts('Select at least one option from Membership Type(s).');
737 $errors['_qf_default'] = ts('Select at least one option from Contribution(s).');
740 if ($otherAmount && !empty($check)) {
741 $errors["price_{$otherAmount}"] = ts('Amount is required field.');
744 if ($self->_useForMember
== 1 && !empty($check) && $membershipIsActive) {
745 $priceFieldIDS = array();
746 $priceFieldMemTypes = array();
748 foreach ($self->_priceSet
['fields'] as $priceId => $value) {
749 if (!empty($fields['price_' . $priceId]) ||
($self->_quickConfig
&& $value['name'] == 'membership_amount' && empty($self->_membershipBlock
['is_required']))) {
750 if (!empty($fields['price_' . $priceId]) && is_array($fields['price_' . $priceId])) {
751 foreach ($fields['price_' . $priceId] as $priceFldVal => $isSet) {
753 $priceFieldIDS[] = $priceFldVal;
757 elseif (!$value['is_enter_qty'] && !empty($fields['price_' . $priceId])) {
758 // The check for {!$value['is_enter_qty']} is done since, quantity fields allow entering
759 // quantity. And the quantity can't be conisdered as civicrm_price_field_value.id, CRM-9577
760 $priceFieldIDS[] = $fields['price_' . $priceId];
763 if (!empty($value['options'])) {
764 foreach ($value['options'] as $val) {
765 if (!empty($val['membership_type_id']) && (
766 ($fields['price_' . $priceId] == $val['id']) ||
767 (isset($fields['price_' . $priceId]) && !empty($fields['price_' . $priceId][$val['id']]))
770 $priceFieldMemTypes[] = $val['membership_type_id'];
777 if (!empty($lifeMember)) {
778 foreach ($priceFieldIDS as $priceFieldId) {
779 if (($id = CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) &&
780 in_array($membershipOrgDetails[$id], $unallowedOrgs)
782 $errors['_qf_default'] = ts('You already have a lifetime membership and cannot select a membership with a shorter term.');
788 if (!empty($priceFieldIDS)) {
789 $ids = implode(',', $priceFieldIDS);
791 $priceFieldIDS['id'] = $fields['priceSetId'];
792 $self->set('memberPriceFieldIDS', $priceFieldIDS);
793 $count = CRM_Price_BAO_PriceSet
::getMembershipCount($ids);
794 foreach ($count as $id => $occurrence) {
795 if ($occurrence > 1) {
796 $errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity. Contact the site administrator if you need assistance.');
801 if (empty($priceFieldMemTypes)) {
802 $errors['_qf_default'] = ts('Please select at least one membership option.');
806 CRM_Price_BAO_PriceSet
::processAmount($self->_values
['fee'],
810 if ($fields['amount'] < 0) {
811 $errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly');
813 $amount = $fields['amount'];
816 if (isset($fields['selectProduct']) &&
817 $fields['selectProduct'] != 'no_thanks'
819 $productDAO = new CRM_Contribute_DAO_Product();
820 $productDAO->id
= $fields['selectProduct'];
821 $productDAO->find(TRUE);
822 $min_amount = $productDAO->min_contribution
;
824 if ($amount < $min_amount) {
825 $errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money
::format($min_amount)));
826 CRM_Core_Session
::setStatus($errors['selectProduct']);
830 //CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
831 CRM_Contribute_BAO_ContributionRecur
::validateRecurContribution($fields, $files, $self, $errors);
833 if (!empty($fields['is_recur']) &&
834 CRM_Utils_Array
::value('payment_processor_id', $fields) == 0
836 $errors['_qf_default'] = ts('You cannot set up a recurring contribution if you are not paying online by credit card.');
839 // validate PCP fields - if not anonymous, we need a nick name value
840 if ($self->_pcpId
&& !empty($fields['pcp_display_in_roll']) &&
841 (CRM_Utils_Array
::value('pcp_is_anonymous', $fields) == 0) &&
842 CRM_Utils_Array
::value('pcp_roll_nickname', $fields) == ''
844 $errors['pcp_roll_nickname'] = ts('Please enter a name to include in the Honor Roll, or select \'contribute anonymously\'.');
847 // return if this is express mode
848 $config = CRM_Core_Config
::singleton();
849 if ($self->_paymentProcessor
&&
850 $self->_paymentProcessor
['billing_mode'] & CRM_Core_Payment
::BILLING_MODE_BUTTON
852 if (!empty($fields[$self->_expressButtonName
. '_x']) ||
!empty($fields[$self->_expressButtonName
. '_y']) ||
853 CRM_Utils_Array
::value($self->_expressButtonName
, $fields)
859 //validate the pledge fields.
860 if (!empty($self->_values
['pledge_block_id'])) {
861 //validation for pledge payment.
862 if (!empty($self->_values
['pledge_id'])) {
863 if (empty($fields['pledge_amount'])) {
864 $errors['pledge_amount'] = ts('At least one payment option needs to be checked.');
867 elseif (!empty($fields['is_pledge'])) {
868 if (CRM_Utils_Rule
::positiveInteger(CRM_Utils_Array
::value('pledge_installments', $fields)) == FALSE) {
869 $errors['pledge_installments'] = ts('Please enter a valid number of pledge installments.');
872 if (CRM_Utils_Array
::value('pledge_installments', $fields) == NULL) {
873 $errors['pledge_installments'] = ts('Pledge Installments is required field.');
875 elseif (CRM_Utils_array
::value('pledge_installments', $fields) == 1) {
876 $errors['pledge_installments'] = ts('Pledges consist of multiple scheduled payments. Select one-time contribution if you want to make your gift in a single payment.');
878 elseif (CRM_Utils_array
::value('pledge_installments', $fields) == 0) {
879 $errors['pledge_installments'] = ts('Pledge Installments field must be > 1.');
883 //validation for Pledge Frequency Interval.
884 if (CRM_Utils_Rule
::positiveInteger(CRM_Utils_Array
::value('pledge_frequency_interval', $fields)) == FALSE) {
885 $errors['pledge_frequency_interval'] = ts('Please enter a valid Pledge Frequency Interval.');
888 if (CRM_Utils_Array
::value('pledge_frequency_interval', $fields) == NULL) {
889 $errors['pledge_frequency_interval'] = ts('Pledge Frequency Interval. is required field.');
891 elseif (CRM_Utils_array
::value('pledge_frequency_interval', $fields) == 0) {
892 $errors['pledge_frequency_interval'] = ts('Pledge frequency interval field must be > 0');
898 // if the user has chosen a free membership or the amount is less than zero
899 // i.e. we don't need to validate payment related fields or profiles.
900 if ((float) $amount <= 0.0) {
904 CRM_Core_Payment_Form
::validatePaymentInstrument(
905 $fields['payment_processor_id'],
908 (!$self->_isBillingAddressRequiredForPayLater ?
NULL : 'billing')
911 foreach (CRM_Contact_BAO_Contact
::$_greetingTypes as $greeting) {
912 if ($greetingType = CRM_Utils_Array
::value($greeting, $fields)) {
913 $customizedValue = CRM_Core_OptionGroup
::getValue($greeting, 'Customized', 'name');
914 if ($customizedValue == $greetingType && empty($fielse[$greeting . '_custom'])) {
915 $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.',
916 array(1 => ucwords(str_replace('_', " ", $greeting)))
922 return empty($errors) ?
TRUE : $errors;
926 * Compute amount to be paid.
928 * @param array $params
929 * @param array $formValues
931 * @return int|mixed|null|string
933 public static function computeAmount($params, $formValues) {
935 // First clean up the other amount field if present.
936 if (isset($params['amount_other'])) {
937 $params['amount_other'] = CRM_Utils_Rule
::cleanMoney($params['amount_other']);
940 if (CRM_Utils_Array
::value('amount', $params) == 'amount_other_radio' ||
!empty($params['amount_other'])) {
941 $amount = $params['amount_other'];
943 elseif (!empty($params['pledge_amount'])) {
944 foreach ($params['pledge_amount'] as $paymentId => $dontCare) {
945 $amount +
= CRM_Core_DAO
::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount');
949 if (!empty($formValues['amount'])) {
950 $amountID = CRM_Utils_Array
::value('amount', $params);
953 // @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
954 // function to get correct amount level consistently. Remove setting of the amount level in
955 // CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
956 // to cover all variants.
957 $params['amount_level'] = CRM_Utils_Array
::value('label', $formValues[$amountID]);
958 $amount = CRM_Utils_Array
::value('value', $formValues[$amountID]);
966 * Process the form submission.
968 public function postProcess() {
969 // we first reset the confirm page so it accepts new values
970 $this->controller
->resetPage('Confirm');
972 // get the submitted form values.
973 $params = $this->controller
->exportValues($this->_name
);
974 $this->submit($params);
976 if (empty($this->_values
['is_confirm_enabled'])) {
977 $this->skipToThankYouPage();
985 * This is the guts of the postProcess made also accessible to the test suite.
987 * @param array $params
990 public function submit($params) {
991 //carry campaign from profile.
992 if (array_key_exists('contribution_campaign_id', $params)) {
993 $params['campaign_id'] = $params['contribution_campaign_id'];
996 $params['currencyID'] = CRM_Core_Config
::singleton()->defaultCurrency
;
998 if (!empty($params['priceSetId'])) {
999 $is_quick_config = CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId
, 'is_quick_config');
1000 if ($is_quick_config) {
1001 $priceField = new CRM_Price_DAO_PriceField();
1002 $priceField->price_set_id
= $params['priceSetId'];
1003 $priceField->orderBy('weight');
1004 $priceField->find();
1006 $priceOptions = array();
1007 while ($priceField->fetch()) {
1008 CRM_Price_BAO_PriceFieldValue
::getValues($priceField->id
, $priceOptions);
1009 if ($selectedPriceOptionID = CRM_Utils_Array
::value("price_{$priceField->id}", $params)) {
1010 switch ($priceField->name
) {
1011 case 'membership_amount':
1012 $this->_params
['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array
::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
1013 $this->set('selectMembership', $params['selectMembership']);
1014 if (CRM_Utils_Array
::value('is_separate_payment', $this->_membershipBlock
) == 0) {
1015 $this->_values
['amount'] = CRM_Utils_Array
::value('amount', $priceOptions[$selectedPriceOptionID]);
1019 case 'contribution_amount':
1020 $params['amount'] = $selectedPriceOptionID;
1021 $this->_values
['amount'] = CRM_Utils_Array
::value('amount', $priceOptions[$selectedPriceOptionID]);
1022 $this->_values
[$selectedPriceOptionID]['value'] = CRM_Utils_Array
::value('amount', $priceOptions[$selectedPriceOptionID]);
1023 $this->_values
[$selectedPriceOptionID]['label'] = CRM_Utils_Array
::value('label', $priceOptions[$selectedPriceOptionID]);
1024 $this->_values
[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array
::value('id', $priceOptions[$selectedPriceOptionID]);
1025 $this->_values
[$selectedPriceOptionID]['weight'] = CRM_Utils_Array
::value('weight', $priceOptions[$selectedPriceOptionID]);
1028 case 'other_amount':
1029 $params['amount_other'] = $selectedPriceOptionID;
1037 if (($this->_values
['is_pay_later'] &&
1038 empty($this->_paymentProcessor
) &&
1039 !array_key_exists('hidden_processor', $params)) ||
1040 (!empty($params['payment_processor_id']) && $params['payment_processor_id'] == 0)
1042 $params['is_pay_later'] = 1;
1045 $params['is_pay_later'] = 0;
1048 // Would be nice to someday understand the point of this set.
1049 $this->set('is_pay_later', $params['is_pay_later']);
1050 // assign pay later stuff
1051 $this->_params
['is_pay_later'] = CRM_Utils_Array
::value('is_pay_later', $params, FALSE);
1052 $this->assign('is_pay_later', $params['is_pay_later']);
1053 if ($params['is_pay_later']) {
1054 $this->assign('pay_later_text', $this->_values
['pay_later_text']);
1055 $this->assign('pay_later_receipt', $this->_values
['pay_later_receipt']);
1058 // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
1059 $params['amount'] = self
::computeAmount($params, $this->_values
);
1060 $params['separate_amount'] = $params['amount'];
1062 if (!empty($params['selectMembership'])) {
1063 if (empty($this->_membershipTypeValues
)) {
1064 $this->_membershipTypeValues
= CRM_Member_BAO_Membership
::buildMembershipTypeValues($this,
1065 (array) $params['selectMembership']
1068 $membershipTypeValues = $this->_membershipTypeValues
[$params['selectMembership']];
1069 $memFee = $membershipTypeValues['minimum_fee'];
1070 if (!$params['amount'] && !$this->_separateMembershipPayment
) {
1071 $params['amount'] = $memFee ?
$memFee : 0;
1074 //If the membership & contribution is used in contribution page & not separate payment
1075 $fieldId = $memPresent = $membershipLabel = $fieldOption = $is_quick_config = NULL;
1076 $proceFieldAmount = 0;
1077 if (property_exists($this, '_separateMembershipPayment') && $this->_separateMembershipPayment
== 0) {
1078 $is_quick_config = CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId
, 'is_quick_config');
1079 if ($is_quick_config) {
1080 foreach ($this->_priceSet
['fields'] as $fieldKey => $fieldVal) {
1081 if ($fieldVal['name'] == 'membership_amount' && !empty($params['price_' . $fieldKey])) {
1082 $fieldId = $fieldVal['id'];
1083 $fieldOption = $params['price_' . $fieldId];
1084 $proceFieldAmount +
= $fieldVal['options'][$this->_submitValues
['price_' . $fieldId]]['amount'];
1088 if (!empty($params['price_' . $fieldKey]) && $memPresent && ($fieldVal['name'] == 'other_amount' ||
$fieldVal['name'] == 'contribution_amount')) {
1089 $fieldId = $fieldVal['id'];
1090 if ($fieldVal['name'] == 'other_amount') {
1091 $proceFieldAmount +
= $this->_submitValues
['price_' . $fieldId];
1093 elseif ($fieldVal['name'] == 'contribution_amount' && $this->_submitValues
['price_' . $fieldId] > 0) {
1094 $proceFieldAmount +
= $fieldVal['options'][$this->_submitValues
['price_' . $fieldId]]['amount'];
1096 unset($params['price_' . $fieldId]);
1104 if (!isset($params['amount_other'])) {
1105 $this->set('amount_level', CRM_Utils_Array
::value('amount_level', $params));
1108 if ($priceSetId = CRM_Utils_Array
::value('priceSetId', $params)) {
1109 $lineItem = array();
1110 $is_quick_config = CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
1111 if ($is_quick_config) {
1112 foreach ($this->_values
['fee'] as $key => & $val) {
1113 if ($val['name'] == 'other_amount' && $val['html_type'] == 'Text' && !empty($params['price_' . $key])) {
1114 // Clean out any currency symbols.
1115 $params['price_' . $key] = CRM_Utils_Rule
::cleanMoney($params['price_' . $key]);
1116 if ($params['price_' . $key] != 0) {
1117 foreach ($val['options'] as $optionKey => & $options) {
1118 $options['amount'] = CRM_Utils_Array
::value('price_' . $key, $params);
1122 $params['price_' . $key] = 1;
1128 if ($this->_membershipBlock
) {
1129 $component = 'membership';
1132 CRM_Price_BAO_PriceSet
::processAmount($this->_values
['fee'], $params, $lineItem[$priceSetId], $component);
1133 if ($params['tax_amount']) {
1134 $this->set('tax_amount', $params['tax_amount']);
1137 if ($proceFieldAmount) {
1138 $lineItem[$params['priceSetId']][$fieldOption]['unit_price'] = $proceFieldAmount;
1139 $lineItem[$params['priceSetId']][$fieldOption]['line_total'] = $proceFieldAmount;
1140 if (isset($lineItem[$params['priceSetId']][$fieldOption]['tax_amount'])) {
1141 $proceFieldAmount +
= $lineItem[$params['priceSetId']][$fieldOption]['tax_amount'];
1143 if (!$this->_membershipBlock
['is_separate_payment']) {
1144 //require when separate membership not used
1145 $params['amount'] = $proceFieldAmount;
1148 $this->set('lineItem', $lineItem);
1151 if ($this->_membershipBlock
['is_separate_payment'] && !empty($params['separate_amount'])) {
1152 $this->set('amount', $params['separate_amount']);
1155 $this->set('amount', $params['amount']);
1158 // generate and set an invoiceID for this transaction
1159 $invoiceID = md5(uniqid(rand(), TRUE));
1160 $this->set('invoiceID', $invoiceID);
1161 $params['invoiceID'] = $invoiceID;
1162 $params['description'] = ts('Online Contribution') . ': ' . ((!empty($this->_pcpInfo
['title']) ?
$this->_pcpInfo
['title'] : $this->_values
['title']));
1163 $params['button'] = $this->controller
->getButtonName();
1164 // required only if is_monetary and valid positive amount
1165 // @todo it seems impossible for $memFee to be greater than 0 & $params['amount'] not to
1166 // be & by requiring $memFee down here we make it harder to do a sensible refactoring of the function
1167 // above (ie. extract the amount in a small function).
1168 if ($this->_values
['is_monetary'] &&
1169 !empty($this->_paymentProcessor
) &&
1170 ((float ) $params['amount'] > 0.0 ||
$memFee > 0.0)
1172 // The concept of contributeMode is deprecated - as should be the 'is_monetary' setting.
1173 $this->setContributeMode();
1174 // Really this setting of $this->_params & params within it should be done earlier on in the function
1175 // probably the values determined here should be reused in confirm postProcess as there is no opportunity to alter anything
1176 // on the confirm page. However as we are dealing with a stable release we go as close to where it is used
1178 // In general the form has a lack of clarity of the logic of why things are set on the form in some cases &
1179 // the logic around when $this->_params is used compared to other params arrays.
1180 $this->_params
= array_merge($params, $this->_params
);
1181 $this->setRecurringMembershipParams();
1182 if ($this->_paymentProcessor
&&
1183 $this->_paymentProcessor
['object']->supports('preApproval')
1185 $this->handlePreApproval($this->_params
);
1191 * Assign the billing mode to the template.
1193 * This is required for legacy support for contributeMode in templates.
1195 * The goal is to remove this parameter & use more relevant parameters.
1197 protected function setContributeMode() {
1198 switch ($this->_paymentProcessor
['billing_mode']) {
1199 case CRM_Core_Payment
::BILLING_MODE_FORM
:
1200 $this->set('contributeMode', 'direct');
1203 case CRM_Core_Payment
::BILLING_MODE_BUTTON
:
1204 $this->set('contributeMode', 'express');
1207 case CRM_Core_Payment
::BILLING_MODE_NOTIFY
:
1208 $this->set('contributeMode', 'notify');
1215 * Process confirm function and pass browser to the thank you page.
1217 protected function skipToThankYouPage() {
1218 // call the post process hook for the main page before we switch to confirm
1219 $this->postProcessHook();
1221 // build the confirm page
1222 $confirmForm = &$this->controller
->_pages
['Confirm'];
1223 $confirmForm->preProcess();
1224 $confirmForm->buildQuickForm();
1226 // the confirmation page is valid
1227 $data = &$this->controller
->container();
1228 $data['valid']['Confirm'] = 1;
1230 // confirm the contribution
1231 // mainProcess calls the hook also
1232 $confirmForm->mainProcess();
1233 $qfKey = $this->controller
->_key
;
1235 // redirect to thank you page
1236 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey=$qfKey", TRUE, NULL, FALSE));
1240 * Function for unit tests on the postProcess function.
1242 * @param array $params
1244 public function testSubmit($params) {
1245 $_SERVER['REQUEST_METHOD'] = 'GET';
1246 $this->controller
= new CRM_Contribute_Controller_Contribution();
1247 $this->submit($params);