1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Merchant helper Paykeeper |
5
|
|
|
* |
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
7
|
|
|
* @link http://inji.ru/ |
8
|
|
|
* @copyright 2015 Alexey Krupskiy |
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Money\MerchantHelper; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class Paykeeper extends \Money\MerchantHelper { |
16
|
|
|
|
17
|
|
|
public static function goToMerchant($payId, $amount, $currency, $description = '', $success = '/', $false = '/') { |
18
|
|
|
$config = static::getConfig(); |
19
|
|
|
# предполагаются заранее известными значения переменных |
20
|
|
|
# $client_login, $order_id, $order_sum и $optional_phone |
|
|
|
|
21
|
|
|
|
22
|
|
|
$payment_parameters = http_build_query(array( |
23
|
|
|
"clientid" => \Users\User::$cur->id, |
24
|
|
|
"orderid" => $payId, |
25
|
|
|
"sum" => $amount, |
26
|
|
|
//"phone" => $optional_phone |
27
|
|
|
)); |
28
|
|
|
$options = array("http" => array( |
29
|
|
|
"method" => "POST", |
30
|
|
|
"header" => |
31
|
|
|
"Content-type: application/x-www-form-urlencoded", |
32
|
|
|
"content" => $payment_parameters |
33
|
|
|
)); |
34
|
|
|
$context = stream_context_create($options); |
35
|
|
|
echo "<style>.tmg {margin:0 auto}</style>"; |
36
|
|
|
echo file_get_contents("http://{$config['domain']}.paykeeper.ru/order/inline/", FALSE, $context); |
37
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public static function reciver($data, $status) { |
41
|
|
|
$config = static::getConfig(); |
42
|
|
|
$result = []; |
43
|
|
|
$result['status'] = 'error'; |
44
|
|
|
|
45
|
|
|
$secret_seed = $config['secret']; |
46
|
|
|
$id = $_POST['id']; |
47
|
|
|
$sum = $_POST['sum']; |
48
|
|
|
$clientid = $_POST['clientid']; |
49
|
|
|
$orderid = $_POST['orderid']; |
50
|
|
|
$key = $_POST['key']; |
51
|
|
|
|
52
|
|
|
if ($key != md5($id . sprintf("%.2lf", $sum) . |
53
|
|
|
$clientid . $orderid . $secret_seed) |
54
|
|
|
) { |
55
|
|
|
$result['callback'] = 'Error! Hash mismatch'; |
56
|
|
|
return $result; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if ($orderid == "") { |
|
|
|
|
60
|
|
|
# Платёж – пополнение счёта, нужно зачислить деньги на баланс $clientid |
61
|
|
|
# ... |
62
|
|
|
} else { |
63
|
|
|
$result['payId'] = $data["orderid"]; |
64
|
|
|
$result['status'] = 'success'; |
65
|
|
|
} |
66
|
|
|
$result['callback'] = "OK " . md5($id . $secret_seed); |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
return $result; |
70
|
|
|
} |
71
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.