54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace sdkwarpper;
|
|
|
|
require 'BaseSdk.php';
|
|
|
|
use phpcommon;
|
|
use classes;
|
|
|
|
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']);
|
|
}
|
|
|
|
public function preOrder()
|
|
{
|
|
$params = array(
|
|
'appid' => 'wx9b006ee01033cec7',
|
|
'mch_id' => '1509252791',
|
|
'nonce_str' => uniqid('201019'),
|
|
'body' => '测试产品',
|
|
'out_trade_no' => uniqid('201019'),
|
|
'total_fee' => '101',
|
|
'spbill_create_ip' => phpcommon\getIPv4(),
|
|
'notify_url' => 'https://gamepay.kingsome.cn/webapp/paynotify/unified_weixin.php',
|
|
'trade_type' => 'MWEB',
|
|
//'scene_info' => '',
|
|
);
|
|
if (SERVER_ENV != _ONLINE) {
|
|
$params['notify_url'] = 'https://gamepay-test.kingsome.cn/webapp/paynotify/unified_weixin.php';
|
|
}
|
|
$sign = phpcommon\wxPaySign($params,
|
|
'ZTlMqTh5lRNefcH2KHroQqxdShEiedD0'
|
|
);
|
|
$params['sign'] = strtoupper($sign);
|
|
error_log(json_encode($params));
|
|
error_log(phpcommon\objectToXml($params));
|
|
$response = '';
|
|
if (phpcommon\HttpClient::postContent(
|
|
'https://api.mch.weixin.qq.com/pay/unifiedorder',
|
|
phpcommon\objectToXml($params),
|
|
$response
|
|
)) {
|
|
|
|
}
|
|
echo $response;
|
|
}
|
|
|
|
}
|