Remove usage of deprecated function from paypal
[civicrm-core.git] / CRM / Core / Payment.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 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. |
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 +--------------------------------------------------------------------+
26 */
27
28 use Civi\Payment\System;
29 use Civi\Payment\Exception\PaymentProcessorException;
30
31 /**
32 * Class CRM_Core_Payment.
33 *
34 * This class is the main class for the payment processor subsystem.
35 *
36 * It is the parent class for payment processors. It also holds some IPN related functions
37 * that need to be moved. In particular handlePaymentMethod should be moved to a factory class.
38 */
39 abstract class CRM_Core_Payment {
40
41 /**
42 * Component - ie. event or contribute.
43 *
44 * This is used for setting return urls.
45 *
46 * @var string
47 */
48 protected $_component;
49
50 /**
51 * How are we getting billing information.
52 *
53 * We are trying to completely deprecate these parameters.
54 *
55 * FORM - we collect it on the same page
56 * BUTTON - the processor collects it and sends it back to us via some protocol
57 */
58 const
59 BILLING_MODE_FORM = 1,
60 BILLING_MODE_BUTTON = 2,
61 BILLING_MODE_NOTIFY = 4;
62
63 /**
64 * Which payment type(s) are we using?
65 *
66 * credit card
67 * direct debit
68 * or both
69 * @todo create option group - nb omnipay uses a 3rd type - transparent redirect cc
70 */
71 const
72 PAYMENT_TYPE_CREDIT_CARD = 1,
73 PAYMENT_TYPE_DIRECT_DEBIT = 2;
74
75 /**
76 * Subscription / Recurring payment Status
77 * START, END
78 */
79 const
80 RECURRING_PAYMENT_START = 'START',
81 RECURRING_PAYMENT_END = 'END';
82
83 protected $_paymentProcessor;
84
85 /**
86 * Base url of the calling form (offsite processors).
87 *
88 * @var string
89 */
90 protected $baseReturnUrl;
91
92 /**
93 * Return url upon success (offsite processors).
94 *
95 * @var string
96 */
97 protected $successUrl;
98
99 /**
100 * Return url upon failure (offsite processors).
101 *
102 * @var string
103 */
104 protected $cancelUrl;
105
106 /**
107 * Processor type label.
108 *
109 * (Deprecated parameter but used in some messages).
110 *
111 * @deprecated
112 *
113 * @var string
114 */
115 public $_processorName;
116
117 /**
118 * The profile configured to show on the billing form.
119 *
120 * Currently only the pseudo-profile 'billing' is supported but hopefully in time we will take an id and
121 * load that from the DB and the processor will be able to return a set of fields that combines it's minimum
122 * requirements with the configured requirements.
123 *
124 * Currently only the pseudo-processor 'manual' or 'pay-later' uses this setting to return a 'curated' set
125 * of fields.
126 *
127 * Note this change would probably include converting 'billing' to a reserved profile.
128 *
129 * @var int|string
130 */
131 protected $billingProfile;
132
133 /**
134 * Payment instrument ID.
135 *
136 * This is normally retrieved from the payment_processor table.
137 *
138 * @var int
139 */
140 protected $paymentInstrumentID;
141
142 /**
143 * Is this a back office transaction.
144 *
145 * @var bool
146 */
147 protected $backOffice = FALSE;
148
149 /**
150 * @return bool
151 */
152 public function isBackOffice() {
153 return $this->backOffice;
154 }
155
156 /**
157 * Set back office property.
158 *
159 * @param bool $isBackOffice
160 */
161 public function setBackOffice($isBackOffice) {
162 $this->backOffice = $isBackOffice;
163 }
164
165 /**
166 * Get payment instrument id.
167 *
168 * @return int
169 */
170 public function getPaymentInstrumentID() {
171 return $this->paymentInstrumentID ? $this->paymentInstrumentID : $this->_paymentProcessor['payment_instrument_id'];
172 }
173
174 /**
175 * Set payment Instrument id.
176 *
177 * By default we actually ignore the form value. The manual processor takes it more seriously.
178 *
179 * @param int $paymentInstrumentID
180 */
181 public function setPaymentInstrumentID($paymentInstrumentID) {
182 $this->paymentInstrumentID = $this->_paymentProcessor['payment_instrument_id'];
183 }
184
185 /**
186 * Set base return path (offsite processors).
187 *
188 * This is only useful with an internal civicrm form.
189 *
190 * @param string $url
191 * Internal civicrm path.
192 */
193 public function setBaseReturnUrl($url) {
194 $this->baseReturnUrl = $url;
195 }
196
197 /**
198 * Set success return URL (offsite processors).
199 *
200 * This overrides $baseReturnUrl
201 *
202 * @param string $url
203 * Full url of site to return browser to upon success.
204 */
205 public function setSuccessUrl($url) {
206 $this->successUrl = $url;
207 }
208
209 /**
210 * Set cancel return URL (offsite processors).
211 *
212 * This overrides $baseReturnUrl
213 *
214 * @param string $url
215 * Full url of site to return browser to upon failure.
216 */
217 public function setCancelUrl($url) {
218 $this->cancelUrl = $url;
219 }
220
221 /**
222 * Set the configured payment profile.
223 *
224 * @param int|string $value
225 */
226 public function setBillingProfile($value) {
227 $this->billingProfile = $value;
228 }
229
230 /**
231 * Opportunity for the payment processor to override the entire form build.
232 *
233 * @param CRM_Core_Form $form
234 *
235 * @return bool
236 * Should form building stop at this point?
237 */
238 public function buildForm(&$form) {
239 return FALSE;
240 }
241
242 /**
243 * Log payment notification message to forensic system log.
244 *
245 * @todo move to factory class \Civi\Payment\System (or similar)
246 *
247 * @param array $params
248 *
249 * @return mixed
250 */
251 public static function logPaymentNotification($params) {
252 $message = 'payment_notification ';
253 if (!empty($params['processor_name'])) {
254 $message .= 'processor_name=' . $params['processor_name'];
255 }
256 if (!empty($params['processor_id'])) {
257 $message .= 'processor_id=' . $params['processor_id'];
258 }
259
260 $log = new CRM_Utils_SystemLogger();
261 $log->alert($message, $_REQUEST);
262 }
263
264 /**
265 * Check if capability is supported.
266 *
267 * Capabilities have a one to one relationship with capability-related functions on this class.
268 *
269 * Payment processor classes should over-ride the capability-specific function rather than this one.
270 *
271 * @param string $capability
272 * E.g BackOffice, LiveMode, FutureRecurStartDate.
273 *
274 * @return bool
275 */
276 public function supports($capability) {
277 $function = 'supports' . ucfirst($capability);
278 if (method_exists($this, $function)) {
279 return $this->$function();
280 }
281 return FALSE;
282 }
283
284 /**
285 * Are back office payments supported.
286 *
287 * e.g paypal standard won't permit you to enter a credit card associated
288 * with someone else's login.
289 * The intention is to support off-site (other than paypal) & direct debit but that is not all working yet so to
290 * reach a 'stable' point we disable.
291 *
292 * @return bool
293 */
294 protected function supportsBackOffice() {
295 if ($this->_paymentProcessor['billing_mode'] == 4 || $this->_paymentProcessor['payment_type'] != 1) {
296 return FALSE;
297 }
298 else {
299 return TRUE;
300 }
301 }
302
303 /**
304 * Can more than one transaction be processed at once?
305 *
306 * In general processors that process payment by server to server communication support this while others do not.
307 *
308 * In future we are likely to hit an issue where this depends on whether a token already exists.
309 *
310 * @return bool
311 */
312 protected function supportsMultipleConcurrentPayments() {
313 if ($this->_paymentProcessor['billing_mode'] == 4 || $this->_paymentProcessor['payment_type'] != 1) {
314 return FALSE;
315 }
316 else {
317 return TRUE;
318 }
319 }
320
321 /**
322 * Are live payments supported - e.g dummy doesn't support this.
323 *
324 * @return bool
325 */
326 protected function supportsLiveMode() {
327 return TRUE;
328 }
329
330 /**
331 * Are test payments supported.
332 *
333 * @return bool
334 */
335 protected function supportsTestMode() {
336 return TRUE;
337 }
338
339 /**
340 * Should the first payment date be configurable when setting up back office recurring payments.
341 *
342 * We set this to false for historical consistency but in fact most new processors use tokens for recurring and can support this
343 *
344 * @return bool
345 */
346 protected function supportsFutureRecurStartDate() {
347 return FALSE;
348 }
349
350 /**
351 * Does this processor support cancelling recurring contributions through code.
352 *
353 * If the processor returns true it must be possible to take action from within CiviCRM
354 * that will result in no further payments being processed. In the case of token processors (e.g
355 * IATS, eWay) updating the contribution_recur table is probably sufficient.
356 *
357 * @return bool
358 */
359 protected function supportsCancelRecurring() {
360 return method_exists(CRM_Utils_System::getClassName($this), 'cancelSubscription');
361 }
362
363 /**
364 * Does this processor support pre-approval.
365 *
366 * This would generally look like a redirect to enter credentials which can then be used in a later payment call.
367 *
368 * Currently Paypal express supports this, with a redirect to paypal after the 'Main' form is submitted in the
369 * contribution page. This token can then be processed at the confirm phase. Although this flow 'looks' like the
370 * 'notify' flow a key difference is that in the notify flow they don't have to return but in this flow they do.
371 *
372 * @return bool
373 */
374 protected function supportsPreApproval() {
375 return FALSE;
376 }
377
378 /**
379 * Can recurring contributions be set against pledges.
380 *
381 * In practice all processors that use the baseIPN function to finish transactions or
382 * call the completetransaction api support this by looking up previous contributions in the
383 * series and, if there is a prior contribution against a pledge, and the pledge is not complete,
384 * adding the new payment to the pledge.
385 *
386 * However, only enabling for processors it has been tested against.
387 *
388 * @return bool
389 */
390 protected function supportsRecurContributionsForPledges() {
391 return FALSE;
392 }
393
394 /**
395 * Function to action pre-approval if supported
396 *
397 * @param array $params
398 * Parameters from the form
399 *
400 * This function returns an array which should contain
401 * - pre_approval_parameters (this will be stored on the calling form & available later)
402 * - redirect_url (if set the browser will be redirected to this.
403 */
404 public function doPreApproval(&$params) {}
405
406 /**
407 * Get any details that may be available to the payment processor due to an approval process having happened.
408 *
409 * In some cases the browser is redirected to enter details on a processor site. Some details may be available as a
410 * result.
411 *
412 * @param array $storedDetails
413 *
414 * @return array
415 */
416 public function getPreApprovalDetails($storedDetails) {
417 return array();
418 }
419
420 /**
421 * Default payment instrument validation.
422 *
423 * Implement the usual Luhn algorithm via a static function in the CRM_Core_Payment_Form if it's a credit card
424 * Not a static function, because I need to check for payment_type.
425 *
426 * @param array $values
427 * @param array $errors
428 */
429 public function validatePaymentInstrument($values, &$errors) {
430 CRM_Core_Form::validateMandatoryFields($this->getMandatoryFields(), $values, $errors);
431 if ($this->_paymentProcessor['payment_type'] == 1) {
432 CRM_Core_Payment_Form::validateCreditCard($values, $errors, $this->_paymentProcessor['id']);
433 }
434 }
435
436 /**
437 * Getter for the payment processor.
438 *
439 * The payment processor array is based on the civicrm_payment_processor table entry.
440 *
441 * @return array
442 * Payment processor array.
443 */
444 public function getPaymentProcessor() {
445 return $this->_paymentProcessor;
446 }
447
448 /**
449 * Setter for the payment processor.
450 *
451 * @param array $processor
452 */
453 public function setPaymentProcessor($processor) {
454 $this->_paymentProcessor = $processor;
455 }
456
457 /**
458 * Setter for the payment form that wants to use the processor.
459 *
460 * @deprecated
461 *
462 * @param CRM_Core_Form $paymentForm
463 */
464 public function setForm(&$paymentForm) {
465 $this->_paymentForm = $paymentForm;
466 }
467
468 /**
469 * Getter for payment form that is using the processor.
470 * @deprecated
471 * @return CRM_Core_Form
472 * A form object
473 */
474 public function getForm() {
475 return $this->_paymentForm;
476 }
477
478 /**
479 * Get help text information (help, description, etc.) about this payment,
480 * to display to the user.
481 *
482 * @param string $context
483 * Context of the text.
484 * Only explicitly supported contexts are handled without error.
485 * Currently supported:
486 * - contributionPageRecurringHelp (params: is_recur_installments, is_email_receipt)
487 *
488 * @param array $params
489 * Parameters for the field, context specific.
490 *
491 * @return string
492 */
493 public function getText($context, $params) {
494 // I have deliberately added a noisy fail here.
495 // The function is intended to be extendable, but not by changes
496 // not documented clearly above.
497 switch ($context) {
498 case 'contributionPageRecurringHelp':
499 // require exactly two parameters
500 if (array_keys($params) == array('is_recur_installments', 'is_email_receipt')) {
501 $gotText = ts('Your recurring contribution will be processed automatically.');
502 if ($params['is_recur_installments']) {
503 $gotText .= ' ' . ts('You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.');
504 }
505 if ($params['is_email_receipt']) {
506 $gotText .= ' ' . ts('You will receive an email receipt for each recurring contribution.');
507 }
508 }
509 break;
510 }
511 return $gotText;
512 }
513
514 /**
515 * Getter for accessing member vars.
516 *
517 * @todo believe this is unused
518 *
519 * @param string $name
520 *
521 * @return null
522 */
523 public function getVar($name) {
524 return isset($this->$name) ? $this->$name : NULL;
525 }
526
527 /**
528 * Get name for the payment information type.
529 * @todo - use option group + name field (like Omnipay does)
530 * @return string
531 */
532 public function getPaymentTypeName() {
533 return $this->_paymentProcessor['payment_type'] == 1 ? 'credit_card' : 'direct_debit';
534 }
535
536 /**
537 * Get label for the payment information type.
538 * @todo - use option group + labels (like Omnipay does)
539 * @return string
540 */
541 public function getPaymentTypeLabel() {
542 return $this->_paymentProcessor['payment_type'] == 1 ? 'Credit Card' : 'Direct Debit';
543 }
544
545 /**
546 * Get array of fields that should be displayed on the payment form.
547 *
548 * Common results are
549 * array('credit_card_type', 'credit_card_number', 'cvv2', 'credit_card_exp_date')
550 * or
551 * array('account_holder', 'bank_account_number', 'bank_identification_number', 'bank_name')
552 * or
553 * array()
554 *
555 * @return array
556 * Array of payment fields appropriate to the payment processor.
557 *
558 * @throws CiviCRM_API3_Exception
559 */
560 public function getPaymentFormFields() {
561 if ($this->_paymentProcessor['billing_mode'] == 4) {
562 return array();
563 }
564 return $this->_paymentProcessor['payment_type'] == 1 ? $this->getCreditCardFormFields() : $this->getDirectDebitFormFields();
565 }
566
567 /**
568 * Get an array of the fields that can be edited on the recurring contribution.
569 *
570 * Some payment processors support editing the amount and other scheduling details of recurring payments, especially
571 * those which use tokens. Others are fixed. This function allows the processor to return an array of the fields that
572 * can be updated from the contribution recur edit screen.
573 *
574 * The fields are likely to be a subset of these
575 * - 'amount',
576 * - 'installments',
577 * - 'frequency_interval',
578 * - 'frequency_unit',
579 * - 'cycle_day',
580 * - 'next_sched_contribution_date',
581 * - 'end_date',
582 * - 'failure_retry_day',
583 *
584 * The form does not restrict which fields from the contribution_recur table can be added (although if the html_type
585 * metadata is not defined in the xml for the field it will cause an error.
586 *
587 * Open question - would it make sense to return membership_id in this - which is sometimes editable and is on that
588 * form (UpdateSubscription).
589 *
590 * @return array
591 */
592 public function getEditableRecurringScheduleFields() {
593 if (method_exists($this, 'changeSubscriptionAmount')) {
594 return array('amount');
595 }
596 }
597
598 /**
599 * Get the help text to present on the recurring update page.
600 *
601 * This should reflect what can or cannot be edited.
602 *
603 * @return string
604 */
605 public function getRecurringScheduleUpdateHelpText() {
606 if (!in_array('amount', $this->getEditableRecurringScheduleFields())) {
607 return ts('Updates made using this form will change the recurring contribution information stored in your CiviCRM database, but will NOT be sent to the payment processor. You must enter the same changes using the payment processor web site.');
608 }
609 return ts('Use this form to change the amount or number of installments for this recurring contribution. Changes will be automatically sent to the payment processor. You can not change the contribution frequency.');
610 }
611
612 /**
613 * Get the metadata for all required fields.
614 *
615 * @return array;
616 */
617 protected function getMandatoryFields() {
618 $mandatoryFields = array();
619 foreach ($this->getAllFields() as $field_name => $field_spec) {
620 if (!empty($field_spec['is_required'])) {
621 $mandatoryFields[$field_name] = $field_spec;
622 }
623 }
624 return $mandatoryFields;
625 }
626
627 /**
628 * Get the metadata of all the fields configured for this processor.
629 *
630 * @return array
631 */
632 protected function getAllFields() {
633 $paymentFields = array_intersect_key($this->getPaymentFormFieldsMetadata(), array_flip($this->getPaymentFormFields()));
634 $billingFields = array_intersect_key($this->getBillingAddressFieldsMetadata(), array_flip($this->getBillingAddressFields()));
635 return array_merge($paymentFields, $billingFields);
636 }
637 /**
638 * Get array of fields that should be displayed on the payment form for credit cards.
639 *
640 * @return array
641 */
642 protected function getCreditCardFormFields() {
643 return array(
644 'credit_card_type',
645 'credit_card_number',
646 'cvv2',
647 'credit_card_exp_date',
648 );
649 }
650
651 /**
652 * Get array of fields that should be displayed on the payment form for direct debits.
653 *
654 * @return array
655 */
656 protected function getDirectDebitFormFields() {
657 return array(
658 'account_holder',
659 'bank_account_number',
660 'bank_identification_number',
661 'bank_name',
662 );
663 }
664
665 /**
666 * Return an array of all the details about the fields potentially required for payment fields.
667 *
668 * Only those determined by getPaymentFormFields will actually be assigned to the form
669 *
670 * @return array
671 * field metadata
672 */
673 public function getPaymentFormFieldsMetadata() {
674 //@todo convert credit card type into an option value
675 $creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard();
676 $isCVVRequired = Civi::settings()->get('cvv_backoffice_required');
677 if (!$this->isBackOffice()) {
678 $isCVVRequired = TRUE;
679 }
680 return array(
681 'credit_card_number' => array(
682 'htmlType' => 'text',
683 'name' => 'credit_card_number',
684 'title' => ts('Card Number'),
685 'cc_field' => TRUE,
686 'attributes' => array(
687 'size' => 20,
688 'maxlength' => 20,
689 'autocomplete' => 'off',
690 'class' => 'creditcard',
691 ),
692 'is_required' => TRUE,
693 ),
694 'cvv2' => array(
695 'htmlType' => 'text',
696 'name' => 'cvv2',
697 'title' => ts('Security Code'),
698 'cc_field' => TRUE,
699 'attributes' => array(
700 'size' => 5,
701 'maxlength' => 10,
702 'autocomplete' => 'off',
703 ),
704 'is_required' => $isCVVRequired,
705 'rules' => array(
706 array(
707 'rule_message' => ts('Please enter a valid value for your card security code. This is usually the last 3-4 digits on the card\'s signature panel.'),
708 'rule_name' => 'integer',
709 'rule_parameters' => NULL,
710 ),
711 ),
712 ),
713 'credit_card_exp_date' => array(
714 'htmlType' => 'date',
715 'name' => 'credit_card_exp_date',
716 'title' => ts('Expiration Date'),
717 'cc_field' => TRUE,
718 'attributes' => CRM_Core_SelectValues::date('creditCard'),
719 'is_required' => TRUE,
720 'rules' => array(
721 array(
722 'rule_message' => ts('Card expiration date cannot be a past date.'),
723 'rule_name' => 'currentDate',
724 'rule_parameters' => TRUE,
725 ),
726 ),
727 ),
728 'credit_card_type' => array(
729 'htmlType' => 'select',
730 'name' => 'credit_card_type',
731 'title' => ts('Card Type'),
732 'cc_field' => TRUE,
733 'attributes' => $creditCardType,
734 'is_required' => FALSE,
735 ),
736 'account_holder' => array(
737 'htmlType' => 'text',
738 'name' => 'account_holder',
739 'title' => ts('Account Holder'),
740 'cc_field' => TRUE,
741 'attributes' => array(
742 'size' => 20,
743 'maxlength' => 34,
744 'autocomplete' => 'on',
745 ),
746 'is_required' => TRUE,
747 ),
748 //e.g. IBAN can have maxlength of 34 digits
749 'bank_account_number' => array(
750 'htmlType' => 'text',
751 'name' => 'bank_account_number',
752 'title' => ts('Bank Account Number'),
753 'cc_field' => TRUE,
754 'attributes' => array(
755 'size' => 20,
756 'maxlength' => 34,
757 'autocomplete' => 'off',
758 ),
759 'rules' => array(
760 array(
761 'rule_message' => ts('Please enter a valid Bank Identification Number (value must not contain punctuation characters).'),
762 'rule_name' => 'nopunctuation',
763 'rule_parameters' => NULL,
764 ),
765 ),
766 'is_required' => TRUE,
767 ),
768 //e.g. SWIFT-BIC can have maxlength of 11 digits
769 'bank_identification_number' => array(
770 'htmlType' => 'text',
771 'name' => 'bank_identification_number',
772 'title' => ts('Bank Identification Number'),
773 'cc_field' => TRUE,
774 'attributes' => array(
775 'size' => 20,
776 'maxlength' => 11,
777 'autocomplete' => 'off',
778 ),
779 'is_required' => TRUE,
780 'rules' => array(
781 array(
782 'rule_message' => ts('Please enter a valid Bank Identification Number (value must not contain punctuation characters).'),
783 'rule_name' => 'nopunctuation',
784 'rule_parameters' => NULL,
785 ),
786 ),
787 ),
788 'bank_name' => array(
789 'htmlType' => 'text',
790 'name' => 'bank_name',
791 'title' => ts('Bank Name'),
792 'cc_field' => TRUE,
793 'attributes' => array(
794 'size' => 20,
795 'maxlength' => 64,
796 'autocomplete' => 'off',
797 ),
798 'is_required' => TRUE,
799
800 ),
801 'check_number' => array(
802 'htmlType' => 'text',
803 'name' => 'check_number',
804 'title' => ts('Check Number'),
805 'is_required' => FALSE,
806 'cc_field' => TRUE,
807 'attributes' => NULL,
808 ),
809 'pan_truncation' => array(
810 'htmlType' => 'text',
811 'name' => 'pan_truncation',
812 'title' => ts('Last 4 digits of the card'),
813 'is_required' => FALSE,
814 'cc_field' => TRUE,
815 'attributes' => array(
816 'size' => 4,
817 'maxlength' => 4,
818 'minlength' => 4,
819 'autocomplete' => 'off',
820 ),
821 'rules' => array(
822 array(
823 'rule_message' => ts('Please enter valid last 4 digit card number.'),
824 'rule_name' => 'numeric',
825 'rule_parameters' => NULL,
826 ),
827 ),
828 ),
829 );
830 }
831
832 /**
833 * Get billing fields required for this processor.
834 *
835 * We apply the existing default of returning fields only for payment processor type 1. Processors can override to
836 * alter.
837 *
838 * @param int $billingLocationID
839 *
840 * @return array
841 */
842 public function getBillingAddressFields($billingLocationID = NULL) {
843 if (!$billingLocationID) {
844 // Note that although the billing id is passed around the forms the idea that it would be anything other than
845 // the result of the function below doesn't seem to have eventuated.
846 // So taking this as a param is possibly something to be removed in favour of the standard default.
847 $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
848 }
849 if ($this->_paymentProcessor['billing_mode'] != 1 && $this->_paymentProcessor['billing_mode'] != 3) {
850 return array();
851 }
852 return array(
853 'first_name' => 'billing_first_name',
854 'middle_name' => 'billing_middle_name',
855 'last_name' => 'billing_last_name',
856 'street_address' => "billing_street_address-{$billingLocationID}",
857 'city' => "billing_city-{$billingLocationID}",
858 'country' => "billing_country_id-{$billingLocationID}",
859 'state_province' => "billing_state_province_id-{$billingLocationID}",
860 'postal_code' => "billing_postal_code-{$billingLocationID}",
861 );
862 }
863
864 /**
865 * Get form metadata for billing address fields.
866 *
867 * @param int $billingLocationID
868 *
869 * @return array
870 * Array of metadata for address fields.
871 */
872 public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
873 if (!$billingLocationID) {
874 // Note that although the billing id is passed around the forms the idea that it would be anything other than
875 // the result of the function below doesn't seem to have eventuated.
876 // So taking this as a param is possibly something to be removed in favour of the standard default.
877 $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
878 }
879 $metadata = array();
880 $metadata['billing_first_name'] = array(
881 'htmlType' => 'text',
882 'name' => 'billing_first_name',
883 'title' => ts('Billing First Name'),
884 'cc_field' => TRUE,
885 'attributes' => array(
886 'size' => 30,
887 'maxlength' => 60,
888 'autocomplete' => 'off',
889 ),
890 'is_required' => TRUE,
891 );
892
893 $metadata['billing_middle_name'] = array(
894 'htmlType' => 'text',
895 'name' => 'billing_middle_name',
896 'title' => ts('Billing Middle Name'),
897 'cc_field' => TRUE,
898 'attributes' => array(
899 'size' => 30,
900 'maxlength' => 60,
901 'autocomplete' => 'off',
902 ),
903 'is_required' => FALSE,
904 );
905
906 $metadata['billing_last_name'] = array(
907 'htmlType' => 'text',
908 'name' => 'billing_last_name',
909 'title' => ts('Billing Last Name'),
910 'cc_field' => TRUE,
911 'attributes' => array(
912 'size' => 30,
913 'maxlength' => 60,
914 'autocomplete' => 'off',
915 ),
916 'is_required' => TRUE,
917 );
918
919 $metadata["billing_street_address-{$billingLocationID}"] = array(
920 'htmlType' => 'text',
921 'name' => "billing_street_address-{$billingLocationID}",
922 'title' => ts('Street Address'),
923 'cc_field' => TRUE,
924 'attributes' => array(
925 'size' => 30,
926 'maxlength' => 60,
927 'autocomplete' => 'off',
928 ),
929 'is_required' => TRUE,
930 );
931
932 $metadata["billing_city-{$billingLocationID}"] = array(
933 'htmlType' => 'text',
934 'name' => "billing_city-{$billingLocationID}",
935 'title' => ts('City'),
936 'cc_field' => TRUE,
937 'attributes' => array(
938 'size' => 30,
939 'maxlength' => 60,
940 'autocomplete' => 'off',
941 ),
942 'is_required' => TRUE,
943 );
944
945 $metadata["billing_state_province_id-{$billingLocationID}"] = array(
946 'htmlType' => 'chainSelect',
947 'title' => ts('State/Province'),
948 'name' => "billing_state_province_id-{$billingLocationID}",
949 'cc_field' => TRUE,
950 'is_required' => TRUE,
951 );
952
953 $metadata["billing_postal_code-{$billingLocationID}"] = array(
954 'htmlType' => 'text',
955 'name' => "billing_postal_code-{$billingLocationID}",
956 'title' => ts('Postal Code'),
957 'cc_field' => TRUE,
958 'attributes' => array(
959 'size' => 30,
960 'maxlength' => 60,
961 'autocomplete' => 'off',
962 ),
963 'is_required' => TRUE,
964 );
965
966 $metadata["billing_country_id-{$billingLocationID}"] = array(
967 'htmlType' => 'select',
968 'name' => "billing_country_id-{$billingLocationID}",
969 'title' => ts('Country'),
970 'cc_field' => TRUE,
971 'attributes' => array(
972 '' => ts('- select -'),
973 ) + CRM_Core_PseudoConstant::country(),
974 'is_required' => TRUE,
975 );
976 return $metadata;
977 }
978
979 /**
980 * Get base url dependent on component.
981 *
982 * (or preferably set it using the setter function).
983 *
984 * @return string
985 */
986 protected function getBaseReturnUrl() {
987 if ($this->baseReturnUrl) {
988 return $this->baseReturnUrl;
989 }
990 if ($this->_component == 'event') {
991 $baseURL = 'civicrm/event/register';
992 }
993 else {
994 $baseURL = 'civicrm/contribute/transact';
995 }
996 return $baseURL;
997 }
998
999 /**
1000 * Get the currency for the transaction.
1001 *
1002 * Handle any inconsistency about how it is passed in here.
1003 *
1004 * @param $params
1005 *
1006 * @return string
1007 */
1008 protected function getCurrency($params) {
1009 return CRM_Utils_Array::value('currencyID', $params, CRM_Utils_Array::value('currency', $params));
1010 }
1011
1012 /**
1013 * Get the currency for the transaction.
1014 *
1015 * Handle any inconsistency about how it is passed in here.
1016 *
1017 * @param $params
1018 *
1019 * @return string
1020 */
1021 protected function getAmount($params) {
1022 return CRM_Utils_Money::format($params['amount'], NULL, NULL, TRUE);
1023 }
1024
1025 /**
1026 * Get url to return to after cancelled or failed transaction.
1027 *
1028 * @param string $qfKey
1029 * @param int $participantID
1030 *
1031 * @return string cancel url
1032 */
1033 public function getCancelUrl($qfKey, $participantID) {
1034 if (isset($this->cancelUrl)) {
1035 return $this->cancelUrl;
1036 }
1037
1038 if ($this->_component == 'event') {
1039 return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
1040 'reset' => 1,
1041 'cc' => 'fail',
1042 'participantId' => $participantID,
1043 ),
1044 TRUE, NULL, FALSE
1045 );
1046 }
1047
1048 return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
1049 '_qf_Main_display' => 1,
1050 'qfKey' => $qfKey,
1051 'cancel' => 1,
1052 ),
1053 TRUE, NULL, FALSE
1054 );
1055 }
1056
1057 /**
1058 * Get URL to return the browser to on success.
1059 *
1060 * @param $qfKey
1061 *
1062 * @return string
1063 */
1064 protected function getReturnSuccessUrl($qfKey) {
1065 if (isset($this->successUrl)) {
1066 return $this->successUrl;
1067 }
1068
1069 return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
1070 '_qf_ThankYou_display' => 1,
1071 'qfKey' => $qfKey,
1072 ),
1073 TRUE, NULL, FALSE
1074 );
1075 }
1076
1077 /**
1078 * Get URL to return the browser to on failure.
1079 *
1080 * @param string $key
1081 * @param int $participantID
1082 * @param int $eventID
1083 *
1084 * @return string
1085 * URL for a failing transactor to be redirected to.
1086 */
1087 protected function getReturnFailUrl($key, $participantID = NULL, $eventID = NULL) {
1088 if (isset($this->cancelUrl)) {
1089 return $this->cancelUrl;
1090 }
1091
1092 $test = $this->_is_test ? '&action=preview' : '';
1093 if ($this->_component == "event") {
1094 return CRM_Utils_System::url('civicrm/event/register',
1095 "reset=1&cc=fail&participantId={$participantID}&id={$eventID}{$test}&qfKey={$key}",
1096 FALSE, NULL, FALSE
1097 );
1098 }
1099 else {
1100 return CRM_Utils_System::url('civicrm/contribute/transact',
1101 "_qf_Main_display=1&cancel=1&qfKey={$key}{$test}",
1102 FALSE, NULL, FALSE
1103 );
1104 }
1105 }
1106
1107 /**
1108 * Get URl for when the back button is pressed.
1109 *
1110 * @param $qfKey
1111 *
1112 * @return string url
1113 */
1114 protected function getGoBackUrl($qfKey) {
1115 return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
1116 '_qf_Confirm_display' => 'true',
1117 'qfKey' => $qfKey,
1118 ),
1119 TRUE, NULL, FALSE
1120 );
1121 }
1122
1123 /**
1124 * Get the notify (aka ipn, web hook or silent post) url.
1125 *
1126 * If there is no '.' in it we assume that we are dealing with localhost or
1127 * similar and it is unreachable from the web & hence invalid.
1128 *
1129 * @return string
1130 * URL to notify outcome of transaction.
1131 */
1132 protected function getNotifyUrl() {
1133 $url = CRM_Utils_System::url(
1134 'civicrm/payment/ipn/' . $this->_paymentProcessor['id'],
1135 array(),
1136 TRUE,
1137 NULL,
1138 FALSE
1139 );
1140 return (stristr($url, '.')) ? $url : '';
1141 }
1142
1143 /**
1144 * Calling this from outside the payment subsystem is deprecated - use doPayment.
1145 *
1146 * Does a server to server payment transaction.
1147 *
1148 * @param array $params
1149 * Assoc array of input parameters for this transaction.
1150 *
1151 * @return array
1152 * the result in an nice formatted array (or an error object - but throwing exceptions is preferred)
1153 */
1154 protected function doDirectPayment(&$params) {
1155 return $params;
1156 }
1157
1158 /**
1159 * Process payment - this function wraps around both doTransferPayment and doDirectPayment.
1160 *
1161 * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
1162 * more agnostic.
1163 *
1164 * Payment processors should set payment_status_id. This function adds some historical defaults ie. the
1165 * assumption that if a 'doDirectPayment' processors comes back it completed the transaction & in fact
1166 * doTransferCheckout would not traditionally come back.
1167 *
1168 * doDirectPayment does not do an immediate payment for Authorize.net or Paypal so the default is assumed
1169 * to be Pending.
1170 *
1171 * Once this function is fully rolled out then it will be preferred for processors to throw exceptions than to
1172 * return Error objects
1173 *
1174 * @param array $params
1175 *
1176 * @param string $component
1177 *
1178 * @return array
1179 * Result array
1180 *
1181 * @throws \Civi\Payment\Exception\PaymentProcessorException
1182 */
1183 public function doPayment(&$params, $component = 'contribute') {
1184 $this->_component = $component;
1185 $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate');
1186
1187 // If we have a $0 amount, skip call to processor and set payment_status to Completed.
1188 // Conceivably a processor might override this - perhaps for setting up a token - but we don't
1189 // have an example of that at the mome.
1190 if ($params['amount'] == 0) {
1191 $result['payment_status_id'] = array_search('Completed', $statuses);
1192 return $result;
1193 }
1194
1195 if ($this->_paymentProcessor['billing_mode'] == 4) {
1196 $result = $this->doTransferCheckout($params, $component);
1197 if (is_array($result) && !isset($result['payment_status_id'])) {
1198 $result['payment_status_id'] = array_search('Pending', $statuses);
1199 }
1200 }
1201 else {
1202 $result = $this->doDirectPayment($params, $component);
1203 if (is_array($result) && !isset($result['payment_status_id'])) {
1204 if (!empty($params['is_recur'])) {
1205 // See comment block.
1206 $result['payment_status_id'] = array_search('Pending', $statuses);
1207 }
1208 else {
1209 $result['payment_status_id'] = array_search('Completed', $statuses);
1210 }
1211 }
1212 }
1213 if (is_a($result, 'CRM_Core_Error')) {
1214 throw new PaymentProcessorException(CRM_Core_Error::getMessages($result));
1215 }
1216 return $result;
1217 }
1218
1219 /**
1220 * Query payment processor for details about a transaction.
1221 *
1222 * @param array $params
1223 * Array of parameters containing one of:
1224 * - trxn_id Id of an individual transaction.
1225 * - processor_id Id of a recurring contribution series as stored in the civicrm_contribution_recur table.
1226 *
1227 * @return array
1228 * Extra parameters retrieved.
1229 * Any parameters retrievable through this should be documented in the function comments at
1230 * CRM_Core_Payment::doQuery. Currently:
1231 * - fee_amount Amount of fee paid
1232 */
1233 public function doQuery($params) {
1234 return array();
1235 }
1236
1237 /**
1238 * This function checks to see if we have the right config values.
1239 *
1240 * @return string
1241 * the error message if any
1242 */
1243 abstract protected function checkConfig();
1244
1245 /**
1246 * Redirect for paypal.
1247 *
1248 * @todo move to paypal class or remove
1249 *
1250 * @param $paymentProcessor
1251 *
1252 * @return bool
1253 */
1254 public static function paypalRedirect(&$paymentProcessor) {
1255 if (!$paymentProcessor) {
1256 return FALSE;
1257 }
1258
1259 if (isset($_GET['payment_date']) &&
1260 isset($_GET['merchant_return_link']) &&
1261 CRM_Utils_Array::value('payment_status', $_GET) == 'Completed' &&
1262 $paymentProcessor['payment_processor_type'] == "PayPal_Standard"
1263 ) {
1264 return TRUE;
1265 }
1266
1267 return FALSE;
1268 }
1269
1270 /**
1271 * Handle incoming payment notification.
1272 *
1273 * IPNs, also called silent posts are notifications of payment outcomes or activity on an external site.
1274 *
1275 * @todo move to0 \Civi\Payment\System factory method
1276 * Page callback for civicrm/payment/ipn
1277 */
1278 public static function handleIPN() {
1279 self::handlePaymentMethod(
1280 'PaymentNotification',
1281 array(
1282 'processor_name' => @$_GET['processor_name'],
1283 'processor_id' => @$_GET['processor_id'],
1284 'mode' => @$_GET['mode'],
1285 )
1286 );
1287 CRM_Utils_System::civiExit();
1288 }
1289
1290 /**
1291 * Payment callback handler.
1292 *
1293 * The processor_name or processor_id is passed in.
1294 * Note that processor_id is more reliable as one site may have more than one instance of a
1295 * processor & ideally the processor will be validating the results
1296 * Load requested payment processor and call that processor's handle<$method> method
1297 *
1298 * @todo move to \Civi\Payment\System factory method
1299 *
1300 * @param string $method
1301 * 'PaymentNotification' or 'PaymentCron'
1302 * @param array $params
1303 *
1304 * @throws \CRM_Core_Exception
1305 * @throws \Exception
1306 */
1307 public static function handlePaymentMethod($method, $params = array()) {
1308 if (!isset($params['processor_id']) && !isset($params['processor_name'])) {
1309 $q = explode('/', CRM_Utils_Array::value(CRM_Core_Config::singleton()->userFrameworkURLVar, $_GET, ''));
1310 $lastParam = array_pop($q);
1311 if (is_numeric($lastParam)) {
1312 $params['processor_id'] = $_GET['processor_id'] = $lastParam;
1313 }
1314 else {
1315 self::logPaymentNotification($params);
1316 throw new CRM_Core_Exception("Either 'processor_id' (recommended) or 'processor_name' (deprecated) is required for payment callback.");
1317 }
1318 }
1319
1320 self::logPaymentNotification($params);
1321
1322 $sql = "SELECT ppt.class_name, ppt.name as processor_name, pp.id AS processor_id
1323 FROM civicrm_payment_processor_type ppt
1324 INNER JOIN civicrm_payment_processor pp
1325 ON pp.payment_processor_type_id = ppt.id
1326 AND pp.is_active";
1327
1328 if (isset($params['processor_id'])) {
1329 $sql .= " WHERE pp.id = %2";
1330 $args[2] = array($params['processor_id'], 'Integer');
1331 $notFound = ts("No active instances of payment processor %1 were found.", array(1 => $params['processor_id']));
1332 }
1333 else {
1334 // This is called when processor_name is passed - passing processor_id instead is recommended.
1335 $sql .= " WHERE ppt.name = %2 AND pp.is_test = %1";
1336 $args[1] = array(
1337 (CRM_Utils_Array::value('mode', $params) == 'test') ? 1 : 0,
1338 'Integer',
1339 );
1340 $args[2] = array($params['processor_name'], 'String');
1341 $notFound = ts("No active instances of payment processor '%1' were found.", array(1 => $params['processor_name']));
1342 }
1343
1344 $dao = CRM_Core_DAO::executeQuery($sql, $args);
1345
1346 // Check whether we found anything at all.
1347 if (!$dao->N) {
1348 CRM_Core_Error::fatal($notFound);
1349 }
1350
1351 $method = 'handle' . $method;
1352 $extension_instance_found = FALSE;
1353
1354 // In all likelihood, we'll just end up with the one instance returned here. But it's
1355 // possible we may get more. Hence, iterate through all instances ..
1356
1357 while ($dao->fetch()) {
1358 // Check pp is extension - is this still required - surely the singleton below handles it.
1359 $ext = CRM_Extension_System::singleton()->getMapper();
1360 if ($ext->isExtensionKey($dao->class_name)) {
1361 $paymentClass = $ext->keyToClass($dao->class_name, 'payment');
1362 require_once $ext->classToPath($paymentClass);
1363 }
1364
1365 $processorInstance = System::singleton()->getById($dao->processor_id);
1366
1367 // Should never be empty - we already established this processor_id exists and is active.
1368 if (empty($processorInstance)) {
1369 continue;
1370 }
1371
1372 // Does PP implement this method, and can we call it?
1373 if (!method_exists($processorInstance, $method) ||
1374 !is_callable(array($processorInstance, $method))
1375 ) {
1376 // on the off chance there is a double implementation of this processor we should keep looking for another
1377 // note that passing processor_id is more reliable & we should work to deprecate processor_name
1378 continue;
1379 }
1380
1381 // Everything, it seems, is ok - execute pp callback handler
1382 $processorInstance->$method();
1383 $extension_instance_found = TRUE;
1384 }
1385
1386 if (!$extension_instance_found) {
1387 $message = "No extension instances of the '%1' payment processor were found.<br />" .
1388 "%2 method is unsupported in legacy payment processors.";
1389 CRM_Core_Error::fatal(ts($message, array(1 => $params['processor_name'], 2 => $method)));
1390 }
1391 }
1392
1393 /**
1394 * Check whether a method is present ( & supported ) by the payment processor object.
1395 *
1396 * @deprecated - use $paymentProcessor->supports(array('cancelRecurring');
1397 *
1398 * @param string $method
1399 * Method to check for.
1400 *
1401 * @return bool
1402 */
1403 public function isSupported($method) {
1404 return method_exists(CRM_Utils_System::getClassName($this), $method);
1405 }
1406
1407 /**
1408 * Some processors replace the form submit button with their own.
1409 *
1410 * Returning false here will leave the button off front end forms.
1411 *
1412 * At this stage there is zero cross-over between back-office processors and processors that suppress the submit.
1413 */
1414 public function isSuppressSubmitButtons() {
1415 return FALSE;
1416 }
1417
1418 /**
1419 * Checks to see if invoice_id already exists in db.
1420 *
1421 * It's arguable if this belongs in the payment subsystem at all but since several processors implement it
1422 * it is better to standardise to being here.
1423 *
1424 * @param int $invoiceId The ID to check.
1425 *
1426 * @param null $contributionID
1427 * If a contribution exists pass in the contribution ID.
1428 *
1429 * @return bool
1430 * True if invoice ID otherwise exists, else false
1431 */
1432 protected function checkDupe($invoiceId, $contributionID = NULL) {
1433 $contribution = new CRM_Contribute_DAO_Contribution();
1434 $contribution->invoice_id = $invoiceId;
1435 if ($contributionID) {
1436 $contribution->whereAdd("id <> $contributionID");
1437 }
1438 return $contribution->find();
1439 }
1440
1441 /**
1442 * Get url for users to manage this recurring contribution for this processor.
1443 *
1444 * @param int $entityID
1445 * @param null $entity
1446 * @param string $action
1447 *
1448 * @return string
1449 */
1450 public function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel') {
1451 // Set URL
1452 switch ($action) {
1453 case 'cancel':
1454 $url = 'civicrm/contribute/unsubscribe';
1455 break;
1456
1457 case 'billing':
1458 //in notify mode don't return the update billing url
1459 if (!$this->isSupported('updateSubscriptionBillingInfo')) {
1460 return NULL;
1461 }
1462 $url = 'civicrm/contribute/updatebilling';
1463 break;
1464
1465 case 'update':
1466 $url = 'civicrm/contribute/updaterecur';
1467 break;
1468 }
1469
1470 $userId = CRM_Core_Session::singleton()->get('userID');
1471 $contactID = 0;
1472 $checksumValue = '';
1473 $entityArg = '';
1474
1475 // Find related Contact
1476 if ($entityID) {
1477 switch ($entity) {
1478 case 'membership':
1479 $contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id");
1480 $entityArg = 'mid';
1481 break;
1482
1483 case 'contribution':
1484 $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id");
1485 $entityArg = 'coid';
1486 break;
1487
1488 case 'recur':
1489 $sql = "
1490 SELECT DISTINCT con.contact_id
1491 FROM civicrm_contribution_recur rec
1492 INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
1493 WHERE rec.id = %1";
1494 $contactID = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($entityID, 'Integer')));
1495 $entityArg = 'crid';
1496 break;
1497 }
1498 }
1499
1500 // Add entity arguments
1501 if ($entityArg != '') {
1502 // Add checksum argument
1503 if ($contactID != 0 && $userId != $contactID) {
1504 $checksumValue = '&cs=' . CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
1505 }
1506 return CRM_Utils_System::url($url, "reset=1&{$entityArg}={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
1507 }
1508
1509 // Else login URL
1510 if ($this->isSupported('accountLoginURL')) {
1511 return $this->accountLoginURL();
1512 }
1513
1514 // Else default
1515 return isset($this->_paymentProcessor['url_recur']) ? $this->_paymentProcessor['url_recur'] : '';
1516 }
1517
1518 /**
1519 * Get description of payment to pass to processor.
1520 *
1521 * This is often what people see in the interface so we want to get
1522 * as much unique information in as possible within the field length (& presumably the early part of the field)
1523 *
1524 * People seeing these can be assumed to be advanced users so quantity of information probably trumps
1525 * having field names to clarify
1526 *
1527 * @param array $params
1528 * @param int $length
1529 *
1530 * @return string
1531 */
1532 protected function getPaymentDescription($params, $length = 24) {
1533 $parts = array('contactID', 'contributionID', 'description', 'billing_first_name', 'billing_last_name');
1534 $validParts = array();
1535 if (isset($params['description'])) {
1536 $uninformativeStrings = array(ts('Online Event Registration: '), ts('Online Contribution: '));
1537 $params['description'] = str_replace($uninformativeStrings, '', $params['description']);
1538 }
1539 foreach ($parts as $part) {
1540 if ((!empty($params[$part]))) {
1541 $validParts[] = $params[$part];
1542 }
1543 }
1544 return substr(implode('-', $validParts), 0, $length);
1545 }
1546
1547 /**
1548 * Checks if backoffice recurring edit is allowed
1549 *
1550 * @return bool
1551 */
1552 public function supportsEditRecurringContribution() {
1553 return FALSE;
1554 }
1555
1556 /**
1557 * Checks if payment processor supports recurring contributions
1558 *
1559 * @return bool
1560 */
1561 public function supportsRecurring() {
1562 if (!empty($this->_paymentProcessor['is_recur'])) {
1563 return TRUE;
1564 }
1565 return FALSE;
1566 }
1567
1568 /**
1569 * Should a receipt be sent out for a pending payment.
1570 *
1571 * e.g for traditional pay later & ones with a delayed settlement a pending receipt makes sense.
1572 */
1573 public function isSendReceiptForPending() {
1574 return FALSE;
1575 }
1576
1577 }