-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheckorder.php
More file actions
62 lines (51 loc) · 1.11 KB
/
checkorder.php
File metadata and controls
62 lines (51 loc) · 1.11 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
<?php
require_once('alif.php');
$a = new Alif('keycode','passcode');
$a->orderId = '321123'; //orderid
$token = $a->checkOrderToken();
// The data to send to the API
$postData = array(
'orderId' => $a->orderId,
'key' => $a->key,
'token' => $token
);
// Setup cURL
$ch = curl_init('https://alifpay.tj/web/checktxn');
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
// Check for errors
if($response === FALSE){
die(curl_error($ch));
}
/**
*
success response
{
"orderId": "12345678",
"transactionId": "92938922",
"status": "ok",
"token": "3792cujidwjkdj981uj918dj19djdad32d23f2f",
"amount": 10,
"phone": "+992931234455"
}
error response
{
"orderId": "12345678",
"status": "not found",
}
or
{
"orderId": "12345678",
"status": "failed",
}
*/
// Decode the response
$responseData = json_decode($response);
// Print the date from the response
echo $responseData['status'];
?>