-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.php
47 lines (39 loc) · 1.34 KB
/
webhook.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
<?php
$data = $_POST;
$mac_provided = $data['mac'];
unset($data['mac']);
$ver = explode('.', phpversion());
$major = (int) $ver[0];
$minor = (int) $ver[1];
if($major >= 5 and $minor >= 4){
ksort($data, SORT_STRING | SORT_FLAG_CASE);
}
else{
uksort($data, 'strcasecmp');
}
$mac_calculated = hash_hmac("sha1", implode("|", $data), "8c1a801326054b9a96d70bbe48ebd7cb");
if($mac_provided == $mac_calculated){
echo "MAC OK";
if($data['status'] == "Credit"){
$to = 'mail@domain.com';
$subject = 'Website Payment Request ' .$data['buyer_name'].'';
$message = "<h1>Payment Details</h1>";
$message .= "<hr>";
$message .= '<p><b>ID:</b> '.$data['payment_id'].'</p>';
$message .= '<p><b>Amount:</b> '.$data['amount'].'</p>';
$message .= "<hr>";
$message .= '<p><b>Name:</b> '.$data['buyer_name'].'</p>';
$message .= '<p><b>Email:</b> '.$data['buyer'].'</p>';
$message .= '<p><b>Phone:</b> '.$data['buyer_phone'].'</p>';
$message .= "<hr>";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
}
else{
}
}
else{
echo "MAC Fail";
}
?>