eee
This commit is contained in:
+154
-154
@@ -16,185 +16,185 @@ abstract class Subject extends Multiprogramming
|
||||
{
|
||||
|
||||
|
||||
private array $keywords = [];
|
||||
private string $templateId = '';
|
||||
private string $openId = '';
|
||||
private string $page = 'pages/index/index';
|
||||
private string $emphasis_keyword = '';
|
||||
private string $oac_appid = '';
|
||||
private string $use_robot = '';
|
||||
private array $keywords = [];
|
||||
private string $templateId = '';
|
||||
private string $openId = '';
|
||||
private string $page = 'pages/index/index';
|
||||
private string $emphasis_keyword = '';
|
||||
private string $oac_appid = '';
|
||||
private string $use_robot = '';
|
||||
|
||||
/**
|
||||
* @param array $keywords
|
||||
*/
|
||||
public function setKeywords(array $keywords)
|
||||
{
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
/**
|
||||
* @param array $keywords
|
||||
*/
|
||||
public function setKeywords(array $keywords)
|
||||
{
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $templateId
|
||||
*/
|
||||
public function setTemplateId($templateId)
|
||||
{
|
||||
$this->templateId = $templateId;
|
||||
}
|
||||
/**
|
||||
* @param $templateId
|
||||
*/
|
||||
public function setTemplateId($templateId)
|
||||
{
|
||||
$this->templateId = $templateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $openId
|
||||
*/
|
||||
public function setOpenId($openId)
|
||||
{
|
||||
$this->openId = $openId;
|
||||
}
|
||||
/**
|
||||
* @param $openId
|
||||
*/
|
||||
public function setOpenId($openId)
|
||||
{
|
||||
$this->openId = $openId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $page
|
||||
*/
|
||||
public function setPage($page)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
/**
|
||||
* @param $page
|
||||
*/
|
||||
public function setPage($page)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $emphasis_keyword
|
||||
*/
|
||||
public function setEmphasisKeyword($emphasis_keyword)
|
||||
{
|
||||
$this->emphasis_keyword = $emphasis_keyword;
|
||||
}
|
||||
/**
|
||||
* @param $emphasis_keyword
|
||||
*/
|
||||
public function setEmphasisKeyword($emphasis_keyword)
|
||||
{
|
||||
$this->emphasis_keyword = $emphasis_keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $index
|
||||
* @param $context
|
||||
* @param string $color
|
||||
*/
|
||||
public function replaceKeyword($index, $context, string $color = '')
|
||||
{
|
||||
if (empty($color)) {
|
||||
$color = '#000';
|
||||
}
|
||||
$this->keywords['keyword' . $index] = [
|
||||
'value' => $context,
|
||||
'color' => $color
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @param $index
|
||||
* @param $context
|
||||
* @param string $color
|
||||
*/
|
||||
public function replaceKeyword($index, $context, string $color = '')
|
||||
{
|
||||
if (empty($color)) {
|
||||
$color = '#000';
|
||||
}
|
||||
$this->keywords['keyword' . $index] = [
|
||||
'value' => $context,
|
||||
'color' => $color
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $color
|
||||
* @param $context
|
||||
*/
|
||||
public function addKeyword($context, $color = null)
|
||||
{
|
||||
if (empty($color)) {
|
||||
$color = '#000';
|
||||
}
|
||||
$this->keywords['keyword' . (count($this->keywords) + 1)] = [
|
||||
'value' => $context,
|
||||
'color' => $color
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @param $color
|
||||
* @param $context
|
||||
*/
|
||||
public function addKeyword($context, $color = null)
|
||||
{
|
||||
if (empty($color)) {
|
||||
$color = '#000';
|
||||
}
|
||||
$this->keywords['keyword' . (count($this->keywords) + 1)] = [
|
||||
'value' => $context,
|
||||
'color' => $color
|
||||
];
|
||||
}
|
||||
|
||||
abstract public function getUrl();
|
||||
abstract public function getUrl();
|
||||
|
||||
abstract public function getHost();
|
||||
abstract public function getHost();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOacAppid(): string
|
||||
{
|
||||
return $this->oac_appid;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOacAppid(): string
|
||||
{
|
||||
return $this->oac_appid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oac_appid
|
||||
*/
|
||||
public function setOacAppid(string $oac_appid): void
|
||||
{
|
||||
$this->oac_appid = $oac_appid;
|
||||
}
|
||||
/**
|
||||
* @param string $oac_appid
|
||||
*/
|
||||
public function setOacAppid(string $oac_appid): void
|
||||
{
|
||||
$this->oac_appid = $oac_appid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUseRobot(): string
|
||||
{
|
||||
return $this->use_robot;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUseRobot(): string
|
||||
{
|
||||
return $this->use_robot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $use_robot
|
||||
*/
|
||||
public function setUseRobot(string $use_robot): void
|
||||
{
|
||||
$this->use_robot = $use_robot;
|
||||
}
|
||||
/**
|
||||
* @param string $use_robot
|
||||
*/
|
||||
public function setUseRobot(string $use_robot): void
|
||||
{
|
||||
$this->use_robot = $use_robot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Result
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sendTemplate(): Result
|
||||
{
|
||||
$access_token = $this->config->getAccessToken();
|
||||
if (empty($access_token)) {
|
||||
throw new \Exception('request access_token con\'t null.');
|
||||
}
|
||||
$params = [
|
||||
"touser" => $this->openId,
|
||||
"template_id" => $this->templateId,
|
||||
"page" => $this->page,
|
||||
"data" => $this->keywords,
|
||||
];
|
||||
if (!empty($this->emphasis_keyword)) {
|
||||
$params['emphasis_keyword'] = $this->emphasis_keyword;
|
||||
}
|
||||
if (!empty($this->oac_appid)) {
|
||||
$params['oac_appid'] = $this->oac_appid;
|
||||
}
|
||||
if (!empty($this->use_robot)) {
|
||||
$params['use_robot'] = $this->use_robot;
|
||||
}
|
||||
$this->reset($result);
|
||||
/**
|
||||
* @return Result
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sendTemplate(): Result
|
||||
{
|
||||
$access_token = $this->payConfig->getAccessToken();
|
||||
if (empty($access_token)) {
|
||||
throw new \Exception('request access_token con\'t null.');
|
||||
}
|
||||
$params = [
|
||||
"touser" => $this->openId,
|
||||
"template_id" => $this->templateId,
|
||||
"page" => $this->page,
|
||||
"data" => $this->keywords,
|
||||
];
|
||||
if (!empty($this->emphasis_keyword)) {
|
||||
$params['emphasis_keyword'] = $this->emphasis_keyword;
|
||||
}
|
||||
if (!empty($this->oac_appid)) {
|
||||
$params['oac_appid'] = $this->oac_appid;
|
||||
}
|
||||
if (!empty($this->use_robot)) {
|
||||
$params['use_robot'] = $this->use_robot;
|
||||
}
|
||||
$this->reset($result);
|
||||
|
||||
$client = new Client($this->getHost(), 443, true);
|
||||
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
|
||||
$client = new Client($this->getHost(), 443, true);
|
||||
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
|
||||
|
||||
$proxyHost = $this->getConfig()->getProxyHost();
|
||||
$proxyPort = $this->getConfig()->getProxyPort();
|
||||
$proxyHost = $this->payConfig->getProxyHost();
|
||||
$proxyPort = $this->payConfig->getProxyPort();
|
||||
if (!empty($proxyHost) && $proxyPort > 0) {
|
||||
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
|
||||
}
|
||||
|
||||
$client->post($this->getUrl() . '?access_token=' . $access_token, $params);
|
||||
$client->close();
|
||||
$client->close();
|
||||
|
||||
if (!in_array($client->getStatusCode(), [101, 200, 201])) {
|
||||
return new Result(code: 505, message: $client->getBody());
|
||||
}
|
||||
$body = json_decode($client->getBody(), true);
|
||||
if (isset($body['errcode']) && $body['errcode'] != 0) {
|
||||
return new Result(code: $body['errcode'], message: $body['errmsg']);
|
||||
} else {
|
||||
return new Result(code: 0, data: $body);
|
||||
}
|
||||
}
|
||||
if (!in_array($client->getStatusCode(), [101, 200, 201])) {
|
||||
return new Result(code: 505, message: $client->getBody());
|
||||
}
|
||||
$body = json_decode($client->getBody(), true);
|
||||
if (isset($body['errcode']) && $body['errcode'] != 0) {
|
||||
return new Result(code: $body['errcode'], message: $body['errmsg']);
|
||||
} else {
|
||||
return new Result(code: 0, data: $body);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset($result)
|
||||
{
|
||||
$this->openId = '';
|
||||
$this->keywords = [];
|
||||
$this->templateId = '';
|
||||
$this->page = '';
|
||||
/**
|
||||
* @param $result
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset($result)
|
||||
{
|
||||
$this->openId = '';
|
||||
$this->keywords = [];
|
||||
$this->templateId = '';
|
||||
$this->page = '';
|
||||
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -68,11 +68,11 @@ abstract class Template extends Multiprogramming
|
||||
$this->emphasis_keyword = $emphasis_keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $index
|
||||
* @param $context
|
||||
* @param $color
|
||||
*/
|
||||
/**
|
||||
* @param $index
|
||||
* @param $context
|
||||
* @param string $color
|
||||
*/
|
||||
public function replaceKeyword($index, $context, string $color = '')
|
||||
{
|
||||
if (empty($color)) {
|
||||
@@ -112,7 +112,7 @@ abstract class Template extends Multiprogramming
|
||||
*/
|
||||
public function sendTemplate(): Result
|
||||
{
|
||||
$access_token = $this->config->getAccessToken();
|
||||
$access_token = $this->payConfig->getAccessToken();
|
||||
if (empty($access_token)) {
|
||||
throw new \Exception('request access_token con\'t null.');
|
||||
}
|
||||
@@ -134,8 +134,8 @@ abstract class Template extends Multiprogramming
|
||||
$client = new Client($this->getHost(), 443, true);
|
||||
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
|
||||
|
||||
$proxyHost = $this->getConfig()->getProxyHost();
|
||||
$proxyPort = $this->getConfig()->getProxyPort();
|
||||
$proxyHost = $this->payConfig->getProxyHost();
|
||||
$proxyPort = $this->payConfig->getProxyPort();
|
||||
if (!empty($proxyHost) && $proxyPort > 0) {
|
||||
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
|
||||
}
|
||||
|
||||
+22
-20
@@ -18,9 +18,6 @@ abstract class Multiprogramming implements Progaram
|
||||
protected string $errorMsg = '';
|
||||
|
||||
|
||||
protected string $host = 'api.weixin.qq.com';
|
||||
|
||||
|
||||
/**
|
||||
* @var AppConfig
|
||||
*/
|
||||
@@ -87,49 +84,54 @@ abstract class Multiprogramming implements Progaram
|
||||
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param string $requestUrl
|
||||
* @param mixed $body
|
||||
* @param string $contentType
|
||||
* @return Result
|
||||
*/
|
||||
protected function post(string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
|
||||
protected function post(string $host, string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
|
||||
{
|
||||
return $this->request('post', $requestUrl, $body, $contentType);
|
||||
return $this->request($host, 'post', $requestUrl, $body, $contentType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param string $requestUrl
|
||||
* @param mixed $body
|
||||
* @param string $contentType
|
||||
* @return Result
|
||||
*/
|
||||
protected function get(string $host, string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
|
||||
{
|
||||
return $this->request($host, 'get', $requestUrl, $body, $contentType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param string $requestUrl
|
||||
* @param mixed $body
|
||||
* @return Result
|
||||
*/
|
||||
protected function get(string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
|
||||
protected function upload(string $host, string $requestUrl, mixed $body): Result
|
||||
{
|
||||
return $this->request('get', $requestUrl, $body, $contentType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $requestUrl
|
||||
* @param mixed $body
|
||||
* @return Result
|
||||
*/
|
||||
protected function upload(string $requestUrl, mixed $body): Result
|
||||
{
|
||||
return $this->request('upload', $requestUrl, $body);
|
||||
return $this->request($host, 'upload', $requestUrl, $body);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param string $method
|
||||
* @param string $requestUrl
|
||||
* @param $body
|
||||
* @param string $contentType
|
||||
* @return Result
|
||||
*/
|
||||
private function request(string $method, string $requestUrl, $body, string $contentType = 'application/application'): Result
|
||||
private function request(string $host, string $method, string $requestUrl, $body, string $contentType = 'application/application'): Result
|
||||
{
|
||||
$client = new Client($this->host, 443, true);
|
||||
$client = new Client($host, 80, true);
|
||||
$proxyHost = $this->payConfig->getProxyHost();
|
||||
$proxyPort = $this->payConfig->getProxyPort();
|
||||
if (!empty($proxyHost) && $proxyPort > 0) {
|
||||
|
||||
+18
-1
@@ -25,7 +25,24 @@ class Account extends SmallProgram
|
||||
$param['js_code'] = $code;
|
||||
$param['grant_type'] = 'authorization_code';
|
||||
|
||||
return $this->get('/sns/jscode2session', $param);
|
||||
return $this->get('api.q.qq.com', '/sns/jscode2session', $param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return Result
|
||||
*/
|
||||
public function appLogin(string $code): Result
|
||||
{
|
||||
$param['appid'] = $this->payConfig->appId;
|
||||
$param['secret'] = $this->payConfig->appSecret;
|
||||
$param['js_code'] = $code;
|
||||
$param['grant_type'] = 'authorization_code';
|
||||
|
||||
$this->host = 'graph.qq.com';
|
||||
|
||||
return $this->get('api.q.qq.com', '/user/get_user_info', $param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ class Recharge extends SmallProgram
|
||||
$this->orderNo = $orderNo;
|
||||
$this->data['openid'] = $openId;
|
||||
|
||||
return $this->post($this->uniformer, $this->builder(), 'application/xml');
|
||||
return $this->post('api.q.qq.com', $this->uniformer, $this->builder(), 'application/xml');
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-8
@@ -299,11 +299,10 @@ class Redhat extends SmallProgram
|
||||
{
|
||||
$client = new Client('api.qpay.qq.com', 443, true);
|
||||
$client->withHeader(['Content-Type' => 'application/x-www-form-urlencoded']);
|
||||
$client->withSslKeyFile($this->payConfig->getSslKey());
|
||||
$client->withSslCertFile($this->payConfig->getSslCert());
|
||||
$client->withCa($this->payConfig->getSslCa());
|
||||
$proxyHost = $this->getConfig()->getProxyHost();
|
||||
$proxyPort = $this->getConfig()->getProxyPort();
|
||||
$client->withSslKeyFile($this->payConfig->pay->wx->mchKey);
|
||||
$client->withSslCertFile($this->payConfig->pay->wx->mchCert);
|
||||
$proxyHost = $this->payConfig->getProxyHost();
|
||||
$proxyPort = $this->payConfig->getProxyPort();
|
||||
if (!empty($proxyHost) && $proxyPort > 0) {
|
||||
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
|
||||
}
|
||||
@@ -332,15 +331,15 @@ class Redhat extends SmallProgram
|
||||
public function searchByOrderNo($listid, $orderNo = null): Result
|
||||
{
|
||||
$requestParam['nonce_str'] = Help::random(31);
|
||||
$requestParam['mch_id'] = $this->payConfig->getMchId();
|
||||
$requestParam['mch_id'] = $this->payConfig->pay->wx->mchId;
|
||||
$requestParam['listid'] = $listid;
|
||||
if (!empty($orderNo)) {
|
||||
$requestParam['mch_billno'] = $orderNo;
|
||||
}
|
||||
$requestParam['sign'] = $this->builderSign($requestParam);
|
||||
$client = new Client('qpay.qq.com', 443, true);
|
||||
$proxyHost = $this->getConfig()->getProxyHost();
|
||||
$proxyPort = $this->getConfig()->getProxyPort();
|
||||
$proxyHost = $this->payConfig->getProxyHost();
|
||||
$proxyPort = $this->payConfig->getProxyPort();
|
||||
if (!empty($proxyHost) && $proxyPort > 0) {
|
||||
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
|
||||
}
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ class SecCheck extends SmallProgram
|
||||
'form-data[filename]' => $path,
|
||||
'form-data[content-type]' => $real_path->getMimeType()
|
||||
];
|
||||
return $this->upload($path, $data);
|
||||
return $this->upload('api.q.qq.com', $this->_url, $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ class SecCheck extends SmallProgram
|
||||
if (empty($content)) {
|
||||
return $this->sendError('文件不存在', 404);
|
||||
}
|
||||
$url = '/' . ltrim($this->_url, '/') . $this->payConfig->getAccessToken();
|
||||
$url = '/' . ltrim($this->_msgUrl, '/') . $this->payConfig->getAccessToken();
|
||||
|
||||
return $this->post($url, ['appid' => $this->payConfig->appId, 'content' => $content]);
|
||||
return $this->post('api.q.qq.com', $url, ['appid' => $this->payConfig->appId, 'content' => $content]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class Token extends SmallProgram
|
||||
'appid' => $this->payConfig->appId,
|
||||
'secret' => $this->payConfig->appSecret
|
||||
];
|
||||
return $this->get('/api/getToken', $query);
|
||||
return $this->get('api.q.qq.com', '/api/getToken', $query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-36
@@ -9,7 +9,6 @@
|
||||
namespace wchat\wx;
|
||||
|
||||
use Exception;
|
||||
use wchat\common\Decode;
|
||||
use wchat\common\Result;
|
||||
|
||||
class Account extends SmallProgram
|
||||
@@ -26,7 +25,7 @@ class Account extends SmallProgram
|
||||
$param['js_code'] = $code;
|
||||
$param['grant_type'] = 'authorization_code';
|
||||
|
||||
return $this->get('/sns/jscode2session', $param);
|
||||
return $this->get('api.weixin.qq.com', '/sns/jscode2session', $param);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +39,7 @@ class Account extends SmallProgram
|
||||
$param['js_code'] = $code;
|
||||
$param['grant_type'] = 'authorization_code';
|
||||
|
||||
return $this->get('/sns/oauth2/access_token', $param);
|
||||
return $this->get('api.weixin.qq.com', '/sns/oauth2/access_token', $param);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +54,7 @@ class Account extends SmallProgram
|
||||
'openid' => $openid,
|
||||
'lang' => 'zh_CN'
|
||||
];
|
||||
return $this->get('/cgi-bin/user/info', $query);
|
||||
return $this->get('api.weixin.qq.com', '/cgi-bin/user/info', $query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,33 +68,7 @@ class Account extends SmallProgram
|
||||
'access_token' => $this->payConfig->getAccessToken(),
|
||||
'openid' => $openid,
|
||||
];
|
||||
return $this->get('/sns/userinfo', $query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $encryptedData
|
||||
* @param $iv
|
||||
* @param $sessionKey
|
||||
* @param bool $asArray
|
||||
* @return object|array
|
||||
* @throws
|
||||
*
|
||||
* * <li>-41001: encodingAesKey 非法</li>
|
||||
* <li>-41003: aes 解密失败</li>
|
||||
* <li>-41004: 解密后得到的buffer非法</li>
|
||||
* <li>-41005: base64加密失败</li>
|
||||
* <li>-41016: base64解密失败</li>
|
||||
*/
|
||||
public function decode($encryptedData, $iv, $sessionKey, bool $asArray = false): object|array
|
||||
{
|
||||
$decode = new Decode();
|
||||
$decode->setSessionKey($sessionKey);
|
||||
$decode->setEncryptedData($encryptedData);
|
||||
$decode->setAppId($this->payConfig->getAppid());
|
||||
$decode->setIv($iv);
|
||||
|
||||
return $decode->decode($asArray);
|
||||
return $this->get('api.weixin.qq.com', '/sns/userinfo', $query);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +84,7 @@ class Account extends SmallProgram
|
||||
$sendBody['path'] = $path;
|
||||
$sendBody['width'] = $width;
|
||||
|
||||
return $this->get($url . $this->payConfig->getAccessToken(), $sendBody);
|
||||
return $this->get('api.weixin.qq.com', $url . $this->payConfig->getAccessToken(), $sendBody);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,11 +102,11 @@ class Account extends SmallProgram
|
||||
$sendBody['width'] = $width;
|
||||
$sendBody['auto_color'] = $auto_color;
|
||||
$sendBody['is_hyaline'] = $is_hyaline;
|
||||
$url = 'wxa/getwxacode?access_token=' . $this->getConfig()->getAccessToken();
|
||||
$url = 'wxa/getwxacode?access_token=' . $this->payConfig->getAccessToken();
|
||||
if ($auto_color) {
|
||||
$sendBody['line_color'] = $line_color;
|
||||
}
|
||||
return $this->get($url . $this->payConfig->getAccessToken(), $sendBody);
|
||||
return $this->get('api.weixin.qq.com', $url . $this->payConfig->getAccessToken(), $sendBody);
|
||||
|
||||
}
|
||||
|
||||
@@ -152,11 +125,11 @@ class Account extends SmallProgram
|
||||
$sendBody['width'] = $width;
|
||||
$sendBody['auto_color'] = $auto_color;
|
||||
$sendBody['is_hyaline'] = $is_hyaline;
|
||||
$url = 'wxa/getwxacodeunlimit?access_token=' . $this->getConfig()->getAccessToken();
|
||||
$url = 'wxa/getwxacodeunlimit?access_token=' . $this->payConfig->getAccessToken();
|
||||
if ($auto_color) {
|
||||
$sendBody['line_color'] = $line_color;
|
||||
}
|
||||
return $this->get($url . $this->payConfig->getAccessToken(), $sendBody);
|
||||
return $this->get('api.weixin.qq.com', $url . $this->payConfig->getAccessToken(), $sendBody);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -225,15 +225,15 @@ class Message extends SmallProgram
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filePath
|
||||
* @param $type
|
||||
* @param string $filePath
|
||||
* @param string $type
|
||||
* @param bool $isPermanent
|
||||
* @param string $title
|
||||
* @param string $introduction
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function upload($filePath, $type, bool $isPermanent = false, string $title = '', string $introduction = ''): Result
|
||||
public function uploadFile(string $filePath, string $type, bool $isPermanent = false, string $title = '', string $introduction = ''): Result
|
||||
{
|
||||
if (!file_exists($filePath)) {
|
||||
throw new Exception('文件不存在');
|
||||
@@ -253,7 +253,7 @@ class Message extends SmallProgram
|
||||
if ($isPermanent && $mime == 'video/mp3') {
|
||||
$data = ['media' => $real_path, 'description[title]' => $title, 'description[introduction]' => $introduction];
|
||||
}
|
||||
return $this->post($url, $data);
|
||||
return $this->post('api.weixin.qq.com', $url, $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -273,6 +273,6 @@ class Message extends SmallProgram
|
||||
private function sendKefuMsg()
|
||||
{
|
||||
$url = '/cgi-bin/message/custom/send?access_token=' . $this->payConfig->getAccessToken();
|
||||
return $this->post($url, $this->msgData);
|
||||
return $this->post('api.weixin.qq.com', $url, $this->msgData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,6 @@ class PublicTemplate extends SmallProgram
|
||||
if (!empty($this->miniprogram)) {
|
||||
$default['miniprogram'] = $this->miniprogram;
|
||||
}
|
||||
return $this->post($url, $default);
|
||||
return $this->post('api.weixin.qq.com', $url, $default);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ class SecCheck extends SmallProgram
|
||||
}
|
||||
$access_token = $this->payConfig->getAccessToken();
|
||||
|
||||
return $this->upload($this->_url . '?access_token=' . $access_token, [
|
||||
return $this->upload('api.weixin.qq.com', $this->_url . '?access_token=' . $access_token, [
|
||||
'media' => new \CURLFile($path)
|
||||
]);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class SecCheck extends SmallProgram
|
||||
}
|
||||
$requestUrl = $this->_mediaCheckAsync . $this->payConfig->getAccessToken();
|
||||
|
||||
return $this->post($requestUrl, ['media_url' => $url, 'media_type' => $type]);
|
||||
return $this->post('api.weixin.qq.com', $requestUrl, ['media_url' => $url, 'media_type' => $type]);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class SecCheck extends SmallProgram
|
||||
}
|
||||
$requestUrl = $this->_msgUrl . $this->payConfig->getAccessToken();
|
||||
|
||||
return $this->post($requestUrl, ['content' => $content]);
|
||||
return $this->post('api.weixin.qq.com', $requestUrl, ['content' => $content]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class Token extends SmallProgram
|
||||
$query['appid'] = $this->payConfig->appId;
|
||||
$query['secret'] = $this->payConfig->appSecret;
|
||||
}
|
||||
return $this->get('cgi-bin/token', $query);
|
||||
return $this->get('api.weixin.qq.com', 'cgi-bin/token', $query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-12
@@ -13,18 +13,18 @@ class WxV3Payment extends SmallProgram
|
||||
use WxV3PaymentTait;
|
||||
|
||||
|
||||
/**
|
||||
* @param $orderNo
|
||||
* @param int $total
|
||||
* @param string|null $openId
|
||||
* @param string $payer_client_ip
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* @param $orderNo
|
||||
* @param int $total
|
||||
* @param string|null $openId
|
||||
* @param string $payer_client_ip
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
||||
{
|
||||
$body = $this->getInitCore($orderNo, $total);
|
||||
$body['payer'] = ['openid' => $openId];
|
||||
$body = $this->getInitCore($orderNo, $total);
|
||||
$body['payer'] = ['openid' => $openId];
|
||||
$body['scene_info'] = ['payer_client_ip' => $payer_client_ip];
|
||||
|
||||
$sign = $this->signature('POST', '/v3/pay/transactions/jsapi', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
|
||||
@@ -34,9 +34,8 @@ class WxV3Payment extends SmallProgram
|
||||
$client->close();
|
||||
|
||||
$json = json_decode($client->getBody(), TRUE);
|
||||
var_dump($client->getBody());
|
||||
if (!isset($json['prepay_id'])) {
|
||||
throw new Exception('微信支付调用失败');
|
||||
throw new Exception('微信支付调用失败: ' . $client->getBody());
|
||||
}
|
||||
|
||||
return $this->createResponse($json, $body);
|
||||
|
||||
@@ -12,28 +12,11 @@ use wchat\common\Help;
|
||||
*/
|
||||
const BLOCK_SIZE = 16;
|
||||
|
||||
/**
|
||||
* Bytes length of the AES secret key.
|
||||
*/
|
||||
const KEY_LENGTH_BYTE = 32;
|
||||
|
||||
/**
|
||||
* Bytes Length of the authentication tag in AEAD cipher mode
|
||||
* @deprecated 1.0 - As of the OpenSSL described, the `auth_tag` length may be one of 16, 15, 14, 13, 12, 8 or 4.
|
||||
* Keep it only compatible for the samples on the official documentation.
|
||||
*/
|
||||
const AUTH_TAG_LENGTH_BYTE = 16;
|
||||
|
||||
/**
|
||||
* The `aes-256-gcm` algorithm string
|
||||
*/
|
||||
const ALGO_AES_256_GCM = 'aes-256-gcm';
|
||||
|
||||
/**
|
||||
* The `aes-256-ecb` algorithm string
|
||||
*/
|
||||
const ALGO_AES_256_ECB = 'aes-256-ecb';
|
||||
|
||||
trait WxV3PaymentTait
|
||||
{
|
||||
|
||||
@@ -111,7 +94,7 @@ trait WxV3PaymentTait
|
||||
{
|
||||
$payConfig = $this->getPayConfig();
|
||||
|
||||
$mch_private_key = openssl_get_privatekey($payConfig->pay->wx->mchKey);
|
||||
$mch_private_key = openssl_get_privatekey(file_get_contents($payConfig->pay->wx->mchKey));
|
||||
|
||||
openssl_sign($body, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
|
||||
return base64_encode($raw_sign);
|
||||
|
||||
Reference in New Issue
Block a user