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 $this->assignBillingType();
308 // check for is_monetary status
309 $isMonetary = CRM_Utils_Array
::value('is_monetary', $this->_values
);
310 $isPayLater = CRM_Utils_Array
::value('is_pay_later', $this->_values
);
312 //FIXME: to support multiple payment processors
314 (!$isPayLater ||
!empty($this->_values
['payment_processor']))
316 $ppID = CRM_Utils_Array
::value('payment_processor', $this->_values
);
318 CRM_Core_Error
::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
321 $paymentProcessorIDs = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $ppID);
323 $this->_paymentProcessors
= CRM_Financial_BAO_PaymentProcessor
::getPayments($paymentProcessorIDs, $this->_mode
);
325 $this->set('paymentProcessors', $this->_paymentProcessors
);
327 if (!empty($this->_paymentProcessors
)) {
328 foreach ($this->_paymentProcessors
as $paymentProcessorID => $paymentProcessorDetail) {
329 if (($processor = Civi\Payment\System
::singleton()->getByProcessor($paymentProcessorDetail)) != FALSE) {
330 // We don't really know why we do this.
331 $this->_paymentObject
= $processor;
334 if (empty($this->_paymentProcessor
) && $paymentProcessorDetail['is_default'] == 1 ||
(count($this->_paymentProcessors
) == 1)
336 $this->_paymentProcessor
= $paymentProcessorDetail;
337 $this->assign('paymentProcessor', $this->_paymentProcessor
);
340 if (empty($this->_paymentObject
)) {
341 throw new CRM_Core_Exception(ts('No valid payment processor'));
345 throw new CRM_Core_Exception(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
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 'is_allow_other_amount',
359 foreach ($setNullFields as $f) {
360 if (!isset($this->_values
[$f])) {
361 $this->_values
[$f] = NULL;
365 //check if Membership Block is enabled, if Membership Fields are included in profile
366 //get membership section for this contribution page
367 $this->_membershipBlock
= CRM_Member_BAO_Membership
::getMembershipBlock($this->_id
);
368 $this->set('membershipBlock', $this->_membershipBlock
);
370 if ($this->_values
['custom_pre_id']) {
371 $preProfileType = CRM_Core_BAO_UFField
::getProfileType($this->_values
['custom_pre_id']);
374 if ($this->_values
['custom_post_id']) {
375 $postProfileType = CRM_Core_BAO_UFField
::getProfileType($this->_values
['custom_post_id']);
378 if (((isset($postProfileType) && $postProfileType == 'Membership') ||
379 (isset($preProfileType) && $preProfileType == 'Membership')
381 !$this->_membershipBlock
['is_active']
383 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.'));
386 $pledgeBlock = CRM_Pledge_BAO_PledgeBlock
::getPledgeBlock($this->_id
);
389 $this->_values
['pledge_block_id'] = CRM_Utils_Array
::value('id', $pledgeBlock);
390 $this->_values
['max_reminders'] = CRM_Utils_Array
::value('max_reminders', $pledgeBlock);
391 $this->_values
['initial_reminder_day'] = CRM_Utils_Array
::value('initial_reminder_day', $pledgeBlock);
392 $this->_values
['additional_reminder_day'] = CRM_Utils_Array
::value('additional_reminder_day', $pledgeBlock);
394 //set pledge id in values
395 $pledgeId = CRM_Utils_Request
::retrieve('pledgeId', 'Positive', $this);
397 //authenticate pledge user for pledge payment.
399 $this->_values
['pledge_id'] = $pledgeId;
401 //lets override w/ pledge campaign.
402 $this->_values
['campaign_id'] = CRM_Core_DAO
::getFieldValue('CRM_Pledge_DAO_Pledge',
406 self
::authenticatePledgeUser();
409 $this->set('values', $this->_values
);
410 $this->set('fields', $this->_fields
);
414 $pcpId = CRM_Utils_Request
::retrieve('pcpId', 'Positive', $this);
416 $pcp = CRM_PCP_BAO_PCP
::handlePcp($pcpId, 'contribute', $this->_values
);
417 $this->_pcpId
= $pcp['pcpId'];
418 $this->_pcpBlock
= $pcp['pcpBlock'];
419 $this->_pcpInfo
= $pcp['pcpInfo'];
422 // Link (button) for users to create their own Personal Campaign page
423 if ($linkText = CRM_PCP_BAO_PCP
::getPcpBlockStatus($this->_id
, 'contribute')) {
424 $linkTextUrl = CRM_Utils_System
::url('civicrm/contribute/campaign',
425 "action=add&reset=1&pageId={$this->_id}&component=contribute",
428 $this->assign('linkTextUrl', $linkTextUrl);
429 $this->assign('linkText', $linkText);
432 //set pledge block if block id is set
433 if (!empty($this->_values
['pledge_block_id'])) {
434 $this->assign('pledgeBlock', TRUE);
437 // check if one of the (amount , membership) blocks is active or not.
438 $this->_membershipBlock
= $this->get('membershipBlock');
440 if (!$this->_values
['amount_block_is_active'] &&
441 !$this->_membershipBlock
['is_active'] &&
444 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.'));
447 if ($this->_values
['amount_block_is_active']) {
448 $this->set('amount_block_is_active', $this->_values
['amount_block_is_active']);
451 $this->_contributeMode
= $this->get('contributeMode');
452 $this->assign('contributeMode', $this->_contributeMode
);
454 //assigning is_monetary and is_email_receipt to template
455 $this->assign('is_monetary', $this->_values
['is_monetary']);
456 $this->assign('is_email_receipt', $this->_values
['is_email_receipt']);
457 $this->assign('bltID', $this->_bltID
);
459 //assign cancelSubscription URL to templates
460 $this->assign('cancelSubscriptionUrl',
461 CRM_Utils_Array
::value('cancelSubscriptionUrl', $this->_values
)
464 // assigning title to template in case someone wants to use it, also setting CMS page title
466 $this->assign('title', $this->_pcpInfo
['title']);
467 CRM_Utils_System
::setTitle($this->_pcpInfo
['title']);
470 $this->assign('title', $this->_values
['title']);
471 CRM_Utils_System
::setTitle($this->_values
['title']);
473 $this->_defaults
= array();
475 $this->_amount
= $this->get('amount');
478 $config = CRM_Core_Config
::singleton();
479 $config->defaultCurrency
= CRM_Utils_Array
::value('currency',
481 $config->defaultCurrency
484 //lets allow user to override campaign.
485 $campID = CRM_Utils_Request
::retrieve('campID', 'Positive', $this);
486 if ($campID && CRM_Core_DAO
::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
487 $this->_values
['campaign_id'] = $campID;
490 //do check for cancel recurring and clean db, CRM-7696
491 if (CRM_Utils_Request
::retrieve('cancel', 'Boolean', CRM_Core_DAO
::$_nullObject)) {
492 self
::cancelRecurring();
495 // check if billing block is required for pay later
496 if (CRM_Utils_Array
::value('is_pay_later', $this->_values
)) {
497 $this->_isBillingAddressRequiredForPayLater
= CRM_Utils_Array
::value('is_billing_required', $this->_values
);
498 $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater
);
503 * Set the default values.
505 public function setDefaultValues() {
506 return $this->_defaults
;
510 * Assign the minimal set of variables to the template.
512 public function assignToTemplate() {
513 $name = CRM_Utils_Array
::value('billing_first_name', $this->_params
);
514 if (!empty($this->_params
['billing_middle_name'])) {
515 $name .= " {$this->_params['billing_middle_name']}";
517 $name .= ' ' . CRM_Utils_Array
::value('billing_last_name', $this->_params
);
519 $this->assign('billingName', $name);
520 $this->set('name', $name);
522 $this->assign('paymentProcessor', $this->_paymentProcessor
);
531 $config = CRM_Core_Config
::singleton();
532 if (isset($this->_values
['is_recur']) && !empty($this->_paymentProcessor
['is_recur'])) {
533 $this->assign('is_recur_enabled', 1);
534 $vars = array_merge($vars, array(
536 'frequency_interval',
542 if (in_array('CiviPledge', $config->enableComponents
) &&
543 CRM_Utils_Array
::value('is_pledge', $this->_params
) == 1
545 $this->assign('pledge_enabled', 1);
547 $vars = array_merge($vars, array(
549 'pledge_frequency_interval',
550 'pledge_frequency_unit',
551 'pledge_installments',
555 if (isset($this->_params
['amount_other']) ||
isset($this->_params
['selectMembership'])) {
556 $this->_params
['amount_level'] = '';
559 foreach ($vars as $v) {
560 if (isset($this->_params
[$v])) {
561 if ($v == "amount" && $this->_params
[$v] === 0) {
562 $this->_params
[$v] = CRM_Utils_Money
::format($this->_params
[$v], NULL, NULL, TRUE);
564 $this->assign($v, $this->_params
[$v]);
568 // assign the address formatted up for display
569 $addressParts = array(
570 "street_address-{$this->_bltID}",
571 "city-{$this->_bltID}",
572 "postal_code-{$this->_bltID}",
573 "state_province-{$this->_bltID}",
574 "country-{$this->_bltID}",
577 $addressFields = array();
578 foreach ($addressParts as $part) {
579 list($n, $id) = explode('-', $part);
580 $addressFields[$n] = CRM_Utils_Array
::value('billing_' . $part, $this->_params
);
583 $this->assign('address', CRM_Utils_Address
::format($addressFields));
585 if (!empty($this->_params
['hidden_onbehalf_profile'])) {
586 $this->assign('onBehalfName', $this->_params
['organization_name']);
587 $locTypeId = array_keys($this->_params
['onbehalf_location']['email']);
588 $this->assign('onBehalfEmail', $this->_params
['onbehalf_location']['email'][$locTypeId[0]]['email']);
592 $assignCCInfo = FALSE;
593 if ($this->_amount
> 0.0) {
594 $assignCCInfo = TRUE;
596 elseif (!empty($this->_params
['selectMembership'])) {
597 $memFee = CRM_Core_DAO
::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params
['selectMembership'], 'minimum_fee');
599 $assignCCInfo = TRUE;
603 if ($this->_contributeMode
== 'direct' && $assignCCInfo) {
604 if ($this->_paymentProcessor
&&
605 $this->_paymentProcessor
['payment_type'] & CRM_Core_Payment
::PAYMENT_TYPE_DIRECT_DEBIT
607 $this->assign('account_holder', $this->_params
['account_holder']);
608 $this->assign('bank_identification_number', $this->_params
['bank_identification_number']);
609 $this->assign('bank_name', $this->_params
['bank_name']);
610 $this->assign('bank_account_number', $this->_params
['bank_account_number']);
613 $date = CRM_Utils_Date
::format(CRM_Utils_array
::value('credit_card_exp_date', $this->_params
));
614 $date = CRM_Utils_Date
::mysqlToIso($date);
615 $this->assign('credit_card_exp_date', $date);
616 $this->assign('credit_card_number',
617 CRM_Utils_System
::mungeCreditCard(CRM_Utils_array
::value('credit_card_number', $this->_params
))
622 $this->assign('email',
623 $this->controller
->exportValue('Main', "email-{$this->_bltID}")
626 // also assign the receipt_text
627 if (isset($this->_values
['receipt_text'])) {
628 $this->assign('receipt_text', $this->_values
['receipt_text']);
633 * Add the custom fields.
636 * @param string $name
637 * @param bool $viewOnly
638 * @param null $profileContactType
639 * @param array $fieldTypes
641 public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL) {
643 $contactID = $this->getContactID();
645 // we don't allow conflicting fields to be
646 // configured via profile - CRM 2100
647 $fieldsToIgnore = array(
653 'non_deductible_amount' => 1,
656 'contribution_status_id' => 1,
657 'payment_instrument' => 1,
659 'financial_type' => 1,
663 if ($contactID && CRM_Core_BAO_UFGroup
::filterUFGroups($id, $contactID)) {
664 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
, NULL, NULL, FALSE,
665 NULL, FALSE, NULL, CRM_Core_Permission
::CREATE
, NULL
669 $fields = CRM_Core_BAO_UFGroup
::getFields($id, FALSE, CRM_Core_Action
::ADD
, NULL, NULL, FALSE,
670 NULL, FALSE, NULL, CRM_Core_Permission
::CREATE
, NULL
675 // unset any email-* fields since we already collect it, CRM-2888
676 foreach (array_keys($fields) as $fieldName) {
677 if (substr($fieldName, 0, 6) == 'email-' && $profileContactType != 'honor') {
678 unset($fields[$fieldName]);
682 if (array_intersect_key($fields, $fieldsToIgnore)) {
683 $fields = array_diff_key($fields, $fieldsToIgnore);
684 CRM_Core_Session
::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
687 $fields = array_diff_assoc($fields, $this->_fields
);
689 CRM_Core_BAO_Address
::checkContactSharedAddressFields($fields, $contactID);
691 foreach ($fields as $key => $field) {
693 isset($field['data_type']) &&
694 $field['data_type'] == 'File' ||
($viewOnly && $field['name'] == 'image_URL')
696 // ignore file upload fields
700 if ($profileContactType) {
701 //Since we are showing honoree name separately so we are removing it from honoree profile just for display
702 $honoreeNamefields = array(
710 if ($profileContactType == 'honor' && in_array($field['name'], $honoreeNamefields)) {
711 unset($fields[$field['name']]);
714 if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
715 CRM_Core_BAO_UFGroup
::buildProfile(
718 CRM_Profile_Form
::MODE_CREATE
,
723 $this->_fields
[$profileContactType][$key] = $field;
726 unset($fields[$key]);
730 CRM_Core_BAO_UFGroup
::buildProfile(
733 CRM_Profile_Form
::MODE_CREATE
,
737 $this->_fields
[$key] = $field;
739 // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
740 if ($field['add_captcha'] && !$this->_userID
) {
745 $this->assign($name, $fields);
747 if ($addCaptcha && !$viewOnly) {
748 $captcha = CRM_Utils_ReCAPTCHA
::singleton();
749 $captcha->add($this);
750 $this->assign('isCaptcha', TRUE);
757 * Check template file exists.
759 * @param string $suffix
761 * @return null|string
763 public function checkTemplateFileExists($suffix = NULL) {
765 $templateFile = "CRM/Contribute/Form/Contribution/{$this->_id}/{$this->_name}.{$suffix}tpl";
766 $template = CRM_Core_Form
::getTemplate();
767 if ($template->template_exists($templateFile)) {
768 return $templateFile;
775 * Use the form name to create the tpl file name.
779 public function getTemplateFileName() {
780 $fileName = $this->checkTemplateFileExists();
781 return $fileName ?
$fileName : parent
::getTemplateFileName();
785 * Add the extra.tpl in.
787 * Default extra tpl file basically just replaces .tpl with .extra.tpl
788 * i.e. we do not override - why isn't this done at the CRM_Core_Form level?
792 public function overrideExtraTemplateFileName() {
793 $fileName = $this->checkTemplateFileExists('extra.');
794 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();
798 * Authenticate pledge user during online payment.
800 public function authenticatePledgeUser() {
801 //get the userChecksum and contact id
802 $userChecksum = CRM_Utils_Request
::retrieve('cs', 'String', $this);
803 $contactID = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
805 //get pledge status and contact id
806 $pledgeValues = array();
807 $pledgeParams = array('id' => $this->_values
['pledge_id']);
808 $returnProperties = array('contact_id', 'status_id');
809 CRM_Core_DAO
::commonRetrieve('CRM_Pledge_DAO_Pledge', $pledgeParams, $pledgeValues, $returnProperties);
812 $allStatus = CRM_Contribute_PseudoConstant
::contributionStatus(NULL, 'name');
813 $validStatus = array(
814 array_search('Pending', $allStatus),
815 array_search('In Progress', $allStatus),
816 array_search('Overdue', $allStatus),
820 if ($this->_userID
&&
821 $this->_userID
== $pledgeValues['contact_id']
823 //check for authenticated user.
826 elseif ($userChecksum && $pledgeValues['contact_id']) {
827 //check for anonymous user.
828 $validUser = CRM_Contact_BAO_Contact_Utils
::validChecksum($pledgeValues['contact_id'], $userChecksum);
830 //make sure cid is same as pledge contact id
831 if ($validUser && ($pledgeValues['contact_id'] != $contactID)) {
837 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."));
840 //check for valid pledge status.
841 if (!in_array($pledgeValues['status_id'], $validStatus)) {
842 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))));
847 * Cancel recurring contributions.
849 * In case user cancel recurring contribution,
850 * When we get the control back from payment gate way
851 * lets delete the recurring and related contribution.
853 public function cancelRecurring() {
854 $isCancel = CRM_Utils_Request
::retrieve('cancel', 'Boolean', CRM_Core_DAO
::$_nullObject);
856 $isRecur = CRM_Utils_Request
::retrieve('isRecur', 'Boolean', CRM_Core_DAO
::$_nullObject);
857 $recurId = CRM_Utils_Request
::retrieve('recurId', 'Positive', CRM_Core_DAO
::$_nullObject);
858 //clean db for recurring contribution.
859 if ($isRecur && $recurId) {
860 CRM_Contribute_BAO_ContributionRecur
::deleteRecurContribution($recurId);
862 $contribId = CRM_Utils_Request
::retrieve('contribId', 'Positive', CRM_Core_DAO
::$_nullObject);
864 CRM_Contribute_BAO_Contribution
::deleteContribution($contribId);