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