eee
This commit is contained in:
+209
-205
@@ -11,250 +11,254 @@ class AppConfig
|
||||
{
|
||||
|
||||
|
||||
const int TYPE_WCHAT_PROJECT = 0;
|
||||
const int TYPE_ALI_GAME_OR_APPLET = 3;
|
||||
const int TYPE_QQ_GAME_OR_APPLET = 1;
|
||||
const int TYPE_APP_PROJECT = 2;
|
||||
const int TYPE_WCHAT_PROJECT = 0;
|
||||
const int TYPE_ALI_GAME_OR_APPLET = 3;
|
||||
const int TYPE_QQ_GAME_OR_APPLET = 1;
|
||||
const int TYPE_APP_PROJECT = 2;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appId = '';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appId = '';
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private string $host = '';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private string $host = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appSecret = '';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appSecret = '';
|
||||
|
||||
|
||||
/**
|
||||
* @var PayConfig
|
||||
*/
|
||||
public PayConfig $pay;
|
||||
/**
|
||||
* @var PayConfig
|
||||
*/
|
||||
public PayConfig $pay;
|
||||
|
||||
|
||||
private string $proxyHost = '';
|
||||
private int $proxyPort = 0;
|
||||
private string $notifyUrl = '';
|
||||
private string $body = '';
|
||||
private string $currency = 'CNY';
|
||||
private string $remoteIp = '';
|
||||
private string $accessToken = '';
|
||||
private string $tradeType = 'JSAPI';
|
||||
private string $signType = 'MD5';
|
||||
private string $proxyHost = '';
|
||||
private int $proxyPort = 0;
|
||||
private string $notifyUrl = '';
|
||||
private string $body = '';
|
||||
private string $currency = 'CNY';
|
||||
private string $remoteIp = '';
|
||||
private string $accessToken = '';
|
||||
private string $tradeType = 'JSAPI';
|
||||
private string $signType = 'MD5';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $type;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $type;
|
||||
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
#[ArrayShape(['token' => 'string', 'secret' => 'string', 'unionId' => 'string'])]
|
||||
public array $notice = ['token' => '', 'secret' => '', 'unionId' => ''];
|
||||
/**
|
||||
* @var NoticeConfig|null
|
||||
*/
|
||||
public ?NoticeConfig $notice = null;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pay = new PayConfig();
|
||||
$this->pay->wx = new Wx();
|
||||
$this->pay->qq = new Qq();
|
||||
$this->pay->ali = new Aliyun();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->pay = new PayConfig;
|
||||
$this->pay->wx = new Wx;
|
||||
$this->pay->qq = new Qq;
|
||||
$this->pay->ali = new Aliyun;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param object $app
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(object $app): static
|
||||
{
|
||||
$model = new static();
|
||||
$model->appId = $app->appId;
|
||||
$model->appSecret = $app->appSecret;
|
||||
$model->type = $app->type;
|
||||
/**
|
||||
* @param object $app
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(object $app): static
|
||||
{
|
||||
$model = new static;
|
||||
$model->appId = $app->appId;
|
||||
$model->appSecret = $app->appSecret;
|
||||
$model->type = $app->type;
|
||||
$model->notice = NoticeConfig::parse($app->notice);
|
||||
|
||||
PayConfig::parse($app->pay, $model->pay);
|
||||
PayConfig::parse($app->pay, $model->pay);
|
||||
|
||||
return $model;
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function typeIsApp(): bool
|
||||
{
|
||||
return $this->type === self::TYPE_APP_PROJECT;
|
||||
}
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function typeIsApp(): bool
|
||||
{
|
||||
return $this->type === self::TYPE_APP_PROJECT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProxyHost(): string
|
||||
{
|
||||
return $this->proxyHost;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProxyHost(): string
|
||||
{
|
||||
return $this->proxyHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $proxyHost
|
||||
*/
|
||||
public function setProxyHost(string $proxyHost): void
|
||||
{
|
||||
$this->proxyHost = $proxyHost;
|
||||
}
|
||||
/**
|
||||
* @param string $proxyHost
|
||||
*/
|
||||
public function setProxyHost(string $proxyHost): void
|
||||
{
|
||||
$this->proxyHost = $proxyHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getProxyPort(): int
|
||||
{
|
||||
return $this->proxyPort;
|
||||
}
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getProxyPort(): int
|
||||
{
|
||||
return $this->proxyPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $proxyPort
|
||||
*/
|
||||
public function setProxyPort(int $proxyPort): void
|
||||
{
|
||||
$this->proxyPort = $proxyPort;
|
||||
}
|
||||
/**
|
||||
* @param int $proxyPort
|
||||
*/
|
||||
public function setProxyPort(int $proxyPort): void
|
||||
{
|
||||
$this->proxyPort = $proxyPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNotifyUrl(): string
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNotifyUrl(): string
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $notifyUrl
|
||||
*/
|
||||
public function setNotifyUrl(string $notifyUrl): void
|
||||
{
|
||||
$this->notifyUrl = $notifyUrl;
|
||||
}
|
||||
/**
|
||||
* @param string $notifyUrl
|
||||
*/
|
||||
public function setNotifyUrl(string $notifyUrl): void
|
||||
{
|
||||
$this->notifyUrl = $notifyUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBody(): string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBody(): string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $body
|
||||
*/
|
||||
public function setBody(string $body): void
|
||||
{
|
||||
$this->body = $body;
|
||||
}
|
||||
/**
|
||||
* @param string $body
|
||||
*/
|
||||
public function setBody(string $body): void
|
||||
{
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $currency
|
||||
*/
|
||||
public function setCurrency(string $currency): void
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
/**
|
||||
* @param string $currency
|
||||
*/
|
||||
public function setCurrency(string $currency): void
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRemoteIp(): string
|
||||
{
|
||||
return $this->remoteIp;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRemoteIp(): string
|
||||
{
|
||||
return $this->remoteIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $remoteIp
|
||||
*/
|
||||
public function setRemoteIp(string $remoteIp): void
|
||||
{
|
||||
$this->remoteIp = $remoteIp;
|
||||
}
|
||||
/**
|
||||
* @param string $remoteIp
|
||||
*/
|
||||
public function setRemoteIp(string $remoteIp): void
|
||||
{
|
||||
$this->remoteIp = $remoteIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
return $this->accessToken;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
return $this->accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*/
|
||||
public function setAccessToken(string $accessToken): void
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
}
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*/
|
||||
public function setAccessToken(string $accessToken): void
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTradeType(): string
|
||||
{
|
||||
return $this->tradeType;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTradeType(): string
|
||||
{
|
||||
return $this->tradeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tradeType
|
||||
*/
|
||||
public function setTradeType(string $tradeType): void
|
||||
{
|
||||
$this->tradeType = $tradeType;
|
||||
}
|
||||
/**
|
||||
* @param string $tradeType
|
||||
*/
|
||||
public function setTradeType(string $tradeType): void
|
||||
{
|
||||
$this->tradeType = $tradeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignType(): string
|
||||
{
|
||||
return $this->signType;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignType(): string
|
||||
{
|
||||
return $this->signType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $signType
|
||||
*/
|
||||
public function setSignType(string $signType): void
|
||||
{
|
||||
$this->signType = $signType;
|
||||
}
|
||||
/**
|
||||
* @param string $signType
|
||||
*/
|
||||
public function setSignType(string $signType): void
|
||||
{
|
||||
$this->signType = $signType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost(): string
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost(): string
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
*/
|
||||
public function setHost(string $host): void
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
/**
|
||||
* @param string $host
|
||||
*/
|
||||
public function setHost(string $host): void
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace wchat\common;
|
||||
|
||||
class NoticeConfig
|
||||
{
|
||||
|
||||
public string $token;
|
||||
public string $encodingAESKey;
|
||||
public string $unionId;
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @param string $encodingAESKey
|
||||
* @param string $unionId
|
||||
*/
|
||||
public function __construct(string $token, string $encodingAESKey, string $unionId)
|
||||
{
|
||||
$this->token = $token;
|
||||
$this->encodingAESKey = $encodingAESKey;
|
||||
$this->unionId = $unionId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param array $map
|
||||
* @return static
|
||||
*/
|
||||
public static function parse(array $map): static
|
||||
{
|
||||
return new static($map['token'], $map['secret'], $map['unionId'] ?? '');
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ class SmallProgram extends Multiprogramming
|
||||
*/
|
||||
public function decode(string $encrypt, string $signature, string $timestamp, string $nonce, string $msg_signature): XPayGoodsDeliverNotify|bool
|
||||
{
|
||||
$WxMsgCrypt = new WxMsgCrypt($this->payConfig->notice['token'], $this->payConfig->notice['secret'], $this->payConfig->appId);
|
||||
$WxMsgCrypt = new WxMsgCrypt($this->payConfig->notice->token, $this->payConfig->notice->encodingAESKey, $this->payConfig->appId);
|
||||
if (!$WxMsgCrypt->verifySignature($timestamp, $nonce, $encrypt, $msg_signature)) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user