eee
This commit is contained in:
+17
-20
@@ -15,10 +15,10 @@ class Account extends SmallProgram
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $code
|
* @param string $code
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
public function login($code): Result
|
public function login(string $code): Result
|
||||||
{
|
{
|
||||||
$param['appid'] = $this->payConfig->appId;
|
$param['appid'] = $this->payConfig->appId;
|
||||||
$param['secret'] = $this->payConfig->appSecret;
|
$param['secret'] = $this->payConfig->appSecret;
|
||||||
@@ -29,10 +29,10 @@ class Account extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $code
|
* @param string $code
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
public function AppLogin($code): Result
|
public function AppLogin(string $code): Result
|
||||||
{
|
{
|
||||||
$param['appid'] = $this->payConfig->pay->wx->appId;
|
$param['appid'] = $this->payConfig->pay->wx->appId;
|
||||||
$param['secret'] = $this->payConfig->pay->wx->appSecret;
|
$param['secret'] = $this->payConfig->pay->wx->appSecret;
|
||||||
@@ -43,11 +43,10 @@ class Account extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $openid
|
* @param string $openid
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function getPublicUserInfo($openid): Result
|
public function getPublicUserInfo(string $openid): Result
|
||||||
{
|
{
|
||||||
$query = [
|
$query = [
|
||||||
'access_token' => $this->payConfig->getAccessToken(),
|
'access_token' => $this->payConfig->getAccessToken(),
|
||||||
@@ -58,11 +57,10 @@ class Account extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $openid
|
* @param string $openid
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function getAppUserInfo($openid): Result
|
public function getAppUserInfo(string $openid): Result
|
||||||
{
|
{
|
||||||
$query = [
|
$query = [
|
||||||
'access_token' => $this->payConfig->getAccessToken(),
|
'access_token' => $this->payConfig->getAccessToken(),
|
||||||
@@ -73,12 +71,11 @@ class Account extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* @param string $path
|
||||||
* @param $width
|
* @param int $width
|
||||||
* @return array|mixed|Result
|
* @return array|mixed|Result
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function createwxaqrcode($path, $width): mixed
|
public function createwxaqrcode(string $path, int $width): mixed
|
||||||
{
|
{
|
||||||
$url = 'cgi-bin/wxaapp/createwxaqrcode?access_token=';
|
$url = 'cgi-bin/wxaapp/createwxaqrcode?access_token=';
|
||||||
$sendBody['path'] = $path;
|
$sendBody['path'] = $path;
|
||||||
@@ -89,14 +86,14 @@ class Account extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* @param string $path
|
||||||
* @param $width
|
* @param int $width
|
||||||
* @param bool $is_hyaline
|
* @param bool $is_hyaline
|
||||||
* @param bool $auto_color
|
* @param bool $auto_color
|
||||||
* @param string $line_color
|
* @param string $line_color
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
public function getwxacode($path, $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
|
public function getwxacode(string $path, int $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
|
||||||
{
|
{
|
||||||
$sendBody['path'] = $path;
|
$sendBody['path'] = $path;
|
||||||
$sendBody['width'] = $width;
|
$sendBody['width'] = $width;
|
||||||
@@ -112,14 +109,14 @@ class Account extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* @param string $path
|
||||||
* @param $width
|
* @param int $width
|
||||||
* @param bool $is_hyaline
|
* @param bool $is_hyaline
|
||||||
* @param bool $auto_color
|
* @param bool $auto_color
|
||||||
* @param string $line_color
|
* @param string $line_color
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
public function getwxacodeunlimit($path, $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
|
public function getwxacodeunlimit(string $path, int $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
|
||||||
{
|
{
|
||||||
$sendBody['path'] = $path;
|
$sendBody['path'] = $path;
|
||||||
$sendBody['width'] = $width;
|
$sendBody['width'] = $width;
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ class ContentAsyncCheck
|
|||||||
return $class->init($params);
|
return $class->init($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $params
|
* @param array $params
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
private function init($params): static
|
private function init(array $params): static
|
||||||
{
|
{
|
||||||
foreach ($params as $item => $param) {
|
foreach ($params as $item => $param) {
|
||||||
$this->{'_' . $item} = $param;
|
$this->{'_' . $item} = $param;
|
||||||
|
|||||||
+40
-40
@@ -19,19 +19,19 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $openid
|
* @param string $openid
|
||||||
*/
|
*/
|
||||||
public function setOpenid($openid)
|
public function setOpenid(string $openid)
|
||||||
{
|
{
|
||||||
$this->msgData['touser'] = $openid;
|
$this->msgData['touser'] = $openid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $content
|
* @param string $content
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendTextNews($content): Result
|
public function sendTextNews(string $content): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'text';
|
$this->msgData['msgtype'] = 'text';
|
||||||
$this->msgData['text'] = ['content' => $content];
|
$this->msgData['text'] = ['content' => $content];
|
||||||
@@ -40,11 +40,11 @@ class Message extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendImageNews($media_id): Result
|
public function sendImageNews(string $media_id): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'image';
|
$this->msgData['msgtype'] = 'image';
|
||||||
$this->msgData['image'] = ['media_id' => $media_id];
|
$this->msgData['image'] = ['media_id' => $media_id];
|
||||||
@@ -54,11 +54,11 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendVoiceNews($media_id): Result
|
public function sendVoiceNews(string $media_id): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'voice';
|
$this->msgData['msgtype'] = 'voice';
|
||||||
$this->msgData['voice'] = ['media_id' => $media_id];
|
$this->msgData['voice'] = ['media_id' => $media_id];
|
||||||
@@ -67,11 +67,11 @@ class Message extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendMpNewsNews($media_id): Result
|
public function sendMpNewsNews(string $media_id): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'mpnews';
|
$this->msgData['msgtype'] = 'mpnews';
|
||||||
$this->msgData['mpnews'] = ['media_id' => $media_id];
|
$this->msgData['mpnews'] = ['media_id' => $media_id];
|
||||||
@@ -81,14 +81,14 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $title
|
* @param string $title
|
||||||
* @param $description
|
* @param string $description
|
||||||
* @param $url
|
* @param string $url
|
||||||
* @param $picurl
|
* @param string $picurl
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendNewsNews($title, $description, $url, $picurl): Result
|
public function sendNewsNews(string $title, string $description, string $url, string $picurl): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'news';
|
$this->msgData['msgtype'] = 'news';
|
||||||
$this->msgData['news'] = [
|
$this->msgData['news'] = [
|
||||||
@@ -106,11 +106,11 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $title
|
* @param string $title
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendCardNews($title): Result
|
public function sendCardNews(string $title): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'wxcard';
|
$this->msgData['msgtype'] = 'wxcard';
|
||||||
$this->msgData['wxcard'] = ['card_id' => $title];
|
$this->msgData['wxcard'] = ['card_id' => $title];
|
||||||
@@ -120,14 +120,14 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @param $thumb_media_id
|
* @param string $thumb_media_id
|
||||||
* @param $title
|
* @param string $title
|
||||||
* @param $description
|
* @param string $description
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendVideoNews($media_id, $thumb_media_id, $title, $description): Result
|
public function sendVideoNews(string $media_id, string $thumb_media_id, string $title, string $description): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'video';
|
$this->msgData['msgtype'] = 'video';
|
||||||
$this->msgData['video'] = [
|
$this->msgData['video'] = [
|
||||||
@@ -143,15 +143,15 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $musicurl
|
* @param string $musicurl
|
||||||
* @param $hqmusicurl
|
* @param string $hqmusicurl
|
||||||
* @param $thumb_media_id
|
* @param string $thumb_media_id
|
||||||
* @param $title
|
* @param string $title
|
||||||
* @param $description
|
* @param string $description
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendMusicNews($musicurl, $hqmusicurl, $thumb_media_id, $title, $description): Result
|
public function sendMusicNews(string $musicurl, string $hqmusicurl, string $thumb_media_id, string $title, string $description): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'music';
|
$this->msgData['msgtype'] = 'music';
|
||||||
$this->msgData['music'] = [
|
$this->msgData['music'] = [
|
||||||
@@ -166,13 +166,13 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $head_content
|
* @param string $head_content
|
||||||
* @param $tail_content
|
* @param string $tail_content
|
||||||
* @param array $menus
|
* @param array $menus
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendMenuNews($head_content, $tail_content, array $menus = []): Result
|
public function sendMenuNews(string $head_content, string $tail_content, array $menus = []): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'msgmenu';
|
$this->msgData['msgtype'] = 'msgmenu';
|
||||||
$this->msgData['msgmenu'] = [
|
$this->msgData['msgmenu'] = [
|
||||||
@@ -191,11 +191,11 @@ class Message extends SmallProgram
|
|||||||
private int $index = 0;
|
private int $index = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $id
|
* @param string $id
|
||||||
* @param $menuName
|
* @param string $menuName
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function addNewsMenu($id, $menuName): static
|
public function addNewsMenu(string $id, string $menuName): static
|
||||||
{
|
{
|
||||||
$lists['id'] = $id;
|
$lists['id'] = $id;
|
||||||
$lists['content'] = $menuName;
|
$lists['content'] = $menuName;
|
||||||
@@ -205,14 +205,14 @@ class Message extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $title
|
* @param string $title
|
||||||
* @param $appid
|
* @param string $appid
|
||||||
* @param $pagepath
|
* @param string $pagepath
|
||||||
* @param $thumb_media_id
|
* @param string $thumb_media_id
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendMiniprogrampageNews($title, $appid, $pagepath, $thumb_media_id): Result
|
public function sendMiniprogrampageNews(string $title, string $appid, string $pagepath, string $thumb_media_id): Result
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'msgmenu';
|
$this->msgData['msgtype'] = 'msgmenu';
|
||||||
$this->msgData['miniprogrampage'] = [
|
$this->msgData['miniprogrampage'] = [
|
||||||
@@ -270,7 +270,7 @@ class Message extends SmallProgram
|
|||||||
* @return Result
|
* @return Result
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function sendKefuMsg()
|
private function sendKefuMsg(): Result
|
||||||
{
|
{
|
||||||
$url = '/cgi-bin/message/custom/send?access_token=' . $this->payConfig->getAccessToken();
|
$url = '/cgi-bin/message/custom/send?access_token=' . $this->payConfig->getAccessToken();
|
||||||
return $this->post('api.weixin.qq.com', $url, $this->msgData);
|
return $this->post('api.weixin.qq.com', $url, $this->msgData);
|
||||||
|
|||||||
+2
-2
@@ -76,7 +76,7 @@ class Notify extends SmallProgram
|
|||||||
* @param $value
|
* @param $value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set(string $name, $value): void
|
public function __set(string $name, mixed $value): void
|
||||||
{
|
{
|
||||||
if (property_exists($this, $name)) {
|
if (property_exists($this, $name)) {
|
||||||
$this->$name = $value;
|
$this->$name = $value;
|
||||||
@@ -94,7 +94,7 @@ class Notify extends SmallProgram
|
|||||||
unset($params['sign']);
|
unset($params['sign']);
|
||||||
|
|
||||||
$signType = $this->payConfig->getSignType();
|
$signType = $this->payConfig->getSignType();
|
||||||
$privateKey = $this->payConfig->getKey();
|
$privateKey = $this->payConfig->pay->wx->secret;
|
||||||
$nowSign = Help::sign($params, $privateKey, $signType);
|
$nowSign = Help::sign($params, $privateKey, $signType);
|
||||||
if ($sign === $nowSign) {
|
if ($sign === $nowSign) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+18
-18
@@ -33,46 +33,46 @@ class PublicTemplate extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $templateId
|
* @param string $templateId
|
||||||
*/
|
*/
|
||||||
public function setTemplateId($templateId)
|
public function setTemplateId(string $templateId)
|
||||||
{
|
{
|
||||||
$this->templateId = $templateId;
|
$this->templateId = $templateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $openId
|
* @param string $openId
|
||||||
*/
|
*/
|
||||||
public function setOpenId($openId)
|
public function setOpenId(string $openId)
|
||||||
{
|
{
|
||||||
$this->openId = $openId;
|
$this->openId = $openId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $defaultUrl
|
* @param string $defaultUrl
|
||||||
*/
|
*/
|
||||||
public function setDefaultUrl($defaultUrl)
|
public function setDefaultUrl(string $defaultUrl)
|
||||||
{
|
{
|
||||||
$this->defaultUrl = $defaultUrl;
|
$this->defaultUrl = $defaultUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param string $name
|
||||||
* @param $context
|
* @param string $context
|
||||||
* @param string $color
|
* @param string $color
|
||||||
*/
|
*/
|
||||||
public function replaceKeyword($name, $context, string $color = '')
|
public function replaceKeyword(string $name, string $context, string $color = '')
|
||||||
{
|
{
|
||||||
$this->keywords[$name] = ['value' => $context, 'color' => $color];
|
$this->keywords[$name] = ['value' => $context, 'color' => $color];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param string $name
|
||||||
* @param $context
|
* @param string $context
|
||||||
* @param null $color
|
* @param null $color
|
||||||
*/
|
*/
|
||||||
public function addKeyword($name, $context, $color = null)
|
public function addKeyword(string $name, string $context, $color = null)
|
||||||
{
|
{
|
||||||
if (empty($color)) {
|
if (empty($color)) {
|
||||||
$color = '#000';
|
$color = '#000';
|
||||||
@@ -84,11 +84,11 @@ class PublicTemplate extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $context
|
* @param string $context
|
||||||
* @param string $color
|
* @param string $color
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setFirst($context, string $color = '#f00'): void
|
public function setFirst(string $context, string $color = '#f00'): void
|
||||||
{
|
{
|
||||||
$this->first = [
|
$this->first = [
|
||||||
'value' => $context,
|
'value' => $context,
|
||||||
@@ -97,11 +97,11 @@ class PublicTemplate extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $context
|
* @param string $context
|
||||||
* @param string $color
|
* @param string $color
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setRemark($context, string $color = '#000'): void
|
public function setRemark(string $context, string $color = '#000'): void
|
||||||
{
|
{
|
||||||
$this->remark = [
|
$this->remark = [
|
||||||
'value' => $context,
|
'value' => $context,
|
||||||
@@ -110,11 +110,11 @@ class PublicTemplate extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $appid
|
* @param string $appid
|
||||||
* @param string $pagepath
|
* @param string $pagepath
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setMiniprogram($appid, string $pagepath): void
|
public function setMiniprogram(string $appid, string $pagepath): void
|
||||||
{
|
{
|
||||||
$this->miniprogram = [
|
$this->miniprogram = [
|
||||||
'appid' => $appid,
|
'appid' => $appid,
|
||||||
|
|||||||
+4
-4
@@ -55,20 +55,20 @@ class SecCheck extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $params
|
* @param array $params
|
||||||
* @return ContentAsyncCheck|null
|
* @return ContentAsyncCheck|null
|
||||||
*/
|
*/
|
||||||
public function readByEvent($params): ?ContentAsyncCheck
|
public function readByEvent(array $params): ?ContentAsyncCheck
|
||||||
{
|
{
|
||||||
return ContentAsyncCheck::instance($params);
|
return ContentAsyncCheck::instance($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $content
|
* @param string $content
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
public function text($content): Result
|
public function text(string $content): Result
|
||||||
{
|
{
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
return $this->sendError('文件不存在', 404);
|
return $this->sendError('文件不存在', 404);
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ class WxV3AppPayment extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $orderNo
|
* @param string $orderNo
|
||||||
* @param int $total
|
* @param int $total
|
||||||
* @param string|null $openId
|
* @param string|null $openId
|
||||||
* @param string $payer_client_ip
|
* @param string $payer_client_ip
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
||||||
{
|
{
|
||||||
$body = $this->getInitCore($orderNo, $total);
|
$body = $this->getInitCore($orderNo, $total);
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ class WxV3NativePayment extends SmallProgram
|
|||||||
use WxV3PaymentTait;
|
use WxV3PaymentTait;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $orderNo
|
* @param string $orderNo
|
||||||
* @param int $total
|
* @param int $total
|
||||||
* @param string|null $openId
|
* @param string|null $openId
|
||||||
* @param string $payer_client_ip
|
* @param string $payer_client_ip
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
#[ArrayShape(['code_url' => "string"])]
|
#[ArrayShape(['code_url' => "string"])]
|
||||||
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
||||||
{
|
{
|
||||||
$body = $this->getInitCore($orderNo, $total);
|
$body = $this->getInitCore($orderNo, $total);
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ class WxV3Payment extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $orderNo
|
* @param string $orderNo
|
||||||
* @param int $total
|
* @param int $total
|
||||||
* @param string|null $openId
|
* @param string|null $openId
|
||||||
* @param string $payer_client_ip
|
* @param string $payer_client_ip
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
|
||||||
{
|
{
|
||||||
$body = $this->getInitCore($orderNo, $total);
|
$body = $this->getInitCore($orderNo, $total);
|
||||||
$body['payer'] = ['openid' => $openId];
|
$body['payer'] = ['openid' => $openId];
|
||||||
|
|||||||
+14
-14
@@ -30,12 +30,12 @@ class WxV3PaymentNotify extends SmallProgram
|
|||||||
* @param array $resource
|
* @param array $resource
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $id = "EV-2018022511223320873",
|
public string $id = "EV-2018022511223320873",
|
||||||
public string $create_time = "2015-05-20T13:29:35+08:00",
|
public string $create_time = "2015-05-20T13:29:35+08:00",
|
||||||
public string $resource_type = "encrypt-resource",
|
public string $resource_type = "encrypt-resource",
|
||||||
public string $event_type = "TRANSACTION.SUCCESS",
|
public string $event_type = "TRANSACTION.SUCCESS",
|
||||||
public string $summary = "支付成功",
|
public string $summary = "支付成功",
|
||||||
public array $resource = []
|
public array $resource = []
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -93,10 +93,10 @@ class WxV3PaymentNotify extends SmallProgram
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $signature
|
* @param string $signature
|
||||||
* @param $publicKey
|
* @param OpenSSLAsymmetricKey $publicKey
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function notifyVerify(string $message, string $signature, $publicKey): bool
|
protected function notifyVerify(string $message, string $signature, OpenSSLAsymmetricKey $publicKey): bool
|
||||||
{
|
{
|
||||||
if (($result = openssl_verify($message, base64_decode($signature), $publicKey, OPENSSL_ALGO_SHA256)) === false) {
|
if (($result = openssl_verify($message, base64_decode($signature), $publicKey, OPENSSL_ALGO_SHA256)) === false) {
|
||||||
throw new \UnexpectedValueException('Verified the input $message failed, please checking your $publicKey whether or nor correct.');
|
throw new \UnexpectedValueException('Verified the input $message failed, please checking your $publicKey whether or nor correct.');
|
||||||
@@ -106,11 +106,11 @@ class WxV3PaymentNotify extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $thing
|
* @param string $thing
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return OpenSSLAsymmetricKey
|
* @return OpenSSLAsymmetricKey
|
||||||
*/
|
*/
|
||||||
protected function rsaFrom($thing, string $type = KEY_TYPE_PRIVATE): OpenSSLAsymmetricKey
|
protected function rsaFrom(string $thing, string $type = KEY_TYPE_PRIVATE): OpenSSLAsymmetricKey
|
||||||
{
|
{
|
||||||
$pkey = (($isPublic = $type === KEY_TYPE_PUBLIC) ? openssl_pkey_get_public(file_get_contents($thing)) : openssl_pkey_get_private(file_get_contents($thing)));
|
$pkey = (($isPublic = $type === KEY_TYPE_PUBLIC) ? openssl_pkey_get_public(file_get_contents($thing)) : openssl_pkey_get_private(file_get_contents($thing)));
|
||||||
if (false === $pkey) {
|
if (false === $pkey) {
|
||||||
@@ -120,12 +120,12 @@ class WxV3PaymentNotify extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $ciphertext
|
* @param string $ciphertext
|
||||||
* @param $nonce
|
* @param string $nonce
|
||||||
* @param $associated_data
|
* @param string $associated_data
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function decode($ciphertext, $nonce, $associated_data): bool
|
public function decode(string $ciphertext, string $nonce, string $associated_data): bool
|
||||||
{
|
{
|
||||||
$data = $this->decrypt($ciphertext, $this->payConfig->pay->wx->secret, $nonce, $associated_data);
|
$data = $this->decrypt($ciphertext, $this->payConfig->pay->wx->secret, $nonce, $associated_data);
|
||||||
$this->notifyModel = new NotifyModel();
|
$this->notifyModel = new NotifyModel();
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ trait WxV3PaymentTait
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $orderNo
|
* @param string $orderNo
|
||||||
* @param $total
|
* @param int $total
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getInitCore($orderNo, $total): array
|
public function getInitCore(string $orderNo, int $total): array
|
||||||
{
|
{
|
||||||
$payConfig = $this->getPayConfig();
|
$payConfig = $this->getPayConfig();
|
||||||
if ($payConfig->typeIsApp()) {
|
if ($payConfig->typeIsApp()) {
|
||||||
@@ -87,10 +87,10 @@ trait WxV3PaymentTait
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $body
|
* @param string $body
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function openssl_signature($body): string
|
public function openssl_signature(string $body): string
|
||||||
{
|
{
|
||||||
$payConfig = $this->getPayConfig();
|
$payConfig = $this->getPayConfig();
|
||||||
|
|
||||||
@@ -102,11 +102,11 @@ trait WxV3PaymentTait
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $json
|
* @param array $json
|
||||||
* @param $body
|
* @param array $body
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function createResponse($json, $body): array
|
private function createResponse(array $json, array $body): array
|
||||||
{
|
{
|
||||||
$responseArray['appId'] = $body['appid'];
|
$responseArray['appId'] = $body['appid'];
|
||||||
$responseArray['timeStamp'] = (string)time();
|
$responseArray['timeStamp'] = (string)time();
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ class WxV3Withdrawal extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $orderNo
|
* @param string $orderNo
|
||||||
* @param string $batch_name
|
* @param string $batch_name
|
||||||
* @param string $batch_remark
|
* @param string $batch_remark
|
||||||
* @param TransferDetail[] $details
|
* @param TransferDetail[] $details
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function payment($orderNo, string $batch_name, string $batch_remark, array $details): array
|
public function payment(string $orderNo, string $batch_name, string $batch_remark, array $details): array
|
||||||
{
|
{
|
||||||
$body = $this->create($orderNo, $batch_name, $batch_remark, $details);
|
$body = $this->create($orderNo, $batch_name, $batch_remark, $details);
|
||||||
|
|
||||||
@@ -41,8 +41,15 @@ class WxV3Withdrawal extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $orderNo
|
||||||
|
* @param string $batch_name
|
||||||
|
* @param string $batch_remark
|
||||||
|
* @param array $details
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
#[ArrayShape(['transfer_detail_list' => "array", 'total_amount' => "int", 'total_num' => "int", 'batch_remark' => "string", 'batch_name' => "string", 'out_batch_no' => ""])]
|
#[ArrayShape(['transfer_detail_list' => "array", 'total_amount' => "int", 'total_num' => "int", 'batch_remark' => "string", 'batch_name' => "string", 'out_batch_no' => ""])]
|
||||||
private function create($orderNo, string $batch_name, string $batch_remark, array $details): array
|
private function create(string $orderNo, string $batch_name, string $batch_remark, array $details): array
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$body = ['transfer_detail_list' => []];
|
$body = ['transfer_detail_list' => []];
|
||||||
|
|||||||
+2
-2
@@ -11,12 +11,12 @@ class WxFactory
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $class
|
* @param string $class
|
||||||
* @param AppConfig $config
|
* @param AppConfig $config
|
||||||
* @return object|null
|
* @return object|null
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function get($class, AppConfig $config): ?object
|
public static function get(string $class, AppConfig $config): ?object
|
||||||
{
|
{
|
||||||
$container = Container::instance();
|
$container = Container::instance();
|
||||||
$object = $container->get($class);
|
$object = $container->get($class);
|
||||||
|
|||||||
Reference in New Issue
Block a user