CRM-16357 (Backoffice contribution Form) minor refactors
[civicrm-core.git] / CRM / Contribute / Form / AbstractEditPayment.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
14 | CiviCRM is distributed in the hope that it will be usefusul, 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. |
18 | |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035
TO
32 */
33
34/**
35 * This class generates form components for processing a contribution
803d4bc0 36 * CRM-16229 - During the event registration bulk action via search we
37 * need to inherit CRM_Contact_Form_Task so that we can inherit functions
38 * like getContactIds and make use of controller state. But this is not possible
39 * because CRM_Event_Form_Participant inherits this class.
40 * Ideal situation would be something like
41 * CRM_Event_Form_Participant extends CRM_Contact_Form_Task,
42 * CRM_Contribute_Form_AbstractEditPayment
43 * However this is not possible. Currently PHP does not support multiple
44 * inheritance. So work around solution is to extend this class with
45 * CRM_Contact_Form_Task which further extends CRM_Core_Form.
6a488035
TO
46 *
47 */
5b7c9ebc 48class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
6a488035
TO
49 public $_mode;
50
51 public $_action;
52
53 public $_bltID;
54
55 public $_fields;
56
a6513ad5
EM
57 /**
58 * @var array current payment processor including a copy of the object in 'object' key
59 */
6a488035
TO
60 public $_paymentProcessor;
61 public $_recurPaymentProcessors;
62
dc913073 63 /**
100fef9d 64 * Array of processor options in the format id => array($id => $label)
dc913073
EM
65 * WARNING it appears that the format used to differ to this and there are places in the code that
66 * expect the old format. $this->_paymentProcessors provides the additional data which this
67 * array seems to have provided in the past
68 * @var array
69 */
6a488035
TO
70 public $_processors;
71
72 /**
100fef9d 73 * Available payment processors with full details including the key 'object' indexed by their id
dc913073
EM
74 * @var array
75 */
76 protected $_paymentProcessors = array();
77 /**
fe482240 78 * The id of the contribution that we are processing.
6a488035
TO
79 *
80 * @var int
6a488035
TO
81 */
82 public $_id;
83
84 /**
fe482240 85 * The id of the premium that we are proceessing.
6a488035
TO
86 *
87 * @var int
6a488035
TO
88 */
89 public $_premiumID = NULL;
4691b077
EM
90
91 /**
92 * @var CRM_Contribute_DAO_ContributionProduct
93 */
6a488035
TO
94 public $_productDAO = NULL;
95
96 /**
100fef9d 97 * The id of the note
6a488035
TO
98 *
99 * @var int
6a488035
TO
100 */
101 public $_noteID;
102
103 /**
100fef9d 104 * The id of the contact associated with this contribution
6a488035
TO
105 *
106 * @var int
6a488035
TO
107 */
108 public $_contactID;
109
110 /**
100fef9d 111 * The id of the pledge payment that we are processing
6a488035
TO
112 *
113 * @var int
6a488035
TO
114 */
115 public $_ppID;
116
117 /**
100fef9d 118 * The id of the pledge that we are processing
6a488035
TO
119 *
120 * @var int
6a488035
TO
121 */
122 public $_pledgeID;
123
124 /**
100fef9d 125 * Is this contribution associated with an online
6a488035
TO
126 * financial transaction
127 *
128 * @var boolean
6a488035
TO
129 */
130 public $_online = FALSE;
131
132 /**
133 * Stores all product option
134 *
135 * @var array
6a488035
TO
136 */
137 public $_options;
138
139 /**
100fef9d 140 * Stores the honor id
6a488035
TO
141 *
142 * @var int
6a488035
TO
143 */
144 public $_honorID = NULL;
145
146 /**
dde5a0ef 147 * Store the financial Type ID
6a488035
TO
148 *
149 * @var array
150 */
151 public $_contributionType;
152
153 /**
154 * The contribution values if an existing contribution
155 */
156 public $_values;
157
158 /**
159 * The pledge values if this contribution is associated with pledge
160 */
161 public $_pledgeValues;
162
163 public $_contributeMode = 'direct';
164
165 public $_context;
166
167 public $_compId;
168
d424ffde 169 /**
6a488035
TO
170 * Store the line items if price set used.
171 */
172 public $_lineItems;
173
0be0b79d
EM
174 /**
175 * Is this a backoffice form
176 * (this will affect whether paypal express code is displayed)
177 * @var bool
178 */
179 public $isBackOffice = TRUE;
180
6a488035 181 protected $_formType;
dde5a0ef
EM
182
183 /**
184 * @var mystery variable screaming out for documentation
185 */
6a488035
TO
186 protected $_cdType;
187
dde5a0ef 188 /**
100fef9d 189 * Array of fields to display on billingBlock.tpl - this is not fully implemented but basically intent is the panes/fieldsets on this page should
dde5a0ef
EM
190 * be all in this array in order like
191 * 'credit_card' => array('credit_card_number' ...
192 * 'billing_details' => array('first_name' ...
193 *
194 * such that both the fields and the order can be more easily altered by payment processors & other extensions
195 * @var array
196 */
197 public $billingFieldSets = array();
198
186c9c17 199 /**
100fef9d 200 * @param int $id
186c9c17 201 */
d5397f2f
PJ
202 public function showRecordLinkMesssage($id) {
203 $statusId = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $id, 'contribution_status_id');
204 if (CRM_Contribute_PseudoConstant::contributionStatus($statusId, 'name') == 'Partially paid') {
205 if ($pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'participant_id', 'contribution_id')) {
206 $recordPaymentLink = CRM_Utils_System::url('civicrm/payment',
207 "reset=1&id={$pid}&cid={$this->_contactID}&action=add&component=event"
208 );
209 CRM_Core_Session::setStatus(ts('Please use the <a href="%1">Record Payment</a> form if you have received an additional payment for this Partially paid contribution record.', array(1 => $recordPaymentLink)), ts('Notice'), 'alert');
210 }
211 }
212 }
213
186c9c17 214 /**
100fef9d 215 * @param int $id
186c9c17
EM
216 * @param $values
217 */
6a488035
TO
218 public function buildValuesAndAssignOnline_Note_Type($id, &$values) {
219 $ids = array();
220 $params = array('id' => $id);
221 CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
222
223 //Check if this is an online transaction (financial_trxn.payment_processor_id NOT NULL)
224 $this->_online = FALSE;
225 $fids = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($id);
a7488080 226 if (!empty($fids['financialTrxnId'])) {
6a488035
TO
227 $this->_online = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $fids['financialTrxnId'], 'payment_processor_id');
228 }
eea16664 229
6a488035
TO
230 // Also don't allow user to update some fields for recurring contributions.
231 if (!$this->_online) {
232 $this->_online = CRM_Utils_Array::value('contribution_recur_id', $values);
233 }
eea16664 234
6a488035
TO
235 $this->assign('isOnline', $this->_online ? TRUE : FALSE);
236
6a488035
TO
237 //to get note id
238 $daoNote = new CRM_Core_BAO_Note();
239 $daoNote->entity_table = 'civicrm_contribution';
240 $daoNote->entity_id = $id;
241 if ($daoNote->find(TRUE)) {
242 $this->_noteID = $daoNote->id;
243 $values['note'] = $daoNote->note;
244 }
245 $this->_contributionType = $values['financial_type_id'];
6a488035
TO
246 }
247
248 /**
014c4014
TO
249 * @param string $type
250 * Eg 'Contribution'.
6a488035
TO
251 * @param string $subType
252 * @param int $entityId
253 */
254 public function applyCustomData($type, $subType, $entityId) {
255 $this->set('type', $type);
256 $this->set('subType', $subType);
257 $this->set('entityId', $entityId);
258
259 CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, 1, $type, $entityId);
260 CRM_Custom_Form_CustomData::buildQuickForm($this);
261 CRM_Custom_Form_CustomData::setDefaultValues($this);
262 }
263
4691b077 264 /**
100fef9d 265 * @param int $id
4691b077
EM
266 * @todo - this function is a long way, non standard of saying $dao = new CRM_Contribute_DAO_ContributionProduct(); $dao->id = $id; $dao->find();
267 */
6ea503d4 268 public function assignPremiumProduct($id) {
6a488035
TO
269 $sql = "
270SELECT *
271FROM civicrm_contribution_product
272WHERE contribution_id = {$id}
273";
274 $dao = CRM_Core_DAO::executeQuery($sql,
275 CRM_Core_DAO::$_nullArray
276 );
277 if ($dao->fetch()) {
278 $this->_premiumID = $dao->id;
279 $this->_productDAO = $dao;
280 }
281 $dao->free();
282 }
283
284 /**
285 * This function process contribution related objects.
03110609 286 *
014c4014
TO
287 * @param int $contributionId
288 * @param int $statusId
289 * @param int|null $previousStatusId
03110609
EM
290 *
291 * @return null|string
6a488035 292 */
35874a67 293 protected function updateRelatedComponent($contributionId, $statusId, $previousStatusId = NULL, $receiveDate = NULL) {
6a488035
TO
294 $statusMsg = NULL;
295 if (!$contributionId || !$statusId) {
296 return $statusMsg;
297 }
298
299 $params = array(
300 'contribution_id' => $contributionId,
301 'contribution_status_id' => $statusId,
302 'previous_contribution_status_id' => $previousStatusId,
35874a67 303 'receive_date' => $receiveDate,
6a488035
TO
304 );
305
306 $updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params);
307
308 if (!is_array($updateResult) ||
309 !($updatedComponents = CRM_Utils_Array::value('updatedComponents', $updateResult)) ||
310 !is_array($updatedComponents) ||
311 empty($updatedComponents)
312 ) {
313 return $statusMsg;
314 }
315
316 // get the user display name.
317 $sql = "
318 SELECT display_name as displayName
319 FROM civicrm_contact
320LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_contact.id )
321 WHERE civicrm_contribution.id = {$contributionId}";
322 $userDisplayName = CRM_Core_DAO::singleValueQuery($sql);
323
324 // get the status message for user.
325 foreach ($updatedComponents as $componentName => $updatedStatusId) {
326
327 if ($componentName == 'CiviMember') {
328 $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
329 CRM_Member_PseudoConstant::membershipStatus()
330 );
331 if ($updatedStatusName == 'Cancelled') {
332 $statusMsg .= "<br />" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName));
333 }
334 elseif ($updatedStatusName == 'Expired') {
335 $statusMsg .= "<br />" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName));
336 }
d008a264 337 else {
13299a2b
JM
338 $endDate = CRM_Utils_Array::value('membership_end_date', $updateResult);
339 if ($endDate) {
d008a264 340 $statusMsg .= "<br />" . ts("Membership for %1 has been updated. The membership End Date is %2.",
353ffa53
TO
341 array(
342 1 => $userDisplayName,
343 2 => $endDate,
344 )
345 );
d008a264 346 }
6a488035
TO
347 }
348 }
349
350 if ($componentName == 'CiviEvent') {
351 $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
352 CRM_Event_PseudoConstant::participantStatus()
353 );
354 if ($updatedStatusName == 'Cancelled') {
355 $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", array(1 => $userDisplayName));
356 }
357 elseif ($updatedStatusName == 'Registered') {
358 $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", array(1 => $userDisplayName));
359 }
360 }
361
362 if ($componentName == 'CiviPledge') {
363 $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
364 CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')
365 );
366 if ($updatedStatusName == 'Cancelled') {
367 $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", array(1 => $userDisplayName));
368 }
369 elseif ($updatedStatusName == 'Failed') {
370 $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", array(1 => $userDisplayName));
371 }
372 elseif ($updatedStatusName == 'Completed') {
373 $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", array(1 => $userDisplayName));
374 }
375 }
376 }
377
378 return $statusMsg;
379 }
380
381 /**
a6c01b45 382 * @return array
16b10e64 383 * Array of valid processors. The array resembles the DB table but also has 'object' as a key
fbcb6fba
EM
384 * @throws Exception
385 */
386 public function getValidProcessors() {
fbcb6fba
EM
387 $defaultID = NULL;
388 $capabilities = array('BackOffice');
52767de0
EM
389 if ($this->_mode) {
390 $capabilities[] = (ucfirst($this->_mode) . 'Mode');
fbcb6fba
EM
391 }
392 $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors($capabilities);
44b6505d
EM
393 return $processors;
394
6a488035
TO
395 }
396
397 /**
fe482240 398 * Assign billing type id to bltID.
6a488035 399 *
44b6505d 400 * @throws CRM_Core_Exception
6a488035
TO
401 * @return void
402 */
403 public function assignBillingType() {
180409a4 404 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
6a488035
TO
405 $this->_bltID = array_search('Billing', $locationTypes);
406 if (!$this->_bltID) {
44b6505d 407 throw new CRM_Core_Exception(ts('Please set a location type of %1', array(1 => 'Billing')));
6a488035
TO
408 }
409 $this->set('bltID', $this->_bltID);
410 $this->assign('bltID', $this->_bltID);
411 }
412
413 /**
414 * Assign $this->processors, $this->recurPaymentProcessors, and related Smarty variables
415 */
416 public function assignProcessors() {
417 //ensure that processor has a valid config
418 //only valid processors get display to user
44b6505d 419
6a488035 420 if ($this->_mode) {
52767de0 421 $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('supportsFutureRecurStartDate')));
dc913073
EM
422 $this->_paymentProcessors = $this->getValidProcessors();
423 if (!isset($this->_paymentProcessor['id'])) {
424 // if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default
425 $this->_paymentProcessor = reset($this->_paymentProcessors);
426 }
427 if (empty($this->_paymentProcessors)) {
44b6505d
EM
428 throw new CRM_Core_Exception(ts('You will need to configure the %1 settings for your Payment Processor before you can submit a credit card transactions.', array(1 => $this->_mode)));
429 }
353ffa53 430 $this->_processors = array();
dc913073 431 foreach ($this->_paymentProcessors as $id => $processor) {
44b6505d 432 $this->_processors[$id] = ts($processor['name']);
a5c78dea
EM
433 if (!empty($processor['description'])) {
434 $this->_processors[$id] .= ' : ' . ts($processor['description']);
435 }
44b6505d 436 }
6a488035 437 //get the valid recurring processors.
239b0928 438 $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
dd660b68 439 $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
5b67fa51 440 $this->_recurPaymentProcessors = array_intersect_key($this->_processors, $recurring);
6a488035
TO
441 }
442 $this->assign('recurringPaymentProcessorIds',
443 empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors))
444 );
445
446 // this required to show billing block
03110609 447 // @todo remove this assignment the billing block is now designed to be always included but will not show fieldsets unless those sets of fields are assigned
44b6505d 448 $this->assign_by_ref('paymentProcessor', $processor);
6a488035
TO
449 }
450
186c9c17 451 /**
6ea503d4
TO
452 * Get current currency from DB or use default currency.
453 *
186c9c17
EM
454 * @param $submittedValues
455 *
456 * @return mixed
457 */
6ea503d4 458 public function getCurrency($submittedValues) {
6a488035
TO
459 $config = CRM_Core_Config::singleton();
460
461 $currentCurrency = CRM_Utils_Array::value('currency',
462 $this->_values,
463 $config->defaultCurrency
464 );
465
466 // use submitted currency if present else use current currency
467 $result = CRM_Utils_Array::value('currency',
468 $submittedValues,
469 $currentCurrency
470 );
471 return $result;
472 }
473
186c9c17 474 /**
100fef9d 475 * @param int $financialTypeId
186c9c17
EM
476 *
477 * @return array
478 */
6a488035
TO
479 public function getFinancialAccounts($financialTypeId) {
480 $financialAccounts = array();
481 CRM_Core_PseudoConstant::populate($financialAccounts,
482 'CRM_Financial_DAO_EntityFinancialAccount',
483 $all = TRUE,
484 $retrieve = 'financial_account_id',
485 $filter = NULL,
486 " entity_id = {$financialTypeId} ", NULL, 'account_relationship');
487 return $financialAccounts;
488 }
489
186c9c17 490 /**
100fef9d
CW
491 * @param int $financialTypeId
492 * @param int $relationTypeId
186c9c17
EM
493 *
494 * @return mixed
495 */
6a488035
TO
496 public function getFinancialAccount($financialTypeId, $relationTypeId) {
497 $financialAccounts = $this->getFinancialAccounts($financialTypeId);
498 return CRM_Utils_Array::value($relationTypeId, $financialAccounts);
499 }
500
501 public function preProcessPledge() {
502 //get the payment values associated with given pledge payment id OR check for payments due.
503 $this->_pledgeValues = array();
504 if ($this->_ppID) {
505 $payParams = array('id' => $this->_ppID);
506
507 CRM_Pledge_BAO_PledgePayment::retrieve($payParams, $this->_pledgeValues['pledgePayment']);
508 $this->_pledgeID = CRM_Utils_Array::value('pledge_id', $this->_pledgeValues['pledgePayment']);
509 $paymentStatusID = CRM_Utils_Array::value('status_id', $this->_pledgeValues['pledgePayment']);
510 $this->_id = CRM_Utils_Array::value('contribution_id', $this->_pledgeValues['pledgePayment']);
511
512 //get all status
513 $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
514 if (!($paymentStatusID == array_search('Pending', $allStatus) || $paymentStatusID == array_search('Overdue', $allStatus))) {
515 CRM_Core_Error::fatal(ts("Pledge payment status should be 'Pending' or 'Overdue'."));
516 }
517
518 //get the pledge values associated with given pledge payment.
519
520 $ids = array();
521 $pledgeParams = array('id' => $this->_pledgeID);
522 CRM_Pledge_BAO_Pledge::getValues($pledgeParams, $this->_pledgeValues, $ids);
523 $this->assign('ppID', $this->_ppID);
524 }
525 else {
526 // Not making a pledge payment, so if adding a new contribution we should check if pledge payment(s) are due for this contact so we can alert the user. CRM-5206
527 if (isset($this->_contactID)) {
528 $contactPledges = CRM_Pledge_BAO_Pledge::getContactPledges($this->_contactID);
529
530 if (!empty($contactPledges)) {
531 $payments = $paymentsDue = NULL;
532 $multipleDue = FALSE;
533 foreach ($contactPledges as $key => $pledgeId) {
534 $payments = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
535 if ($payments) {
536 if ($paymentsDue) {
537 $multipleDue = TRUE;
538 break;
539 }
540 else {
541 $paymentsDue = $payments;
542 }
543 }
544 }
545 if ($multipleDue) {
546 // Show link to pledge tab since more than one pledge has a payment due
547 $pledgeTab = CRM_Utils_System::url('civicrm/contact/view',
548 "reset=1&force=1&cid={$this->_contactID}&selectedChild=pledge"
549 );
550 CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. <a href="%1">Click here to view their Pledges tab</a> and verify whether this contribution should be applied as a pledge payment.', array(1 => $pledgeTab)), ts('Notice'), 'alert');
551 }
552 elseif ($paymentsDue) {
553 // Show user link to oldest Pending or Overdue pledge payment
554 $ppAmountDue = CRM_Utils_Money::format($payments['amount'], $payments['currency']);
555 $ppSchedDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $payments['id'], 'scheduled_date'));
556 if ($this->_mode) {
557 $ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution',
558 "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge&mode=live"
559 );
560 }
561 else {
562 $ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution',
563 "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge"
564 );
565 }
566 CRM_Core_Session::setStatus(ts('This contact has a pending or overdue pledge payment of %2 which is scheduled for %3. <a href="%1">Click here to enter a pledge payment</a>.', array(
567 1 => $ppUrl,
568 2 => $ppAmountDue,
21dfd5f5 569 3 => $ppSchedDate,
6a488035
TO
570 )), ts('Notice'), 'alert');
571 }
572 }
573 }
574 }
575 }
576
186c9c17
EM
577 /**
578 * @param $submittedValues
579 *
580 * @return mixed
581 */
6a488035
TO
582 public function unsetCreditCardFields($submittedValues) {
583 //Offline Contribution.
584 $unsetParams = array(
585 'payment_processor_id',
586 "email-{$this->_bltID}",
587 'hidden_buildCreditCard',
588 'hidden_buildDirectDebit',
589 'billing_first_name',
590 'billing_middle_name',
591 'billing_last_name',
592 'street_address-5',
593 "city-{$this->_bltID}",
594 "state_province_id-{$this->_bltID}",
595 "postal_code-{$this->_bltID}",
596 "country_id-{$this->_bltID}",
597 'credit_card_number',
598 'cvv2',
599 'credit_card_exp_date',
600 'credit_card_type',
601 );
602 foreach ($unsetParams as $key) {
603 if (isset($submittedValues[$key])) {
604 unset($submittedValues[$key]);
605 }
606 }
607 return $submittedValues;
608 }
609
cc984198 610 /**
100fef9d 611 * Common block for setting up the parts of a form that relate to credit / debit card
cc984198
EM
612 * @throws Exception
613 */
614 protected function assignPaymentRelatedVariables() {
615 try {
99efbbf8
EM
616 if ($this->_contactID) {
617 list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
618 $this->assign('displayName', $this->userDisplayName);
619 }
cc984198
EM
620 if ($this->_mode) {
621 $this->assignProcessors();
cc984198
EM
622
623 $this->assignBillingType();
624
625 $this->_fields = array();
626 CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
627 }
628 }
629 catch (CRM_Core_Exception $e) {
630 CRM_Core_Error::fatal($e->getMessage());
631 }
632 }
96025800 633
6a488035 634}