These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | global $debug; |
||
4 | |||
5 | // Придумать какой статус должен быть у глобальных ответов, что бы не перекрывать статусы платежных систем |
||
6 | // Может добавить спецстатус "Ответ системы платежа" и парсить дальше getMessage |
||
7 | // см constants.php |
||
8 | |||
9 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
10 | |||
11 | if(!sn_module_get_active_count('payment')) { |
||
12 | sys_redirect('dark_matter.php'); |
||
13 | die(); |
||
14 | } |
||
15 | |||
16 | lng_include('payment'); |
||
17 | lng_include('infos'); |
||
18 | |||
19 | $template = gettemplate('metamatter', true); |
||
20 | |||
21 | $player_currency_default = classSupernova::$user_options[PLAYER_OPTION_CURRENCY_DEFAULT]; |
||
22 | $player_currency = sys_get_param_str('player_currency', $player_currency_default); |
||
23 | empty(classLocale::$lang['pay_currency_list'][$player_currency]) ? ($player_currency = $player_currency_default ? $player_currency_default : classSupernova::$config->payment_currency_default) : false; |
||
24 | $player_currency_default != $player_currency ? classSupernova::$user_options[PLAYER_OPTION_CURRENCY_DEFAULT] = $player_currency : false; |
||
25 | |||
26 | // Таблица скидок |
||
27 | $prev_discount = 0; |
||
28 | if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
||
29 | foreach(sn_module_payment::$bonus_table as $sum => $discount) { |
||
30 | if($discount && $discount != $prev_discount) { |
||
31 | $template->assign_block_vars('discount', array( |
||
32 | 'SUM' => $sum, |
||
33 | 'DISCOUNT' => $discount * 100, |
||
34 | 'DISCOUNT_ONE' => 1 + $discount, |
||
35 | 'TEXT' => sprintf(classLocale::$lang['pay_mm_bonus_each'], pretty_number($sum), round($discount * 100)), |
||
36 | )); |
||
37 | $prev_discount = $discount; |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
42 | // Результат платежа |
||
43 | if($payment_id = sys_get_param_id('payment_id')) { |
||
44 | $payment = db_payment_get($payment_id); |
||
45 | if($payment && $payment['payment_user_id'] == $user['id']) { |
||
46 | View Code Duplication | if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
47 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained']))); |
||
48 | } |
||
49 | View Code Duplication | if($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
50 | $template->assign_block_vars('result', array( |
||
51 | 'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']), |
||
52 | 'STATUS' => 1, |
||
53 | )); |
||
54 | } |
||
55 | if($payment['payment_test']) { |
||
56 | $template->assign_block_vars('result', array( |
||
57 | 'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_test']), |
||
58 | 'STATUS' => -1, |
||
59 | )); |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | |||
64 | $unit_available_amount_list = &sn_module_payment::$bonus_table; |
||
65 | |||
66 | $request = array( |
||
67 | 'metamatter' => sys_get_param_float('metamatter'), |
||
68 | ); |
||
69 | |||
70 | if(!$request['metamatter']) { |
||
71 | unset($_POST); |
||
72 | } |
||
73 | |||
74 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
||
75 | array_walk($payment_methods_available, function (&$value, $index) { |
||
76 | $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value; |
||
77 | }); |
||
78 | |||
79 | // pdump($payment_methods_available); |
||
80 | $payment_module_valid = false; |
||
81 | $payment_module = sys_get_param_str('payment_module'); |
||
82 | foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) { |
||
83 | if(!is_object($module) || !$module->manifest['active']) { |
||
84 | continue; |
||
85 | } |
||
86 | |||
87 | lng_include($module_name, $module->manifest['root_relative']); |
||
88 | |||
89 | foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
||
90 | foreach($available_methods as $payment_method => $payment_currency) { |
||
91 | if(isset($module->manifest['payment_method'][$payment_method])) { |
||
92 | $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method]; |
||
93 | } |
||
94 | } |
||
95 | } |
||
96 | |||
97 | $payment_module_valid = $payment_module_valid || $module_name == $payment_module; |
||
98 | } |
||
99 | |||
100 | global $template_result; |
||
101 | // Доступные платежные методы |
||
102 | foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
||
103 | if(empty($payment_methods)) { |
||
104 | continue; |
||
105 | } |
||
106 | |||
107 | $template_result['.']['payment'][$payment_type_id] = array( |
||
108 | 'ID' => $payment_type_id, |
||
109 | 'NAME' => classLocale::$lang['pay_methods'][$payment_type_id], |
||
110 | ); |
||
111 | foreach($payment_methods as $payment_method_id => $module_list) { |
||
112 | if(empty($module_list)) { |
||
113 | continue; |
||
114 | } |
||
115 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array( |
||
116 | 'ID' => $payment_method_id, |
||
117 | 'NAME' => classLocale::$lang['pay_methods'][$payment_method_id], |
||
118 | 'IMAGE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['image']) |
||
119 | ? sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['image'] : '', |
||
120 | 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), |
||
121 | 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']), |
||
122 | ); |
||
123 | foreach($module_list as $payment_module_name => $payment_module_method_details) { |
||
124 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array( |
||
125 | 'MODULE' => $payment_module_name, |
||
126 | ); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | if(empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
||
131 | unset($template_result['.']['payment'][$payment_type_id]); |
||
132 | } |
||
133 | } |
||
134 | |||
135 | $template->assign_recursive($template_result); |
||
136 | |||
137 | $payment_type_selected = sys_get_param_int('payment_type'); |
||
138 | $payment_method_selected = sys_get_param_int('payment_method'); |
||
139 | |||
140 | $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); |
||
141 | |||
142 | // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it |
||
143 | if($payment_module_valid) { |
||
144 | // $payment_module = $payment_module; // Really - do nothing |
||
145 | } elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
||
146 | reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
||
147 | $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
||
148 | } elseif(count(sn_module::$sn_module_list['payment']) == 1) { |
||
149 | $payment_module = $module_name; |
||
150 | } else { |
||
151 | $payment_module = ''; |
||
152 | } |
||
153 | |||
154 | if($payment_type_selected && $payment_method_selected) { |
||
155 | foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
||
156 | $template->assign_block_vars('payment_module', array( |
||
157 | 'ID' => $module_name, |
||
158 | 'NAME' => classLocale::$lang["module_{$module_name}_name"], |
||
159 | 'DESCRIPTION' => classLocale::$lang["module_{$module_name}_description"], |
||
160 | )); |
||
161 | } |
||
162 | } |
||
163 | |||
164 | foreach(classLocale::$lang['pay_currency_list'] as $key => $value) { |
||
165 | $course = get_exchange_rate($key); |
||
166 | if(!$course) { |
||
167 | continue; |
||
168 | } |
||
169 | $template->assign_block_vars('exchange', array( |
||
170 | 'SYMBOL' => $key, |
||
171 | 'TEXT' => $value, |
||
172 | 'COURSE_DIRECT' => pretty_number($course, 4), |
||
0 ignored issues
–
show
|
|||
173 | 'COURSE_REVERSE' => pretty_number(1 / $course, 4), |
||
0 ignored issues
–
show
4 is of type integer , but the function expects a boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
174 | 'MM_PER_CURRENCY' => pretty_number(sn_module_payment::currency_convert(1, $key, 'MM_')), |
||
175 | 'LOT_PRICE' => sn_module_payment::currency_convert(get_mm_cost(), 'MM_', $key), |
||
176 | 'DEFAULT' => $key == classSupernova::$config->payment_currency_default, |
||
177 | // 'UNIT_PER_LOT' => sn_module_payment::currency_convert(2500, 'MM_', $key), |
||
178 | )); |
||
179 | } |
||
180 | |||
181 | if($request['metamatter'] && $payment_module) { |
||
182 | try { |
||
183 | // Any possible errors about generating paylink should be raised in module! |
||
184 | $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request); |
||
185 | |||
186 | // Поддержка дополнительной информации |
||
187 | if(is_array($pay_link['RENDER'])) { |
||
188 | foreach($pay_link['RENDER'] as $html_data) { |
||
189 | $template->assign_block_vars('render', $html_data); |
||
190 | View Code Duplication | if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
191 | foreach($html_data['VALUE'] as $value_id => $value_value) { |
||
192 | $template->assign_block_vars('render.value', array( |
||
193 | 'FIELD' => $value_id, |
||
194 | 'VALUE' => $value_value, |
||
195 | )); |
||
196 | } |
||
197 | } |
||
198 | } |
||
199 | } |
||
200 | |||
201 | // Поддержка передачи данных для многошаговых платежных систем |
||
202 | View Code Duplication | if(is_array($pay_link['DATA'])) { |
|
203 | foreach($pay_link['DATA'] as $key => $value) { |
||
204 | $template->assign_block_vars('pay_link_data', array( |
||
205 | 'FIELD' => $key, |
||
206 | 'VALUE' => $value, |
||
207 | )); |
||
208 | } |
||
209 | } |
||
210 | |||
211 | if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
||
212 | // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте |
||
213 | $template->assign_vars(array( |
||
214 | 'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'], |
||
215 | 'PAY_LINK_URL' => $pay_link['PAY_LINK_URL'], |
||
216 | )); |
||
217 | } else { |
||
218 | throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR); |
||
219 | } |
||
220 | } catch(exception $e) { |
||
221 | $template->assign_block_vars('result', $response = array( |
||
222 | 'STATUS' => $e->getCode(), |
||
223 | 'MESSAGE' => $e->getMessage(), |
||
224 | )); |
||
225 | $debug->warning('Результат операции: код ' . $e->getCode() . ' сообщение "' . $e->getMessage() . '"', 'Ошибка платежа', LOG_INFO_PAYMENT); |
||
226 | } |
||
227 | } |
||
228 | |||
229 | // Прегенерированные пакеты |
||
230 | foreach($unit_available_amount_list as $unit_amount => $discount) { |
||
231 | $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency); |
||
232 | $template->assign_block_vars('mm_amount', array( |
||
233 | 'VALUE' => $unit_amount, |
||
234 | // 'PRICE' => $temp, |
||
235 | 'PRICE_TEXT' => pretty_number($temp, 2), |
||
0 ignored issues
–
show
2 is of type integer , but the function expects a boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
236 | 'CURRENCY' => $player_currency, |
||
237 | 'DISCOUNT' => $discount, |
||
238 | 'DISCOUNT_PERCENT' => $discount * 100, |
||
239 | 'DISCOUNTED' => $unit_amount * (1 + $discount), |
||
240 | 'TEXT' => pretty_number($unit_amount), |
||
241 | 'TEXT_DISCOUNTED' => pretty_number($unit_amount * (1 + $discount)), |
||
242 | )); |
||
243 | } |
||
244 | |||
245 | $currency = $payment_module ? sn_module_payment::$payment_methods[$payment_type_selected][$payment_method_selected]['currency'] : ''; |
||
246 | $bonus_percent = round(sn_module_payment::bonus_calculate($request['metamatter'], true, true) * 100); |
||
247 | $income_metamatter_text = pretty_number(sn_module_payment::bonus_calculate($request['metamatter']), true, true); |
||
248 | |||
249 | $template->assign_vars(array( |
||
250 | 'PAGE_HEADER' => classLocale::$lang['sys_metamatter'], |
||
251 | |||
252 | 'URL_PURCHASE' => classSupernova::$config->url_purchase_metamatter, |
||
253 | |||
254 | 'PAYMENT_TYPE' => $payment_type_selected, |
||
255 | 'PAYMENT_METHOD' => $payment_method_selected, |
||
256 | 'PAYMENT_METHOD_NAME' => classLocale::$lang['pay_methods'][$payment_method_selected], |
||
257 | |||
258 | 'PAYMENT_MODULE' => $payment_module, |
||
259 | 'PAYMENT_MODULE_NAME' => classLocale::$lang["module_{$payment_module}_name"], |
||
260 | 'PAYMENT_MODULE_DESCRIPTION' => classLocale::$lang["module_{$payment_module}_description"], |
||
261 | |||
262 | 'PLAYER_CURRENCY' => $player_currency, |
||
263 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
||
264 | |||
265 | 'UNIT_AMOUNT' => (float)$request['metamatter'], |
||
266 | 'UNIT_AMOUNT_TEXT' => pretty_number($request['metamatter']), |
||
267 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
||
268 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
||
269 | 'UNIT_AMOUNT_TEXT_COST_BASE' => pretty_number(sn_module_payment::currency_convert($request['metamatter'], 'MM_', $player_currency), 2), |
||
0 ignored issues
–
show
2 is of type integer , but the function expects a boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
270 | |||
271 | 'PAYMENT_CURRENCY_EXCHANGE_DEFAULT' => pretty_number(get_mm_cost(), true, true), |
||
272 | 'PAYMENT_CURRENCY_DEFAULT_TEXT' => classLocale::$lang['pay_currency_list'][classSupernova::$config->payment_currency_default], |
||
273 | |||
274 | 'METAMATTER' => mrc_get_level($user, null, RES_METAMATTER), |
||
275 | |||
276 | 'METAMATTER_COST_TEXT' => sprintf(classLocale::$lang['pay_mm_buy_conversion_cost'], |
||
277 | pretty_number($request['metamatter'], true, true), |
||
278 | pretty_number(sn_module_payment::currency_convert($request['metamatter'], 'MM_', $currency), 2, true), |
||
0 ignored issues
–
show
2 is of type integer , but the function expects a boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
279 | $currency), |
||
280 | 'METAMATTER_COST_BONUS_TEXT' => $bonus_percent |
||
281 | ? sprintf(classLocale::$lang['pay_mm_buy_real_income'], pretty_number($bonus_percent, true, true), $income_metamatter_text) |
||
282 | : '', |
||
283 | |||
284 | 'DARK_MATTER_DESCRIPTION' => classLocale::$lang['info'][RES_DARK_MATTER]['description'], |
||
285 | |||
286 | 'PAYMENT_AVAILABLE' => sn_module_get_active_count('payment') && !defined('SN_GOOGLE'), |
||
287 | |||
288 | )); |
||
289 | |||
290 | display($template, classLocale::$lang['sys_metamatter']); |
||
291 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: