-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.php
More file actions
34 lines (27 loc) · 746 Bytes
/
Copy pathverify.php
File metadata and controls
34 lines (27 loc) · 746 Bytes
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
<?
if(isset($_POST['token'], $_POST['amount'])) {
$args = http_build_query(array(
'token' => $_POST['token'],
'amount' => $_POST['amount']
));
$url = "https://khalti.com/api/v2/payment/verify/";
# Make the call using API.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = ['Authorization: Key test_secret_key_'];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Response
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$obj = json_decode($response);
if ($status_code == 200) {
echo $status_code;
}else{
echo $obj->error_key;
}
curl_close($ch);
}
?>