58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
const _ONLINE = 1;
|
|
const _DEBUG = 2;
|
|
const _TEST = 3;
|
|
|
|
if (getenv('SERVER_ENV') == 'DEBUG') {
|
|
define('SERVER_ENV', _DEBUG);
|
|
} else if (getenv('SERVER_ENV') == 'TEST') {
|
|
define('SERVER_ENV', _TEST);
|
|
} else {
|
|
define('SERVER_ENV', _ONLINE);
|
|
}
|
|
|
|
function postContent($url, $content, &$response, $headers = null,
|
|
$ssl_key = null, $ssl_cert = null)
|
|
{
|
|
$ch = curl_init();
|
|
if (!$headers) {
|
|
$headers = array(
|
|
);
|
|
}
|
|
try{
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
|
if (!empty($ssl_key) && !empty($ssl_cert)) {
|
|
curl_setopt($ch, CURLOPT_SSLKEY, $ssl_key);
|
|
curl_setopt($ch, CURLOPT_SSLCERT, $ssl_cert);
|
|
}
|
|
$response = curl_exec($ch);
|
|
return true;
|
|
}catch(Exception $e){
|
|
return false;
|
|
}
|
|
curl_close($ch);
|
|
}
|
|
|
|
error_log(json_encode($_REQUEST));
|
|
|
|
$url = 'https://gamepay.kingsome.cn/webapp/index.php';
|
|
if (SERVER_ENV != _ONLINE) {
|
|
$url = 'https://gamepay-test.kingsome.cn/webapp/index.php';
|
|
}
|
|
|
|
$response = '';
|
|
|
|
if (!postContent($url . '?c=Pay&a=payNotify&_unified_channel=9001',
|
|
file_get_contents('php://input'),
|
|
$response)
|
|
) {
|
|
die();
|
|
}
|
|
echo $response;
|