-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathserver1.php
53 lines (47 loc) · 1.81 KB
/
server1.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
<?php
/*$file = fopen("./server.log", "a");
fwrite($file , "\nAccessed " . date("Y-m-d H:i:s") . "\n");
fwrite($file , "\n_POST " . print_r($_POST, true) . "\n");
fclose($file );*/
if($_POST['action'] == "approve")
{
$url = 'https://api.minepi.com/v2/payments/'.$_POST['paymentId'].'/approve';
$data = array();
}else if($_POST['action'] == "complete")
{
$url = 'https://api.minepi.com/v2/payments/'.$_POST['paymentId'].'/complete';
$data = array('txid' => $_POST['txid']);
}
$apps = array();
$apps['auth_app1'] = 'Key onycnt6xapyy2rrzucnkfsf0jnrrrgcdc21xugk2gum1nzsolvjaidt1kfgedkyu';
$apps['LazadaDemoTest'] = 'Key onycnt6xapyy2rrzucnkfsf0jnrrrgcdc21xugk2gum1nzsolvjaidt1kfgedkyu';
//$apps['LazadaDemoTest'] = 'Key <your Server API Key>';
//$apps['auth_app4'] = 'Key <your Server API Key>';
$ch = curl_init($url);
# Form data string
$postString = http_build_query($data, '', '&');
# Setting our options
$headers = array(
"Authorization: " . $apps[$_POST['app_client']],
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
# Get the response
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
/*$file = fopen("./server.log", "a");
fwrite($file , "\nResponse " . date("Y-m-d H:i:s") . "\n");
fwrite($file , $response);
fwrite($file , "\nError\n");
fwrite($file , $error);
fwrite($file , "\n");
fclose($file );*/
//var_dump($response);
header("HTTP/1.1 200 OK");
header('Content-Type: application/json');
echo json_encode($response);
?>