3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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
34 use Civi\Payment\System
;
37 * This class generates form components for processing a contribution.
39 class CRM_Contribute_Form_ContributionBase
extends CRM_Core_Form
{
42 * The id of the contribution page that we are processing.
49 * The mode that we are in
57 * The contact id related to a membership
61 public $_membershipContactID;
64 * The values for the contribution db object
71 * The paymentProcessor attributes for this page
75 public $_paymentProcessor;
76 public $_paymentObject = NULL;
79 * The membership block for this page
83 public $_membershipBlock = NULL;
86 * Does this form support a separate membership payment
89 protected $_separateMembershipPayment;
91 * The default values for the form
98 * The params submitted by the form and computed by the app
105 * The fields involved in this contribution page
109 public $_fields = array();
112 * The billing location id for this contribution page.
119 * Cache the amount to make things easier
147 * The contact id of the person for whom membership is being added or renewed based on the cid in the url,
148 * checksum, or session
156 * The Membership ID for membership renewal
160 public $_membershipId;
163 * Price Set ID, if the new price set method is used
170 * Array of fields for the price set
179 * Is honor block is enabled for this contribution?
183 public $_honor_block_is_active = FALSE;
186 * Contribution mode e.g express for payment express, notify for off-site + notification back to CiviCRM
189 public $_contributeMode;
192 * Contribution page supports memberships
195 public $_useForMember;
197 public $_isBillingAddressRequiredForPayLater;
200 * Set variables up before form is built.
202 * @throws \CRM_Contribute_Exception_InactiveContributionPageException
205 public function preProcess() {
206 $session = CRM_Core_Session
::singleton();
208 // current contribution page id
209 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
211 // seems like the session is corrupted and/or we lost the id trail
212 // lets just bump this to a regular session error and redirect user to main page
213 $this->controller
->invalidKeyRedirect();
216 // this was used prior to the cleverer this_>getContactID - unsure now
217 $this->_userID
= $session->get('userID');
219 //Check if honor block is enabled for current contribution
220 $ufJoinParams = array(
221 'module' => 'soft_credit',
222 'entity_table' => 'civicrm_contribution_page',
223 'entity_id' => $this->_id
,
225 $ufJoin = new CRM_Core_DAO_UFJoin();
226 $ufJoin->copyValues($ufJoinParams);
228 $this->_honor_block_is_active
= $ufJoin->is_active
;
230 $this->_contactID
= $this->_membershipContactID
= $this->getContactID();
232 if ($this->_contactID
) {
233 $this->_mid
= CRM_Utils_Request
::retrieve('mid', 'Positive', $this);
235 $membership = new CRM_Member_DAO_Membership();
236 $membership->id
= $this->_mid
;
238 if ($membership->find(TRUE)) {
239 $this->_defaultMemTypeId
= $membership->membership_type_id
;
240 if ($membership->contact_id
!= $this->_contactID
) {
241 $validMembership = FALSE;
242 $employers = CRM_Contact_BAO_Relationship
::getPermissionedEmployer($this->_userID
);
243 if (!empty($employers) && array_key_exists($membership->contact_id
, $employers)) {
244 $this->_membershipContactID
= $membership->contact_id
;
245 $this->assign('membershipContactID', $this->_membershipContactID
);
246 $this->assign('membershipContactName', $employers[$this->_membershipContactID
]['name']);
247 $validMembership = TRUE;
250 $membershipType = new CRM_Member_BAO_MembershipType();
251 $membershipType->id
= $membership->membership_type_id
;
252 if ($membershipType->find(TRUE)) {
253 // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
254 // Convert to comma separated list.
255 $inheritedRelTypes = implode(CRM_Utils_Array
::explodePadded($membershipType->relationship_type_id
), ',');
256 $permContacts = CRM_Contact_BAO_Relationship
::getPermissionedContacts($this->_userID
, $membershipType->relationship_type_id
);
257 if (array_key_exists($membership->contact_id
, $permContacts)) {
258 $this->_membershipContactID
= $membership->contact_id
;
259 $validMembership = TRUE;
263 if (!$validMembership) {
264 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');
269 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');
275 // we do not want to display recently viewed items, so turn off
276 $this->assign('displayRecent', FALSE);
277 // Contribution page values are cleared from session, so can't use normal Printer Friendly view.
278 // Use Browser Print instead.
279 $this->assign('browserPrint', TRUE);
282 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'add');
283 $this->assign('action', $this->_action
);
286 $this->_mode
= ($this->_action
== 1024) ?
'test' : 'live';
288 $this->_values
= $this->get('values');
289 $this->_fields
= $this->get('fields');
290 $this->_bltID
= $this->get('bltID');
291 $this->_paymentProcessor
= $this->get('paymentProcessor');
292 $this->_priceSetId
= $this->get('priceSetId');
293 $this->_priceSet
= $this->get('priceSet');
295 if (!$this->_values
) {
296 // get all the values from the dao object
297 $this->_values
= array();
298 $this->_fields
= array();
300 CRM_Contribute_BAO_ContributionPage
::setValues($this->_id
, $this->_values
);
302 if (empty($this->_values
['is_active'])) {
303 throw new CRM_Contribute_Exception_InactiveContributionPageException(ts('The page you requested is currently unavailable.'), $this->_id
);
306 // also check for billing information.
307 // get the billing location type
308 $locationTypes = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
309 // CRM-8108 remove ts around Billing location type
310 //$this->_bltID = array_search( ts('Billing'), $locationTypes );
311 $this->_bltID
= array_search('Billing', $locationTypes);
312 if (!$this->_bltID
) {
313 CRM_Core_Error
::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
315 $this->set('bltID', $this->_bltID
);
317 // check for is_monetary status
318 $isMonetary = CRM_Utils_Array
::value('is_monetary', $this->_values
);
319 $isPayLater = CRM_Utils_Array
::value('is_pay_later', $this->_values
);
321 //FIXME: to support multiple payment processors
323 (!$isPayLater ||
!empty($this->_values
['payment_processor']))
325 $ppID = CRM_Utils_Array
::value('payment_processor', $this->_values
);
327 CRM_Core_Error
::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
330 $paymentProcessorIDs = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $ppID);
332 $this->_paymentProcessors
= CRM_Financial_BAO_PaymentProcessor
::getPayments($paymentProcessorIDs, $this->_mode
);
334 $this->set('paymentProcessors', $this->_paymentProcessors
);
336 if (!empty($this->_paymentProcessors
)) {
337 foreach ($this->_paymentProcessors
as $paymentProcessorID => $paymentProcessorDetail) {
338 if (($processor = Civi\Payment\System
::singleton()->getByProcessor($paymentProcessorDetail)) != FALSE) {
339 // We don't really know why we do this.
340 $this->_paymentObject
= $processor;
343 if (empty($this->_paymentProcessor
) && $paymentProcessorDetail['is_default'] == 1 ||
(count($this->_paymentProcessors
) == 1)
345 $this->_paymentProcessor
= $paymentProcessorDetail;
346 $this->assign('paymentProcessor', $this->_paymentProcessor
);
349 if (empty($this->_paymentObject
)) {
350 throw new CRM_Core_Exception(ts('No valid payment processor'));
354 throw new CRM_Core_Exception(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
360 CRM_Price_BAO_PriceSet
::initSet($this, $this->_id
, 'civicrm_contribution_page');
362 // this avoids getting E_NOTICE errors in php
363 $setNullFields = array(
364 'amount_block_is_active',
365 'is_allow_other_amount',
368 foreach ($setNullFields as $f) {
369 if (!isset($this->_values
[$f])) {
370 $this->_values
[$f] = NULL;
374 //check if Membership Block is enabled, if Membership Fields are included in profile
375 //get membership section for this contribution page
376 $this->_membershipBlock
= CRM_Member_BAO_Membership
::getMembershipBlock($this->_id
);
377 $this->set('membershipBlock', $this->_membershipBlock
);
379 if ($this->_values
['custom_pre_id']) {
380 $preProfileType = CRM_Core_BAO_UFField
::getProfileType($this->_values
['custom_pre_id']);
383 if ($this->_values
['custom_post_id']) {
384 $postProfileType = CRM_Core_BAO_UFField
::getProfileType($this->_values
['custom_post_id']);
387 if (((isset($postProfileType) && $postProfileType == 'Membership') ||
388 (isset($preProfileType) && $preProfileType == 'Membership')
390 !$this->_membershipBlock
['is_active']
392 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.'));
395 $pledgeBlock = CRM_Pledge_BAO_PledgeBlock
::getPledgeBlock($this->_id
);
398 $this->_values
['pledge_block_id'] = CRM_Utils_Array
::value('id', $pledgeBlock);
399 $this->_values
['max_reminders'] = CRM_Utils_Array
::value('max_reminders', $pledgeBlock);
400 $this->_values
['initial_reminder_day'] = CRM_Utils_Array
::value('initial_reminder_day', $pledgeBlock);
401 $this->_values
['additional_reminder_day'] = CRM_Utils_Array
::value('additional_reminder_day', $pledgeBlock);
403 //set pledge id in values
404 $pledgeId = CRM_Utils_Request
::retrieve('pledgeId', 'Positive', $this);
406 //authenticate pledge user for pledge payment.
408 $this->_values
['pledge_id'] = $pledgeId;
410 //lets override w/ pledge campaign.
411 $this->_values
['campaign_id'] = CRM_Core_DAO
::getFieldValue('CRM_Pledge_DAO_Pledge',
415 self
::authenticatePledgeUser();
418 $this->set('values', $this->_values
);
419 $this->set('fields', $this->_fields
);
423 $pcpId = CRM_Utils_Request
::retrieve('pcpId', 'Positive', $this);
425 $pcp = CRM_PCP_BAO_PCP
::handlePcp($pcpId, 'contribute', $this->_values
);
426 $this->_pcpId
= $pcp['pcpId'];
427 $this->_pcpBlock
= $pcp['pcpBlock'];
428 $this->_pcpInfo
= $pcp['pcpInfo'];
431 // Link (button) for users to create their own Personal Campaign page
432 if ($linkText = CRM_PCP_BAO_PCP
::getPcpBlockStatus($this->_id
, 'contribute')) {
433 $linkTextUrl = CRM_Utils_System
::url('civicrm/contribute/campaign',
434 "action=add&reset=1&pageId={$this->_id}&component=contribute",
437 $this->assign('linkTextUrl', $linkTextUrl);
438 $this->assign('linkText', $linkText);
441 //set pledge block if block id is set
442 if (!empty($this->_values
['pledge_block_id'])) {
443 $this->assign('pledgeBlock', TRUE);
446 // check if one of the (amount , membership) blocks is active or not.
447 $this->_membershipBlock
= $this->get('membershipBlock');
449 if (!$this->_values
['amount_block_is_active'] &&
450 !$this->_membershipBlock
['is_active'] &&
453 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.'));
456 if ($this->_values
['amount_block_is_active']) {
457 $this->set('amount_block_is_active', $this->_values
['amount_block_is_active']);
460 $this->_contributeMode
= $this->get('contributeMode');
461 $this->assign('contributeMode', $this->_contributeMode
);
463 //assigning is_monetary and is_email_receipt to template
464 $this->assign('is_monetary', $this->_values
['is_monetary']);
465 $this->assign('is_email_receipt', $this->_values
['is_email_receipt']);
466 $this->assign('bltID', $this->_bltID
);
468 //assign cancelSubscription URL to templates
469 $this->assign('cancelSubscriptionUrl',
470 CRM_Utils_Array
::value('cancelSubscriptionUrl', $this->_values
)
473 // assigning title to template in case someone wants to use it, also setting CMS page title
475 $this->assign('title', $this->_pcpInfo
['title']);
476 CRM_Utils_System
::setTitle($this->_pcpInfo
['title']);
479 $this->assign('title', $this->_values
['title']);
480 CRM_Utils_System
::setTitle($this->_values
['title']);
482 $this->_defaults
= array();
484 $this->_amount
= $this->get('amount');
487 $config = CRM_Core_Config
::singleton();
488 $config->defaultCurrency
= CRM_Utils_Array
::value('currency',
490 $config->defaultCurrency
493 //lets allow user to override campaign.
494 $campID = CRM_Utils_Request
::retrieve('campID', 'Positive', $this);
495 if ($campID && CRM_Core_DAO
::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
496 $this->_values
['campaign_id'] = $campID;
499 //do check for cancel recurring and clean db, CRM-7696
500 if (CRM_Utils_Request
::retrieve('cancel', 'Boolean', CRM_Core_DAO
::$_nullObject)) {
501 self
::cancelRecurring();
504 // check if billing block is required for pay later
505 if (CRM_Utils_Array
::value('is_pay_later', $this->_values
)) {
506 $this->_isBillingAddressRequiredForPayLater
= CRM_Utils_Array
::value('is_billing_required', $this->_values
);
507 $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater
);
512 * Set the default values.
514 public function setDefaultValues() {
515 return $this->_defaults
;
519 * Assign the minimal set of variables to the template.
521 public function assignToTemplate() {
522 $name = CRM_Utils_Array
::value('billing_first_name', $this->_params
);
523 if (!empty($this->_params
['billing_middle_name'])) {
524 $name .= " {$this->_params['billing_middle_name']}";
526 $name .= ' ' . CRM_Utils_Array
::value('billing_last_name', $this->_params
);
528 $this->assign('billingName', $name);
529 $this->set('name', $name);
531 $this->assign('paymentProcessor', $this->_paymentProcessor
);
540 $config = CRM_Core_Config
::singleton();
541 if (isset($this->_values
['is_recur']) && !empty($this->_paymentProcessor
['is_recur'])) {
542 $this->assign('is_recur_enabled', 1);
543 $vars = array_merge($vars, array(
545 'frequency_interval',
551 if (in_array('CiviPledge', $config->enableComponents
) &&
552 CRM_Utils_Array
::value('is_pledge', $this->_params
) == 1
554 $this->assign('pledge_enabled', 1);
556 $vars = array_merge($vars, array(
558 'pledge_frequency_interval',
559 'pledge_frequency_unit',
560 'pledge_installments',
564 if (isset($this->_params
['amount_other']) ||
isset($this->_params
['selectMembership'])) {
565 $this->_params
['amount_level'] = '';
568 foreach ($vars as $v) {
569 if (isset($this->_params
[$v])) {
570 if ($v == "amount" && $this->_params
[$v] === 0) {
571 $this->_params
[$v] = CRM_Utils_Money
::format($this->_params
[$v], NULL, NULL, TRUE);
573 $this->assign($v, $this->_params
[$v]);
577 // assign the address formatted up for display
578 $addressParts = array(
579 "street_address-{$this->_bltID}",
580 "city-{$this->_bltID}",
581 "postal_code-{$this->_bltID}",
582 "state_province-{$this->_bltID}",
583 "country-{$this->_bltID}",
586 $addressFields = array();
587 foreach ($addressParts as $part) {
588 list($n, $id) = explode('-', $part);
589 $addressFields[$n] = CRM_Utils_Array
::value('billing_' . $part, $this->_params
);
592 $this->assign('address', CRM_Utils_Address
::format($addressFields));
594 if (!empty($this->_params
['hidden_onbehalf_profile'])) {
595 $this->assign('onBehalfName', $this->_params
['organization_name']);
596 $locTypeId = array_keys($this->_params
['onbehalf_location']['email']);
597 $this->assign('onBehalfEmail', $this->_params
['onbehalf_location']['email'][$locTypeId[0]]['email']);
601 $assignCCInfo = FALSE;
602 if ($this->_amount
> 0.0) {
603 $assignCCInfo = TRUE;
605 elseif (!empty($this->_params
['selectMembership'])) {
606 $memFee = CRM_Core_DAO
::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params
['selectMembership'], 'minimum_fee');
608 $assignCCInfo = TRUE;
612 if ($this->_contributeMode
== 'direct' && $assignCCInfo) {
613 if ($this->_paymentProcessor
&&
614 $this->_paymentProcessor
['payment_type'] & CRM_Core_Payment
::PAYMENT_TYPE_DIRECT_DEBIT
616 $this->assign('account_holder', $this->_params
['account_holder']);
617 $this->assign('bank_identification_number', $this->_params
['bank_identification_number']);
618 $this->assign('bank_name', $this->_params
['bank_name']);
619 $this->assign('bank_account_number', $this->_params
['bank_account_number']);
622 $date = CRM_Utils_Date
::format(CRM_Utils_array
::value('credit_card_exp_date', $this->_params
));
623 $date = CRM_Utils_Date
::mysqlToIso($date);
624 $this->assign('credit_card_exp_date', $date);
625 $this->assign('credit_card_number',
626 CRM_Utils_System
::mungeCreditCard(CRM_Utils_array
::value('credit_card_number', $this->_params
))
631 $this->assign('email',
632 $this->controller
->exportValue('Main', "email-{$this->_bltID}")
635 // also assign the receipt_text
636 if (isset($this->_values
['receipt_text'])) {
637 $this->assign('receipt_text', $this->_values
['receipt_text']);
642 * Add the custom fields.
645 * @param string $name
646 * @param bool $viewOnly
647 * @param null $profileContactType
648 * @param array $fieldTypes
650 public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL) {
652 $contactID = $this->getContactID();
654 // we don't allow conflicting fields to be
655 // configured via profile - CRM 2100
656 $fieldsToIgnore = array(
662 'non_deductible_amount' => 1,
665 'contribution_status_id' => 1,
666 'payment_instrument' => 1,
668 'financial_type' => 1,
672 if ($contactID && CRM_Core_BAO_UFGroup
::filterUFGroups($id, $contactID)) {
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
678 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
, NULL, NULL, FALSE,
679 NULL, FALSE, NULL, CRM_Core_Permission
::CREATE
, NULL
684 // unset any email-* fields since we already collect it, CRM-2888
685 foreach (array_keys($fields) as $fieldName) {
686 if (substr($fieldName, 0, 6) == 'email-' && $profileContactType != 'honor') {
687 unset($fields[$fieldName]);
691 if (array_intersect_key($fields, $fieldsToIgnore)) {
692 $fields = array_diff_key($fields, $fieldsToIgnore);
693 CRM_Core_Session
::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
696 $fields = array_diff_assoc($fields, $this->_fields
);
698 CRM_Core_BAO_Address
::checkContactSharedAddressFields($fields, $contactID);
700 foreach ($fields as $key => $field) {
702 isset($field['data_type']) &&
703 $field['data_type'] == 'File' ||
($viewOnly && $field['name'] == 'image_URL')
705 // ignore file upload fields
709 if ($profileContactType) {
710 //Since we are showing honoree name separately so we are removing it from honoree profile just for display
711 $honoreeNamefields = array(
719 if ($profileContactType == 'honor' && in_array($field['name'], $honoreeNamefields)) {
720 unset($fields[$field['name']]);
723 if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
724 CRM_Core_BAO_UFGroup
::buildProfile(
727 CRM_Profile_Form
::MODE_CREATE
,
732 $this->_fields
[$profileContactType][$key] = $field;
735 unset($fields[$key]);
739 CRM_Core_BAO_UFGroup
::buildProfile(
742 CRM_Profile_Form
::MODE_CREATE
,
746 $this->_fields
[$key] = $field;
748 // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
749 if ($field['add_captcha'] && !$this->_userID
) {
754 $this->assign($name, $fields);
756 if ($addCaptcha && !$viewOnly) {
757 $captcha = CRM_Utils_ReCAPTCHA
::singleton();
758 $captcha->add($this);
759 $this->assign('isCaptcha', TRUE);
766 * Check template file exists.
768 * @param string $suffix
770 * @return null|string
772 public function checkTemplateFileExists($suffix = NULL) {
774 $templateFile = "CRM/Contribute/Form/Contribution/{$this->_id}/{$this->_name}.{$suffix}tpl";
775 $template = CRM_Core_Form
::getTemplate();
776 if ($template->template_exists($templateFile)) {
777 return $templateFile;
784 * Use the form name to create the tpl file name.
788 public function getTemplateFileName() {
789 $fileName = $this->checkTemplateFileExists();
790 return $fileName ?
$fileName : parent
::getTemplateFileName();
794 * Add the extra.tpl in.
796 * Default extra tpl file basically just replaces .tpl with .extra.tpl
797 * i.e. we do not override - why isn't this done at the CRM_Core_Form level?
801 public function overrideExtraTemplateFileName() {
802 $fileName = $this->checkTemplateFileExists('extra.');
803 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();
807 * Authenticate pledge user during online payment.
809 public function authenticatePledgeUser() {
810 //get the userChecksum and contact id
811 $userChecksum = CRM_Utils_Request
::retrieve('cs', 'String', $this);
812 $contactID = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
814 //get pledge status and contact id
815 $pledgeValues = array();
816 $pledgeParams = array('id' => $this->_values
['pledge_id']);
817 $returnProperties = array('contact_id', 'status_id');
818 CRM_Core_DAO
::commonRetrieve('CRM_Pledge_DAO_Pledge', $pledgeParams, $pledgeValues, $returnProperties);
821 $allStatus = CRM_Contribute_PseudoConstant
::contributionStatus(NULL, 'name');
822 $validStatus = array(
823 array_search('Pending', $allStatus),
824 array_search('In Progress', $allStatus),
825 array_search('Overdue', $allStatus),
829 if ($this->_userID
&&
830 $this->_userID
== $pledgeValues['contact_id']
832 //check for authenticated user.
835 elseif ($userChecksum && $pledgeValues['contact_id']) {
836 //check for anonymous user.
837 $validUser = CRM_Contact_BAO_Contact_Utils
::validChecksum($pledgeValues['contact_id'], $userChecksum);
839 //make sure cid is same as pledge contact id
840 if ($validUser && ($pledgeValues['contact_id'] != $contactID)) {
846 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."));
849 //check for valid pledge status.
850 if (!in_array($pledgeValues['status_id'], $validStatus)) {
851 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))));
856 * Cancel recurring contributions.
858 * In case user cancel recurring contribution,
859 * When we get the control back from payment gate way
860 * lets delete the recurring and related contribution.
862 public function cancelRecurring() {
863 $isCancel = CRM_Utils_Request
::retrieve('cancel', 'Boolean', CRM_Core_DAO
::$_nullObject);
865 $isRecur = CRM_Utils_Request
::retrieve('isRecur', 'Boolean', CRM_Core_DAO
::$_nullObject);
866 $recurId = CRM_Utils_Request
::retrieve('recurId', 'Positive', CRM_Core_DAO
::$_nullObject);
867 //clean db for recurring contribution.
868 if ($isRecur && $recurId) {
869 CRM_Contribute_BAO_ContributionRecur
::deleteRecurContribution($recurId);
871 $contribId = CRM_Utils_Request
::retrieve('contribId', 'Positive', CRM_Core_DAO
::$_nullObject);
873 CRM_Contribute_BAO_Contribution
::deleteContribution($contribId);