1
This commit is contained in:
parent
6cb9a7ec6d
commit
997ca9606c
@ -35,6 +35,9 @@ class PayController {
|
||||
} else {
|
||||
$channel = $_REQUEST['_channel'];
|
||||
}
|
||||
if (!empty($_REQUEST['_unified_channel'])) {
|
||||
$channel = $_REQUEST['_unified_channel'];
|
||||
}
|
||||
$sdk = sdkwarpper\createSdkByChannel($channel);
|
||||
if (!$sdk) {
|
||||
echo 'is null';
|
||||
@ -46,6 +49,14 @@ class PayController {
|
||||
|
||||
public function queryOrderInfo()
|
||||
{
|
||||
$channel = phpcommon\extractChannel($_REQUEST['account_id']);
|
||||
$sdk = sdkwarpper\createSdkByChannel($channel);
|
||||
if (!$sdk) {
|
||||
echo 'is null';
|
||||
} else {
|
||||
$sdk->setChannel($channel);
|
||||
$sdk->queryOrderInfo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ class BaseSdk
|
||||
{
|
||||
protected $real_channel = '0';
|
||||
protected $channel = '0';
|
||||
protected $unified_channel = '0';
|
||||
protected $poly_sdk_channel = '0';
|
||||
protected $gameid = 0;
|
||||
|
||||
protected $order_ctrl = null;
|
||||
|
@ -12,6 +12,7 @@ class UnifiedWeiXin extends BaseSdk {
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->unified_channel = $this->channel;
|
||||
$this->conf_appid = '';
|
||||
$this->conf_mch_id = '';
|
||||
$this->conf_pay_secret_key = '';
|
||||
@ -30,15 +31,31 @@ class UnifiedWeiXin extends BaseSdk {
|
||||
public function preOrder()
|
||||
{
|
||||
$this->gameid = phpcommon\extractGameId($_REQUEST['account_id']);
|
||||
$this->real_channel = phpcommon\extractGameId($_REQUEST['account_id']);
|
||||
$this->real_channel = phpcommon\extractChannelId($_REQUEST['account_id']);
|
||||
$this->loadConfig();
|
||||
|
||||
$cp_orderid = $this->order_ctrl->genOrderId();
|
||||
{
|
||||
$this->order_ctrl->addPreOrder(
|
||||
array(
|
||||
'orderid' => $cp_orderid,
|
||||
'account_id' => $_REQUEST['account_id'],
|
||||
'roleid' => '',
|
||||
'server_id' => 0,
|
||||
'poly_sdk_channel' => $this->poly_sdk_channel,
|
||||
'unified_channel' => $this->unified_channel,
|
||||
'itemid' => $itemid,
|
||||
'ipv4' => phpcommon\getIPv4(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'appid' => $this->conf_appid,
|
||||
'mch_id' => $this->conf_mch_id,
|
||||
'nonce_str' => uniqid('201019'),
|
||||
'nonce_str' => md5($cp_orderid . time()),
|
||||
'body' => '测试产品',
|
||||
'out_trade_no' => uniqid('201019'),
|
||||
'out_trade_no' => $cp_orderid,
|
||||
'total_fee' => '101',
|
||||
'spbill_create_ip' => phpcommon\getIPv4(),
|
||||
'notify_url' => 'https://gamepay.kingsome.cn/webapp/paynotify/unified_weixin.php',
|
||||
@ -60,9 +77,26 @@ class UnifiedWeiXin extends BaseSdk {
|
||||
phpcommon\objectToXml($params),
|
||||
$response
|
||||
)) {
|
||||
|
||||
phpcommon\sendError(1, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
echo $response;
|
||||
$xml = new \SimpleXMLElement($response);
|
||||
if ($xml->return_code != 'SUCCESS') {
|
||||
phpcommon\sendError(2, $xml->return_msg);
|
||||
return;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'cp_orderid' => $cp_orderid,
|
||||
'prepayid' => $xml->prepay_id
|
||||
));
|
||||
}
|
||||
|
||||
public function payNotify()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user