pay/webapp/sdkwarpper/GoogleAndroid.php
aozhiwei a0dbdeb259 1
2020-11-04 12:02:11 +08:00

65 lines
1.7 KiB
PHP

<?php
namespace sdkwarpper;
require 'BaseSdk.php';
use phpcommon;
use classes;
class GoogleAndroid extends BaseSdk {
function __construct()
{
parent::__construct();
$this->conf_appid = '';
}
private function loadConfig()
{
$config_name = "../config/game{$this->gameid}/{$this->channel}/config.php";
$this->config = require($config_name);
$this->conf_appid = $this->config['appid'];
$this->conf_package_name = $this->config['package_name'];
}
public function payNotify()
{
if (!phpcommon\isValidSessionId($_REQUEST['_account_id'], $_REQUEST['_session_id'])) {
phpcommon\sendError(1, 'session无效');
return;
}
$this->gameid = phpcommon\extractGameId($_REQUEST['_account_id']);
$this->real_channel = phpcommon\extractChannel($_REQUEST['_account_id']);
$this->loadConfig();
$packageName = $this->conf_package_name;
$productId = $_REQUEST['_itemid'];
$token = $_REQUEST['_purchase_token'];
$response = '';
$proxy = null;
if (SERVER_ENV != _ONLINE) {
$proxy = array(
"host" => "127.0.0.1",
"port" => 8118,
"user_pwd" => ""
);
}
if (phpcommon\HttpClient::get(
"https://androidpublisher.googleapis.com/androidpublisher/v3/applications/" .
"{$packageName}/purchases/products/{$productId}/tokens/{$token}",
array(
'access_token' => '2134234'
),
$response,
$proxy)) {
phpcommon\sendError(2, '服务器内部错误');
}
error_log($response);
echo $response;
}
}