|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
$Id$ |
|
4
|
|
|
|
|
5
|
|
|
osCommerce, Open Source E-Commerce Solutions |
|
6
|
|
|
http://www.oscommerce.com |
|
7
|
|
|
|
|
8
|
|
|
Copyright (c) 2014 osCommerce |
|
9
|
|
|
|
|
10
|
|
|
Released under the GNU General Public License |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
if ( !class_exists('OSCOM_Braintree') ) { |
|
14
|
|
|
include(DIR_FS_CATALOG . 'includes/apps/braintree/OSCOM_Braintree.php'); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
class cm_account_braintree_cards { |
|
18
|
|
|
var $code; |
|
19
|
|
|
var $group; |
|
20
|
|
|
var $title; |
|
21
|
|
|
var $description; |
|
22
|
|
|
var $sort_order; |
|
23
|
|
|
var $enabled = false; |
|
24
|
|
|
var $_app; |
|
25
|
|
|
|
|
26
|
|
|
function cm_account_braintree_cards() { |
|
27
|
|
|
global $language; |
|
28
|
|
|
|
|
29
|
|
|
$this->_app = new OSCOM_Braintree(); |
|
30
|
|
|
$this->_app->loadLanguageFile('shop/account_cards_page.php'); |
|
31
|
|
|
|
|
32
|
|
|
$this->code = get_class($this); |
|
33
|
|
|
$this->group = basename(dirname(__FILE__)); |
|
34
|
|
|
|
|
35
|
|
|
$this->title = $this->_app->getDef('account_braintree_cards_title'); |
|
36
|
|
|
$this->description = $this->_app->getDef('account_braintree_cards_description') . '<div align="center">' . $this->_app->drawButton($this->_app->getDef('accouint_braintree_cards_legacy_admin_app_button'), tep_href_link('braintree.php', 'action=configure&module=CC'), 'primary', null, true) . '</div>'; |
|
37
|
|
|
|
|
38
|
|
|
if ( defined('MODULE_CONTENT_ACCOUNT_BRAINTREE_CARDS_SORT_ORDER') ) { |
|
39
|
|
|
$this->sort_order = MODULE_CONTENT_ACCOUNT_BRAINTREE_CARDS_SORT_ORDER; |
|
40
|
|
|
$this->enabled = defined('OSCOM_APP_PAYPAL_BRAINTREE_CC_STATUS') && in_array(OSCOM_APP_PAYPAL_BRAINTREE_CC_STATUS, array('1', '0')) ? true : false; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$this->public_title = $this->_app->getDef('account_braintree_cards_link_title'); |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
$braintree_enabled = false; |
|
46
|
|
|
|
|
47
|
|
|
if ( defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED) && in_array('braintree_cc.php', explode(';', MODULE_PAYMENT_INSTALLED)) ) { |
|
48
|
|
|
if ( !class_exists('braintree_cc') ) { |
|
49
|
|
|
include(DIR_FS_CATALOG . 'includes/languages/' . $language . '/modules/payment/braintree_cc.php'); |
|
50
|
|
|
include(DIR_FS_CATALOG . 'includes/modules/payment/braintree_cc.php'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$braintree_cc = new braintree_cc(); |
|
54
|
|
|
|
|
55
|
|
|
if ( $braintree_cc->enabled ) { |
|
56
|
|
|
if ( defined('OSCOM_APP_PAYPAL_BRAINTREE_CC_STATUS') ) { |
|
57
|
|
|
$braintree_enabled = true; |
|
58
|
|
|
|
|
59
|
|
View Code Duplication |
if ( OSCOM_APP_PAYPAL_BRAINTREE_CC_STATUS == '0' ) { |
|
|
|
|
|
|
60
|
|
|
$this->title .= ' [Sandbox]'; |
|
61
|
|
|
$this->public_title .= ' (' . $braintree_cc->code . '; Sandbox)'; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if (OSCOM_APP_PAYPAL_BRAINTREE_CC_CC_TOKENS == '0') { |
|
65
|
|
|
$braintree_enabled = false; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if ( $braintree_enabled !== true ) { |
|
72
|
|
|
$this->enabled = false; |
|
73
|
|
|
|
|
74
|
|
|
$this->description = '<div class="secWarning">' . $this->_app->getDef('account_braintree_cards_error_main_module') . '</div>' . $this->description; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
function execute() { |
|
79
|
|
|
global $oscTemplate; |
|
80
|
|
|
|
|
81
|
|
|
$oscTemplate->_data['account']['account']['links']['braintree_cards'] = array('title' => $this->public_title, |
|
82
|
|
|
'link' => tep_href_link('ext/modules/content/account/braintree/cards.php', '', 'SSL'), |
|
83
|
|
|
'icon' => 'newwin'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
function isEnabled() { |
|
87
|
|
|
return $this->enabled; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
function check() { |
|
91
|
|
|
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'OSCOM_APP_PAYPAL_BRAINTREE_CC_STATUS'"); |
|
92
|
|
|
if ( tep_db_num_rows($check_query) ) { |
|
93
|
|
|
$check = tep_db_fetch_array($check_query); |
|
94
|
|
|
|
|
95
|
|
|
return tep_not_null($check['configuration_value']); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
return false; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
function install() { |
|
102
|
|
|
tep_redirect(tep_href_link('braintree.php', 'action=configure')); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
function remove() { |
|
106
|
|
|
tep_redirect(tep_href_link('braintree.php', 'action=configure')); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
function keys() { |
|
110
|
|
|
return array('MODULE_CONTENT_ACCOUNT_BRAINTREE_CARDS_SORT_ORDER'); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
?> |
|
|
|
|
|
|
114
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: