3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * This class generates form components for processing a ontribution
40 class CRM_Contribute_Form_ContributionBase
extends CRM_Core_Form
{
43 * the id of the contribution page that we are proceessing
51 * the mode that we are in
59 * the contact id related to a membership
64 public $_membershipContactID;
67 * the values for the contribution db object
75 * the paymentProcessor attributes for this page
80 public $_paymentProcessor;
81 public $_paymentObject = NULL;
84 * The membership block for this page
89 public $_membershipBlock = NULL;
92 * the default values for the form
100 * The params submitted by the form and computed by the app
108 * The fields involved in this contribution page
116 * The billing location id for this contribiution page
124 * Cache the amount to make things easier
156 * The contact id of the person for whom membership is being added or renewed based on the cid in the url,
157 * checksum, or session
160 protected $_contactID;
165 * the Membership ID for membership renewal
170 public $_membershipId;
173 * Price Set ID, if the new price set method is used
181 * Array of fields for the price set
191 * Function to set variables up before form is built
196 public function preProcess() {
197 $config = CRM_Core_Config
::singleton();
198 $session = CRM_Core_Session
::singleton();
200 // current contribution page id
201 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
203 // seems like the session is corrupted and/or we lost the id trail
204 // lets just bump this to a regular session error and redirect user to main page
205 $this->controller
->invalidKeyRedirect();
208 // this was used prior to the cleverer this_>getContactID - unsure now
209 $this->_userID
= $session->get('userID');
211 $this->_contactID
= $this->_membershipContactID
= $this->getContactID();
213 if ($this->_contactID
) {
214 $this->_mid
= CRM_Utils_Request
::retrieve('mid', 'Positive', $this);
216 $membership = new CRM_Member_DAO_Membership();
217 $membership->id
= $this->_mid
;
219 if ($membership->find(TRUE)) {
220 $this->_defaultMemTypeId
= $membership->membership_type_id
;
221 if ($membership->contact_id
!= $this->_contactID
) {
222 $validMembership = FALSE;
223 $employers = CRM_Contact_BAO_Relationship
::getPermissionedEmployer($this->_userID
);
224 if (!empty($employers) && array_key_exists($membership->contact_id
, $employers)) {
225 $this->_membershipContactID
= $membership->contact_id
;
226 $this->assign('membershipContactID', $this->_membershipContactID
);
227 $this->assign('membershipContactName', $employers[$this->_membershipContactID
]['name']);
228 $validMembership = TRUE;
230 $membershipType = new CRM_Member_BAO_MembershipType();
231 $membershipType->id
= $membership->membership_type_id
;
232 if ($membershipType->find(TRUE)) {
233 // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
234 // Convert to commma separated list.
235 $inheritedRelTypes = implode(CRM_Utils_Array
::explodePadded($membershipType->relationship_type_id
), ',');
236 $permContacts = CRM_Contact_BAO_Relationship
::getPermissionedContacts($this->_userID
, $membershipType->relationship_type_id
);
237 if (array_key_exists($membership->contact_id
, $permContacts)) {
238 $this->_membershipContactID
= $membership->contact_id
;
239 $validMembership = TRUE;
243 if (!$validMembership) {
244 CRM_Core_Session
::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
249 CRM_Core_Session
::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
255 // we do not want to display recently viewed items, so turn off
256 $this->assign('displayRecent', FALSE);
257 // Contribution page values are cleared from session, so can't use normal Printer Friendly view.
258 // Use Browser Print instead.
259 $this->assign('browserPrint', TRUE);
262 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'add');
263 $this->assign('action', $this->_action
);
266 $this->_mode
= ($this->_action
== 1024) ?
'test' : 'live';
268 $this->_values
= $this->get('values');
269 $this->_fields
= $this->get('fields');
270 $this->_bltID
= $this->get('bltID');
271 $this->_paymentProcessor
= $this->get('paymentProcessor');
272 $this->_priceSetId
= $this->get('priceSetId');
273 $this->_priceSet
= $this->get('priceSet');
275 if (!$this->_values
) {
276 // get all the values from the dao object
277 $this->_values
= array();
278 $this->_fields
= array();
280 CRM_Contribute_BAO_ContributionPage
::setValues($this->_id
, $this->_values
);
282 // check if form is active
283 if (!CRM_Utils_Array
::value('is_active', $this->_values
)) {
284 // form is inactive, die a fatal death
285 CRM_Core_Error
::fatal(ts('The page you requested is currently unavailable.'));
288 // also check for billing informatin
289 // get the billing location type
290 $locationTypes = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
291 // CRM-8108 remove ts around Billing location type
292 //$this->_bltID = array_search( ts('Billing'), $locationTypes );
293 $this->_bltID
= array_search('Billing', $locationTypes);
294 if (!$this->_bltID
) {
295 CRM_Core_Error
::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
297 $this->set('bltID', $this->_bltID
);
299 // check for is_monetary status
300 $isMonetary = CRM_Utils_Array
::value('is_monetary', $this->_values
);
301 $isPayLater = CRM_Utils_Array
::value('is_pay_later', $this->_values
);
303 //FIXME: to support multiple payment processors
305 (!$isPayLater || CRM_Utils_Array
::value('payment_processor', $this->_values
))
307 $ppID = CRM_Utils_Array
::value('payment_processor', $this->_values
);
309 CRM_Core_Error
::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
312 $ppIds = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $ppID);
313 $this->_paymentProcessors
= CRM_Financial_BAO_PaymentProcessor
::getPayments($ppIds, $this->_mode
);
315 $this->set('paymentProcessors', $this->_paymentProcessors
);
317 //set default payment processor
318 if (!empty($this->_paymentProcessors
) && empty($this->_paymentProcessor
)) {
319 foreach ($this->_paymentProcessors
as $ppId => $values) {
320 if ($values['is_default'] == 1 ||
(count($this->_paymentProcessors
) == 1)) {
321 $defaultProcessorId = $ppId;
327 if (isset($defaultProcessorId)) {
328 $this->_paymentProcessor
= CRM_Financial_BAO_PaymentProcessor
::getPayment($defaultProcessorId, $this->_mode
);
329 $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor
);
332 if (!CRM_Utils_System
::isNull($this->_paymentProcessors
)) {
333 foreach ($this->_paymentProcessors
as $eachPaymentProcessor) {
334 // check selected payment processor is active
335 if (empty($eachPaymentProcessor)) {
336 CRM_Core_Error
::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
339 // ensure that processor has a valid config
340 $this->_paymentObject
= &CRM_Core_Payment
::singleton($this->_mode
, $eachPaymentProcessor, $this);
341 $error = $this->_paymentObject
->checkConfig();
342 if (!empty($error)) {
343 CRM_Core_Error
::fatal($error);
351 CRM_Price_BAO_PriceSet
::initSet($this, $this->_id
, 'civicrm_contribution_page');
353 // this avoids getting E_NOTICE errors in php
354 $setNullFields = array(
355 'amount_block_is_active',
356 'honor_block_is_active',
357 'is_allow_other_amount',
360 foreach ($setNullFields as $f) {
361 if (!isset($this->_values
[$f])) {
362 $this->_values
[$f] = NULL;
366 //check if Membership Block is enabled, if Membership Fields are included in profile
367 //get membership section for this contribution page
368 $this->_membershipBlock
= CRM_Member_BAO_Membership
::getMembershipBlock($this->_id
);
369 $this->set('membershipBlock', $this->_membershipBlock
);
371 if ($this->_values
['custom_pre_id']) {
372 $preProfileType = CRM_Core_BAO_UFField
::getProfileType($this->_values
['custom_pre_id']);
375 if ($this->_values
['custom_post_id']) {
376 $postProfileType = CRM_Core_BAO_UFField
::getProfileType($this->_values
['custom_post_id']);
379 if (((isset($postProfileType) && $postProfileType == 'Membership') ||
380 (isset($preProfileType) && $preProfileType == 'Membership')
382 !$this->_membershipBlock
['is_active']
384 CRM_Core_Error
::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
387 $pledgeBlock = CRM_Pledge_BAO_PledgeBlock
::getPledgeBlock($this->_id
);
390 $this->_values
['pledge_block_id'] = CRM_Utils_Array
::value('id', $pledgeBlock);
391 $this->_values
['max_reminders'] = CRM_Utils_Array
::value('max_reminders', $pledgeBlock);
392 $this->_values
['initial_reminder_day'] = CRM_Utils_Array
::value('initial_reminder_day', $pledgeBlock);
393 $this->_values
['additional_reminder_day'] = CRM_Utils_Array
::value('additional_reminder_day', $pledgeBlock);
395 //set pledge id in values
396 $pledgeId = CRM_Utils_Request
::retrieve('pledgeId', 'Positive', $this);
398 //authenticate pledge user for pledge payment.
400 $this->_values
['pledge_id'] = $pledgeId;
402 //lets override w/ pledge campaign.
403 $this->_values
['campaign_id'] = CRM_Core_DAO
::getFieldValue('CRM_Pledge_DAO_Pledge',
407 self
::authenticatePledgeUser();
410 $this->set('values', $this->_values
);
411 $this->set('fields', $this->_fields
);
415 $pcpId = CRM_Utils_Request
::retrieve('pcpId', 'Positive', $this);
417 $pcp = CRM_PCP_BAO_PCP
::handlePcp($pcpId, 'contribute', $this->_values
);
418 $this->_pcpId
= $pcp['pcpId'];
419 $this->_pcpBlock
= $pcp['pcpBlock'];
420 $this->_pcpInfo
= $pcp['pcpInfo'];
423 // Link (button) for users to create their own Personal Campaign page
424 if ($linkText = CRM_PCP_BAO_PCP
::getPcpBlockStatus($this->_id
, 'contribute')) {
425 $linkTextUrl = CRM_Utils_System
::url('civicrm/contribute/campaign',
426 "action=add&reset=1&pageId={$this->_id}&component=contribute",
429 $this->assign('linkTextUrl', $linkTextUrl);
430 $this->assign('linkText', $linkText);
433 //set pledge block if block id is set
434 if (CRM_Utils_Array
::value('pledge_block_id', $this->_values
)) {
435 $this->assign('pledgeBlock', TRUE);
438 // check if one of the (amount , membership) bloks is active or not
439 $this->_membershipBlock
= $this->get('membershipBlock');
441 if (!$this->_values
['amount_block_is_active'] &&
442 !$this->_membershipBlock
['is_active'] &&
445 CRM_Core_Error
::fatal(ts('The requested online contribution page is missing a required Contribution Amount section or Membership section or Price Set. Please check with the site administrator for assistance.'));
448 if ($this->_values
['amount_block_is_active']) {
449 $this->set('amount_block_is_active', $this->_values
['amount_block_is_active']);
452 $this->_contributeMode
= $this->get('contributeMode');
453 $this->assign('contributeMode', $this->_contributeMode
);
455 //assigning is_monetary and is_email_receipt to template
456 $this->assign('is_monetary', $this->_values
['is_monetary']);
457 $this->assign('is_email_receipt', $this->_values
['is_email_receipt']);
458 $this->assign('bltID', $this->_bltID
);
460 //assign cancelSubscription URL to templates
461 $this->assign('cancelSubscriptionUrl',
462 CRM_Utils_Array
::value('cancelSubscriptionUrl', $this->_values
)
465 // assigning title to template in case someone wants to use it, also setting CMS page title
467 $this->assign('title', $this->_pcpInfo
['title']);
468 CRM_Utils_System
::setTitle($this->_pcpInfo
['title']);
471 $this->assign('title', $this->_values
['title']);
472 CRM_Utils_System
::setTitle($this->_values
['title']);
474 $this->_defaults
= array();
476 $this->_amount
= $this->get('amount');
479 $config = CRM_Core_Config
::singleton();
480 $config->defaultCurrency
= CRM_Utils_Array
::value('currency',
482 $config->defaultCurrency
485 //lets allow user to override campaign.
486 $campID = CRM_Utils_Request
::retrieve('campID', 'Positive', $this);
487 if ($campID && CRM_Core_DAO
::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
488 $this->_values
['campaign_id'] = $campID;
491 //do check for cancel recurring and clean db, CRM-7696
492 if (CRM_Utils_Request
::retrieve('cancel', 'Boolean', CRM_Core_DAO
::$_nullObject)) {
493 self
::cancelRecurring();
498 * set the default values
503 function setDefaultValues() {
504 return $this->_defaults
;
508 * assign the minimal set of variables to the template
513 function assignToTemplate() {
514 $name = CRM_Utils_Array
::value('billing_first_name', $this->_params
);
515 if (CRM_Utils_Array
::value('billing_middle_name', $this->_params
)) {
516 $name .= " {$this->_params['billing_middle_name']}";
518 $name .= ' ' . CRM_Utils_Array
::value('billing_last_name', $this->_params
);
520 $this->assign('billingName', $name);
521 $this->set('name', $name);
523 $this->assign('paymentProcessor', $this->_paymentProcessor
);
525 'amount', 'currencyID',
526 'credit_card_type', 'trxn_id', 'amount_level',
529 $config = CRM_Core_Config
::singleton();
530 if (isset($this->_values
['is_recur']) &&
531 CRM_Utils_Array
::value('is_recur', $this->_paymentProcessor
)
533 $this->assign('is_recur_enabled', 1);
534 $vars = array_merge($vars, array(
535 'is_recur', 'frequency_interval', 'frequency_unit',
540 if (in_array('CiviPledge', $config->enableComponents
) &&
541 CRM_Utils_Array
::value('is_pledge', $this->_params
) == 1
543 $this->assign('pledge_enabled', 1);
545 $vars = array_merge($vars, array(
547 'pledge_frequency_interval',
548 'pledge_frequency_unit',
549 'pledge_installments',
553 if (isset($this->_params
['amount_other']) ||
isset($this->_params
['selectMembership'])) {
554 $this->_params
['amount_level'] = '';
557 foreach ($vars as $v) {
558 if (isset($this->_params
[$v])) {
559 if ($v == 'frequency_unit' ||
$v == 'pledge_frequency_unit') {
560 $frequencyUnits = CRM_Core_OptionGroup
::values('recur_frequency_units');
561 if (array_key_exists($this->_params
[$v], $frequencyUnits)) {
562 $this->_params
[$v] = $frequencyUnits[$this->_params
[$v]];
565 if ($v == "amount" && $this->_params
[$v] === 0) {
566 $this->_params
[$v] = CRM_Utils_Money
::format($this->_params
[$v], NULL, NULL, TRUE);
568 $this->assign($v, $this->_params
[$v]);
572 // assign the address formatted up for display
573 $addressParts = array(
574 "street_address-{$this->_bltID}",
575 "city-{$this->_bltID}",
576 "postal_code-{$this->_bltID}",
577 "state_province-{$this->_bltID}",
578 "country-{$this->_bltID}",
581 $addressFields = array();
582 foreach ($addressParts as $part) {
583 list($n, $id) = explode('-', $part);
584 $addressFields[$n] = CRM_Utils_Array
::value('billing_' . $part, $this->_params
);
587 $this->assign('address', CRM_Utils_Address
::format($addressFields));
589 if (CRM_Utils_Array
::value('hidden_onbehalf_profile', $this->_params
)) {
590 $this->assign('onBehalfName', $this->_params
['organization_name']);
591 $locTypeId = array_keys($this->_params
['onbehalf_location']['email']);
592 $this->assign('onBehalfEmail', $this->_params
['onbehalf_location']['email'][$locTypeId[0]]['email']);
596 $assignCCInfo = FALSE;
597 if ($this->_amount
> 0.0) {
598 $assignCCInfo = TRUE;
600 elseif (CRM_Utils_array
::value('selectMembership', $this->_params
)) {
601 $memFee = CRM_Core_DAO
::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params
['selectMembership'], 'minimum_fee');
603 $assignCCInfo = TRUE;
607 if ($this->_contributeMode
== 'direct' && $assignCCInfo) {
608 if ($this->_paymentProcessor
&&
609 $this->_paymentProcessor
['payment_type'] & CRM_Core_Payment
::PAYMENT_TYPE_DIRECT_DEBIT
611 $this->assign('payment_type', $this->_paymentProcessor
['payment_type']);
612 $this->assign('account_holder', $this->_params
['account_holder']);
613 $this->assign('bank_identification_number', $this->_params
['bank_identification_number']);
614 $this->assign('bank_name', $this->_params
['bank_name']);
615 $this->assign('bank_account_number', $this->_params
['bank_account_number']);
618 $date = CRM_Utils_Date
::format(CRM_Utils_array
::value('credit_card_exp_date', $this->_params
));
619 $date = CRM_Utils_Date
::mysqlToIso($date);
620 $this->assign('credit_card_exp_date', $date);
621 $this->assign('credit_card_number',
622 CRM_Utils_System
::mungeCreditCard(CRM_Utils_array
::value('credit_card_number', $this->_params
))
627 $this->assign('email',
628 $this->controller
->exportValue('Main', "email-{$this->_bltID}")
631 // also assign the receipt_text
632 if (isset($this->_values
['receipt_text'])) {
633 $this->assign('receipt_text', $this->_values
['receipt_text']);
638 * Function to add the custom fields
643 function buildCustom($id, $name, $viewOnly = FALSE, $onBehalf = FALSE, $fieldTypes = NULL) {
644 $stateCountryMap = array();
647 $contactID = $this->getContactID();
649 // we don't allow conflicting fields to be
650 // configured via profile - CRM 2100
651 $fieldsToIgnore = array(
657 'non_deductible_amount' => 1,
660 'contribution_status_id' => 1,
661 'payment_instrument' => 1,
663 'financial_type' => 1,
667 if ($contactID && CRM_Core_BAO_UFGroup
::filterUFGroups($id, $contactID)) {
668 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
, NULL, NULL, FALSE,
669 NULL, FALSE, NULL, CRM_Core_Permission
::CREATE
, NULL
673 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
, NULL, NULL, FALSE,
674 NULL, FALSE, NULL, CRM_Core_Permission
::CREATE
, NULL
679 // unset any email-* fields since we already collect it, CRM-2888
680 foreach (array_keys($fields) as $fieldName) {
681 if (substr($fieldName, 0, 6) == 'email-') {
682 unset($fields[$fieldName]);
686 if (array_intersect_key($fields, $fieldsToIgnore)) {
687 $fields = array_diff_key($fields, $fieldsToIgnore);
688 CRM_Core_Session
::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
691 $fields = array_diff_assoc($fields, $this->_fields
);
693 CRM_Core_BAO_Address
::checkContactSharedAddressFields($fields, $contactID);
695 foreach ($fields as $key => $field) {
697 isset($field['data_type']) &&
698 $field['data_type'] == 'File' ||
($viewOnly && $field['name'] == 'image_URL')
700 // ignore file upload fields
704 list($prefixName, $index) = CRM_Utils_System
::explode('-', $key, 2);
705 if ($prefixName == 'state_province' ||
$prefixName == 'country' ||
$prefixName == 'county') {
706 if (!array_key_exists($index, $stateCountryMap)) {
707 $stateCountryMap[$index] = array();
709 $stateCountryMap[$index][$prefixName] = $key;
713 if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
714 CRM_Core_BAO_UFGroup
::buildProfile(
717 CRM_Profile_Form
::MODE_CREATE
,
721 $this->_fields
['onbehalf'][$key] = $field;
724 unset($fields[$key]);
728 CRM_Core_BAO_UFGroup
::buildProfile(
731 CRM_Profile_Form
::MODE_CREATE
,
735 $this->_fields
[$key] = $field;
737 // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
738 if ($field['add_captcha'] && !$this->_userID
) {
743 $this->assign($name, $fields);
745 CRM_Core_BAO_Address
::addStateCountryMap($stateCountryMap);
747 if ($addCaptcha && !$viewOnly) {
748 $captcha = CRM_Utils_ReCAPTCHA
::singleton();
749 $captcha->add($this);
750 $this->assign('isCaptcha', TRUE);
756 function checkTemplateFileExists($suffix = NULL) {
758 $templateFile = "CRM/Contribute/Form/Contribution/{$this->_id}/{$this->_name}.{$suffix}tpl";
759 $template = CRM_Core_Form
::getTemplate();
760 if ($template->template_exists($templateFile)) {
761 return $templateFile;
767 function getTemplateFileName() {
768 $fileName = $this->checkTemplateFileExists();
769 return $fileName ?
$fileName : parent
::getTemplateFileName();
772 function overrideExtraTemplateFileName() {
773 $fileName = $this->checkTemplateFileExists('extra.');
774 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();
778 * Function to authenticate pledge user during online payment.
784 public function authenticatePledgeUser() {
785 //get the userChecksum and contact id
786 $userChecksum = CRM_Utils_Request
::retrieve('cs', 'String', $this);
787 $contactID = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
789 //get pledge status and contact id
790 $pledgeValues = array();
791 $pledgeParams = array('id' => $this->_values
['pledge_id']);
792 $returnProperties = array('contact_id', 'status_id');
793 CRM_Core_DAO
::commonRetrieve('CRM_Pledge_DAO_Pledge', $pledgeParams, $pledgeValues, $returnProperties);
796 $allStatus = CRM_Contribute_PseudoConstant
::contributionStatus(NULL, 'name');
797 $validStatus = array(array_search('Pending', $allStatus),
798 array_search('In Progress', $allStatus),
799 array_search('Overdue', $allStatus),
803 if ($this->_userID
&&
804 $this->_userID
== $pledgeValues['contact_id']
806 //check for authenticated user.
809 elseif ($userChecksum && $pledgeValues['contact_id']) {
810 //check for anonymous user.
811 $validUser = CRM_Contact_BAO_Contact_Utils
::validChecksum($pledgeValues['contact_id'], $userChecksum);
813 //make sure cid is same as pledge contact id
814 if ($validUser && ($pledgeValues['contact_id'] != $contactID)) {
820 CRM_Core_Error
::fatal(ts("Oops. It looks like you have an incorrect or incomplete link (URL). Please make sure you've copied the entire link, and try again. Contact the site administrator if this error persists."));
823 //check for valid pledge status.
824 if (!in_array($pledgeValues['status_id'], $validStatus)) {
825 CRM_Core_Error
::fatal(ts('Oops. You cannot make a payment for this pledge - pledge status is %1.', array(1 => CRM_Utils_Array
::value($pledgeValues['status_id'], $allStatus))));
830 * In case user cancel recurring contribution,
831 * When we get the control back from payment gate way
832 * lets delete the recurring and related contribution.
835 public function cancelRecurring() {
836 $isCancel = CRM_Utils_Request
::retrieve('cancel', 'Boolean', CRM_Core_DAO
::$_nullObject);
838 $isRecur = CRM_Utils_Request
::retrieve('isRecur', 'Boolean', CRM_Core_DAO
::$_nullObject);
839 $recurId = CRM_Utils_Request
::retrieve('recurId', 'Positive', CRM_Core_DAO
::$_nullObject);
840 //clean db for recurring contribution.
841 if ($isRecur && $recurId) {
842 CRM_Contribute_BAO_ContributionRecur
::deleteRecurContribution($recurId);
844 $contribId = CRM_Utils_Request
::retrieve('contribId', 'Positive', CRM_Core_DAO
::$_nullObject);
846 CRM_Contribute_BAO_Contribution
::deleteContribution($contribId);