87 lines
2.2 KiB
PHP
87 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace sdkwarpper;
|
|
|
|
use phpcommon;
|
|
|
|
class SelfSdk extends BaseSdk {
|
|
|
|
public function getOrderId()
|
|
{
|
|
|
|
if (SERVER_ENV != _ONLINE) {
|
|
$url = "http://127.0.0.1:7051/webapp/index.php?c=Pay&a=getOrderId";
|
|
} else {
|
|
$url = "https://center.kingsome.cn/api/games/click/$game_id";
|
|
}
|
|
|
|
$response = '';
|
|
$params = array(
|
|
'accountid' => $_REQUEST['accountid'],
|
|
'roleid' => $_REQUEST['roleid'],
|
|
'rolename' => $_REQUEST['rolename'],
|
|
'serverid' => $_REQUEST['serverid'],
|
|
'itemid' => $_REQUEST['itemid'],
|
|
'price' => $_REQUEST['price'],
|
|
'sp_orderid' => 'testtttttt'
|
|
);
|
|
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
|
phpcommon\sendError(100,'获取失败');
|
|
return;
|
|
}
|
|
|
|
error_log($response);
|
|
$ret_info = json_decode($response, true);
|
|
if ($ret_info['errcode'] == 0) {
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => ''
|
|
));
|
|
$data = array(
|
|
'pay_type' => 1,
|
|
'orderid' => $ret_info['orderid'],
|
|
'payresult' => 1
|
|
);
|
|
$this->payNotify($data);
|
|
} else {
|
|
echo json_encode(array(
|
|
'errcode' => $ret_info['errcode'],
|
|
'errmsg' => $ret_info['errmsg'],
|
|
));
|
|
}
|
|
}
|
|
|
|
private function payNotify($data)
|
|
{
|
|
|
|
if (SERVER_ENV != _ONLINE) {
|
|
$url = "http://127.0.0.1:7051/webapp/index.php?c=Pay&a=payNotify";
|
|
} else {
|
|
$url = "https://center.kingsome.cn/api/games/click/$game_id";
|
|
}
|
|
|
|
$response = '';
|
|
$params = array(
|
|
'pay_type' => $data['pay_type'],
|
|
'orderid' => $data['orderid'],
|
|
'payresult' => $data['payresult']
|
|
);
|
|
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
|
phpcommon\sendError(100,'获取失败');
|
|
return;
|
|
}
|
|
|
|
error_log($response);
|
|
|
|
$ret_info = json_decode($response, true);
|
|
|
|
if ($ret_info['errcode'] == 0) {
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|