-
Notifications
You must be signed in to change notification settings - Fork 0
/
callback.php
57 lines (43 loc) · 1.53 KB
/
callback.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
<?php
$reference = $_REQUEST["reference"];
$url = "https://sandbox.api.pay.yigim.az/payment/status?reference=".$reference;
$secretkey = "0000000"; // replace
$signature = base64_encode(md5($reference.$secretkey, true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Merchant: 0000000', // replace
'X-Signature:'.$signature,
'X-Type: json'
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
echo $response = curl_exec($ch);
curl_close($ch);
file_put_contents($_SERVER["DOCUMENT_ROOT"].'/path/to/log.txt', $response."\n", FILE_APPEND);
if($_REQUEST["reference"]!="") {
$order_id = explode("_",$_REQUEST["reference"]);
$order_id = intval($order_id[0]);
if($order_id > 0) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Merchant: 0000000', // replace
'X-Signature:'.$signature,
'X-Type: json'
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
echo $response = curl_exec($ch);
curl_close($ch);
preg_match("/<code>(.+)<\/code>/is", $response, $respCode);
preg_match("/<status>(.+)<\/status>/is", $response, $respStatus);
preg_match("/<message>(.+)<\/message>/is", $response, $respMessage);
if($respStatus[1]=="00"&&$respCode[1]=="0") {
// change order status
}
}
}
?>