-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcallback.php
More file actions
71 lines (53 loc) · 1.28 KB
/
Copy pathcallback.php
File metadata and controls
71 lines (53 loc) · 1.28 KB
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
68
69
70
71
<?php
require_once('variables.php');
if (empty($_POST['status']) ||
empty($_POST['id']) ||
empty($_POST['track_id']) ||
empty($_POST['order_id']) ||
empty($_POST['amount']) ||
empty($_POST['amount'])) {
return FALSE;
}
if ($_POST['status'] != 100) {
return FALSE;
}
// if $_POST['id'] was not in the database return FALSE
$header = array(
'Content-Type: application/json',
'X-API-KEY:' . APIKEY,
'X-SANDBOX:' . SANDBOX,
);
$params = array(
'id' => $_POST['id'],
'order_id' => $_POST['order_id'],
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, URL_INQUIRY);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
if (empty($result) ||
empty($result->status)) {
print 'Error handeling';
return FALSE;
}
switch ($result->status) {
case 1:
print 'پرداخت انجام نشده است';
return;
case 2:
print 'پرداخت ناموفق بوده است';
return;
case 3:
print 'خطا رخ داده است';
return;
case 100:
print 'پرداخت تایید شده است';
return;
default:
print 'Error handeling';
return;
}