-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreceiveRefundResponse.php
67 lines (60 loc) · 1.85 KB
/
receiveRefundResponse.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
61
62
63
64
65
66
67
<?php
/**
* Created by PhpStorm.
* User: unevmerzhuzkiy
* Date: 6/24/15
* Time: 6:49 PM
*/
include_once 'library/changeRefundStatus.php';
include_once 'library/db.php';
include_once 'library/changeKeyStatus.php';
include_once 'library/getPercent.php';
if(isset($_POST['refunds']))
{
$jsonResponse = $_POST['refunds'];
$response = json_decode($jsonResponse,true);
if(isset($response['id_refund'])){
$id_refund = $response['id_refund'];
if(isset($response['success']))
{
if($response['success']===true)
{
changeRefundStatus(getConnect(),$id_refund,2);
if(isset($response['id_keys']))
{
$keys = $response['id_keys'];
decrementKeysPercent($id_refund,$keys);
}
}
else
{
changeRefundStatus(getConnect(),$id_refund,3);
$keys = getKeyList(getConnect(),$id_refund);
decrementKeysPercent($id_refund,$keys);
/*if(isset($response['id_keys']))
{
foreach($response['id_keys'] as $key=>$value)
{
switch($value)
{
case 'notexists':
changeKeyStatus(getConnect(),$id_key,2);
break;
case 'canceled':
changeKeyStatus(getConnect(),$id_key,1);
break;
}
}
}*/
}
}
}
}
function decrementKeysPercent($refund_id, $keys)
{
$percent = getPercent(getConnect(),$refund_id);
foreach($keys as $key)
{
decrementKeyPercent(getConnect(),$key,$percent);
}
}