This commit is contained in:
aozhiwei 2020-10-19 16:48:19 +08:00
parent bf49f87329
commit 6cb9a7ec6d
3 changed files with 30 additions and 6 deletions

View File

@ -21,6 +21,7 @@ class PayController {
if (!$sdk) {
echo 'is null';
} else {
$sdk->setChannel($channel);
$sdk->preOrder();
}
}
@ -38,6 +39,7 @@ class PayController {
if (!$sdk) {
echo 'is null';
} else {
$sdk->setChannel($channel);
$sdk->payNotify();
}
}

View File

@ -14,10 +14,17 @@ class BaseSdk
protected $gameid = 0;
protected $order_ctrl = null;
protected $config = null;
function __construct()
{
$this->order_ctrl = new classes\OrderCtrl();
error_log('basesdk new');
}
protected function setChannel($channel)
{
$this->channel = $channel;
}
public function preOrder()

View File

@ -11,16 +11,31 @@ class UnifiedWeiXin extends BaseSdk {
function __construct()
{
$this->channel = UNIFIED_WEIXIN_CHANNEL;
$this->gameid = phpcommon\extractGameId($_REQUEST['account_id']);
$this->real_channel = phpcommon\extractGameId($_REQUEST['account_id']);
parent::__construct();
$this->conf_appid = '';
$this->conf_mch_id = '';
$this->conf_pay_secret_key = '';
}
private function loadConfig()
{
$config_name = "../config/game{$this->gameid}/{$this->channel}/config.php";
$this->config = require($config_name);
$this->conf_appid = $this->config['appid'];
$tmp_str = explode('|', $this->config['pay_secret_key']);
$this->conf_mch_id = $tmp_str[0];
$this->conf_pay_secret_key = $tmp_str[1];
}
public function preOrder()
{
$this->gameid = phpcommon\extractGameId($_REQUEST['account_id']);
$this->real_channel = phpcommon\extractGameId($_REQUEST['account_id']);
$this->loadConfig();
$params = array(
'appid' => 'wx9b006ee01033cec7',
'mch_id' => '1509252791',
'appid' => $this->conf_appid,
'mch_id' => $this->conf_mch_id,
'nonce_str' => uniqid('201019'),
'body' => '测试产品',
'out_trade_no' => uniqid('201019'),
@ -34,7 +49,7 @@ class UnifiedWeiXin extends BaseSdk {
$params['notify_url'] = 'https://gamepay-test.kingsome.cn/webapp/paynotify/unified_weixin.php';
}
$sign = phpcommon\wxPaySign($params,
'ZTlMqTh5lRNefcH2KHroQqxdShEiedD0'
$this->conf_pay_secret_key
);
$params['sign'] = strtoupper($sign);
error_log(json_encode($params));