-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification.php
85 lines (39 loc) · 1.37 KB
/
notification.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
// Check if the request method is POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Get the payload from the request body
$payload = file_get_contents('php://input');
// Decode the payload as JSON
$payloadData = json_decode($payload, true);
// Check if the status field exists in the payload
if (isset($payloadData['status'])) {
$status = $payloadData['status'];
// Prepare the response based on the status
if ($status === "0") {
$response = array(
'responseCode' => '0',
'responseMessage' => 'Transaction Updated Successfully'
);
$statusCode = 200;
} else{
$response = array(
'responseCode' => '1',
'responseMessage' => 'Transaction could not be Updated'
);
$statusCode = 403;
}
// Set the response headers
header('Content-Type: application/json');
http_response_code($statusCode);
// Send the response
echo json_encode($response);
} else {
// Handle missing status field
http_response_code(400);
echo 'Invalid payload: status field is missing';
}
} else {
// Handle invalid request method
http_response_code(405);
echo 'Method Not Allowed';
}