forked from H3Gi/tatar-wars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaymentservice1.php
60 lines (42 loc) · 1.42 KB
/
paymentservice1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require( '.' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'boot.php' );
require_once( MODEL_PATH . 'payment.php' );
class GPage extends WebService {
function load() {
$AppConfig = $GLOBALS['AppConfig'];
if ($this->isPost()) {
$usedPackage = NULL;
foreach ($AppConfig['plus']['packages'] as $package) {
if ($package['cost'] == $_POST['amount']) {
$usedPackage = $package;
continue;
}
}
$merchant_id = $AppConfig['plus']['payments']['cashu']['merchant_id'];
$usedPayment = NULL;
foreach ($AppConfig['plus']['payments'] as $payment) {
if ($payment['merchant_id'] == $merchant_id) {
$usedPayment = $payment;
continue;
}
}
if (!isset( $_GET[$usedPayment['returnKey']] )) {
return null;
}
if (( ( $usedPackage != NULL && $usedPayment != NULL ) && $_POST['token'] == md5( sprintf( '%s:%s:%s:%s', $merchant_id, $_POST['amount'], strtolower( $_POST['currency'] ), ($_POST['test_mode'] ? $usedPayment['testKey'] : $usedPayment['key']) ) ) )) {
$playerId = base64_decode( $_POST['session_id'] );
$goldNumber = $usedPackage['gold'];
PaymentModel;
$m = new ();
$m->incrementPlayerGold( $playerId, $goldNumber );
$m->dispose();
echo '<h2 style="color:#00ff00;">success</h2>';
return null;
}
echo '<h2 style="color:#ff0000;">failed</h2>';
}
}
}
$p = new GPage();
$p->run();
?>