eee
This commit is contained in:
+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