Commit | Line | Data |
---|---|---|
aaff4c69 EM |
1 | <?php |
2 | /* | |
4f6cdd27 | 3 | +--------------------------------------------------------------------+ |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
4f6cdd27 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
4f6cdd27 EM |
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 | +--------------------------------------------------------------------+ | |
aaff4c69 EM |
26 | */ |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
fa938177 | 31 | * @copyright CiviCRM LLC (c) 2004-2016 |
aaff4c69 EM |
32 | */ |
33 | class CRM_Financial_Form_Payment extends CRM_Core_Form { | |
1d1fee72 | 34 | |
35 | /** | |
36 | * @var int | |
37 | */ | |
38 | protected $_paymentProcessorID; | |
f61437d3 | 39 | protected $currency; |
c0fbe80f | 40 | public $_values = array(); |
1d1fee72 | 41 | |
42 | /** | |
43 | * @var array | |
44 | */ | |
45 | public $_paymentProcessor; | |
aaff4c69 EM |
46 | /** |
47 | * Set variables up before form is built. | |
aaff4c69 EM |
48 | */ |
49 | public function preProcess() { | |
50 | parent::preProcess(); | |
423b9af4 | 51 | |
d38c288e | 52 | $this->_values['custom_pre_id'] = CRM_Utils_Request::retrieve('pre_profile_id', 'Integer', $this); |
423b9af4 | 53 | |
aaff4c69 EM |
54 | $this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, |
55 | TRUE); | |
f61437d3 K |
56 | $this->currency = CRM_Utils_Request::retrieve('currency', 'String', CRM_Core_DAO::$_nullObject, |
57 | TRUE); | |
aaff4c69 EM |
58 | |
59 | $this->assignBillingType(); | |
60 | ||
a9768188 | 61 | $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID); |
1d1fee72 | 62 | |
aaff4c69 EM |
63 | CRM_Core_Payment_ProcessorForm::preProcess($this); |
64 | ||
bc44463a | 65 | self::addCreditCardJs(); |
aaff4c69 | 66 | |
bc44463a | 67 | $this->assign('paymentProcessorID', $this->_paymentProcessorID); |
f61437d3 | 68 | $this->assign('currency', $this->currency); |
d87cd28c CW |
69 | |
70 | $this->assign('suppressForm', TRUE); | |
a38068fe | 71 | $this->controller->_generateQFKey = FALSE; |
bc44463a CW |
72 | } |
73 | ||
f61437d3 K |
74 | /** |
75 | * @return string | |
76 | */ | |
77 | public function getCurrency() { | |
78 | return $this->currency; | |
79 | } | |
80 | ||
1d1fee72 | 81 | /** |
82 | * Build quickForm. | |
83 | */ | |
bc44463a CW |
84 | public function buildQuickForm() { |
85 | CRM_Core_Payment_ProcessorForm::buildQuickForm($this); | |
86 | } | |
87 | ||
70d1766d | 88 | /** |
89 | * Set default values for the form. | |
90 | */ | |
91 | public function setDefaultValues() { | |
92 | $contactID = $this->getContactID(); | |
93 | CRM_Core_Payment_Form::setDefaultValues($this, $contactID); | |
94 | return $this->_defaults; | |
95 | } | |
96 | ||
bc44463a | 97 | /** |
1d1fee72 | 98 | * Add JS to show icons for the accepted credit cards. |
bc44463a CW |
99 | */ |
100 | public static function addCreditCardJs() { | |
aaff4c69 EM |
101 | $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames(); |
102 | CRM_Core_Resources::singleton() | |
103 | ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10) | |
104 | // workaround for CRM-13634 | |
105 | // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes))); | |
106 | ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';'); | |
aaff4c69 EM |
107 | } |
108 | ||
109 | } |