20 Commits

Author SHA1 Message Date
as2252258 693ec4fa65 Default Changelist 2023-11-07 16:48:59 +08:00
as2252258 389f5261c7 Default Changelist 2023-11-07 16:33:09 +08:00
as2252258 cf03ebd6dc Default Changelist 2023-11-07 16:31:30 +08:00
as2252258 e0d1811a00 Default Changelist 2023-11-07 16:29:44 +08:00
as2252258 1a78bdb173 Default Changelist 2023-11-07 16:26:06 +08:00
as2252258 c5f8b19a83 Default Changelist 2023-11-07 16:14:59 +08:00
as2252258 227ff1c166 Default Changelist 2023-11-07 16:14:09 +08:00
as2252258 b8960deda5 Default Changelist 2023-11-07 16:09:40 +08:00
as2252258 ac70bd3df5 Default Changelist 2023-11-07 16:07:57 +08:00
as2252258 9264f05a49 Default Changelist 2023-11-07 16:01:11 +08:00
as2252258 a2dc66ec84 Default Changelist 2023-11-07 15:59:17 +08:00
as2252258 d0a6787b85 Default Changelist 2023-11-07 15:56:53 +08:00
as2252258 7f2bdbdb4f Default Changelist 2023-11-07 15:55:50 +08:00
as2252258 459d298983 Default Changelist 2023-11-07 15:39:46 +08:00
as2252258 a876b780f5 Default Changelist 2023-11-07 15:17:59 +08:00
as2252258 885c902be8 Default Changelist 2023-11-07 15:14:25 +08:00
as2252258 43f504b2ad Default Changelist 2023-11-07 15:13:11 +08:00
as2252258 dbdae7c6c5 Default Changelist 2023-11-07 14:02:43 +08:00
as2252258 b87232bbc0 Default Changelist 2023-11-07 13:48:18 +08:00
as2252258 d9528679ff Default Changelist 2023-11-07 13:48:04 +08:00
26 changed files with 1043 additions and 734 deletions
+1
View File
@@ -1,3 +1,4 @@
/.idea/php.xml /.idea/php.xml
vendor/ vendor/
composer.lock composer.lock
.idea/*
+7
View File
@@ -162,6 +162,13 @@ abstract class Subject extends Multiprogramming
$client = new Client($this->getHost(), 443, true); $client = new Client($this->getHost(), 443, true);
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']); $client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->getUrl() . '?access_token=' . $access_token, $params); $client->post($this->getUrl() . '?access_token=' . $access_token, $params);
$client->close(); $client->close();
+7
View File
@@ -133,6 +133,13 @@ abstract class Template extends Multiprogramming
$client = new Client($this->getHost(), 443, true); $client = new Client($this->getHost(), 443, true);
$client->withHeader(['Content-Type' => 'application/json; charset=utf-8']); $client->withHeader(['Content-Type' => 'application/json; charset=utf-8']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->getUrl() . '?access_token=' . $access_token, $params); $client->post($this->getUrl() . '?access_token=' . $access_token, $params);
$client->close(); $client->close();
+73
View File
@@ -107,11 +107,19 @@ class Config
private string $remote_addr = '127.0.0.1'; private string $remote_addr = '127.0.0.1';
private string $proxyHost = '';
private int $proxyPort = 0;
private string $ssl_cert = ''; private string $ssl_cert = '';
private string $ssl_key = ''; private string $ssl_key = '';
private string $ssl_ca = ''; private string $ssl_ca = '';
private int $port = 443; private int $port = 443;
private string $mchCert = '';
private string $mchKey = '';
/** /**
* @var string * @var string
*/ */
@@ -120,6 +128,38 @@ class Config
private string $agent = ''; private string $agent = '';
private bool $usrSwoole = false; private bool $usrSwoole = false;
/**
* @return string
*/
public function getMchCert(): string
{
return $this->mchCert;
}
/**
* @param string $mchCert
*/
public function setMchCert(string $mchCert): void
{
$this->mchCert = $mchCert;
}
/**
* @return string
*/
public function getMchKey(): string
{
return $this->mchKey;
}
/**
* @param string $mchKey
*/
public function setMchKey(string $mchKey): void
{
$this->mchKey = $mchKey;
}
/** /**
* @return string * @return string
*/ */
@@ -152,6 +192,39 @@ class Config
$this->serial_no = $serial_no; $this->serial_no = $serial_no;
} }
/**
* @param string $proxyHost
*/
public function setProxyHost(string $proxyHost): void
{
$this->proxyHost = $proxyHost;
}
/**
* @param int $proxyPort
*/
public function setProxyPort(int $proxyPort): void
{
$this->proxyPort = $proxyPort;
}
/**
* @return string
*/
public function getProxyHost(): string
{
return $this->proxyHost;
}
/**
* @return int
*/
public function getProxyPort(): int
{
return $this->proxyPort;
}
/** /**
* @return string * @return string
*/ */
+7
View File
@@ -27,6 +27,13 @@ class Account extends SmallProgram
$client = new Client('api.q.qq.com', 443, true); $client = new Client('api.q.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->get('sns/jscode2session', $param); $client->get('sns/jscode2session', $param);
$client->close(); $client->close();
+7
View File
@@ -52,6 +52,13 @@ class Recharge extends SmallProgram
$client = new Client('qpay.qq.com', 443, true); $client = new Client('qpay.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/xml']); $client->withHeader(['Content-Type' => 'application/xml']);
$client->withBody($this->builder()); $client->withBody($this->builder());
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->uniformer); $client->post($this->uniformer);
$client->close(); $client->close();
+10
View File
@@ -303,6 +303,11 @@ class Redhat extends SmallProgram
$client->withSslKeyFile($this->config->getSslKey()); $client->withSslKeyFile($this->config->getSslKey());
$client->withSslCertFile($this->config->getSslCert()); $client->withSslCertFile($this->config->getSslCert());
$client->withCa($this->config->getSslCa()); $client->withCa($this->config->getSslCa());
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->sendUrl, http_build_query($this->generate())); $client->post($this->sendUrl, http_build_query($this->generate()));
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
@@ -336,6 +341,11 @@ class Redhat extends SmallProgram
$requestParam['sign'] = $this->builderSign($requestParam); $requestParam['sign'] = $this->builderSign($requestParam);
$client = new Client('qpay.qq.com', 443, true); $client = new Client('qpay.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->searchUrl, $requestParam); $client->post($this->searchUrl, $requestParam);
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
+10
View File
@@ -37,6 +37,11 @@ class SecCheck extends SmallProgram
]; ];
$client = new Client('api.q.qq.com', 443, true); $client = new Client('api.q.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'multipart/form-data']); $client->withHeader(['Content-Type' => 'multipart/form-data']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->upload($path, $data); $client->upload($path, $data);
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
@@ -64,6 +69,11 @@ class SecCheck extends SmallProgram
$client = new Client('api.q.qq.com', 443, true); $client = new Client('api.q.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($url, ['appid' => $this->config->getAppid(), 'content' => $content]); $client->post($url, ['appid' => $this->config->getAppid(), 'content' => $content]);
$client->close(); $client->close();
+5
View File
@@ -22,6 +22,11 @@ class Token extends SmallProgram
]; ];
$client = new Client('api.q.qq.com', 443, true); $client = new Client('api.q.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->get('/api/getToken', $query); $client->get('/api/getToken', $query);
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
+7
View File
@@ -91,6 +91,13 @@ class Cash_Bonus extends SmallProgram
$client->withSslCertFile($this->getConfig()->getSslCert()); $client->withSslCertFile($this->getConfig()->getSslCert());
$client->withSslKeyFile($this->getConfig()->getSslKey()); $client->withSslKeyFile($this->getConfig()->getSslKey());
$client->withCa($this->getConfig()->getSslCa()); $client->withCa($this->getConfig()->getSslCa());
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); $client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price));
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
+7
View File
@@ -77,6 +77,13 @@ class Enterprise_payment extends SmallProgram
$client->withSslCertFile($this->getConfig()->getSslCert()); $client->withSslCertFile($this->getConfig()->getSslCert());
$client->withSslKeyFile($this->getConfig()->getSslKey()); $client->withSslKeyFile($this->getConfig()->getSslKey());
$client->withCa($this->getConfig()->getSslCa()); $client->withCa($this->getConfig()->getSslCa());
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); $client->post($this->_cash, $this->orderConfig($mch_billno, $openId, $price));
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
+12
View File
@@ -30,6 +30,9 @@ class Account extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
if (!empty($this->getConfig()->getProxyHost()) && $this->getConfig()->getProxyPort() > 0) {
$client->withProxyHost("192.168.0.57")->withProxyPort(12286);
}
$client->get('sns/jscode2session', $param); $client->get('sns/jscode2session', $param);
$client->close(); $client->close();
@@ -59,6 +62,9 @@ class Account extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
if (!empty($this->getConfig()->getProxyHost()) && $this->getConfig()->getProxyPort() > 0) {
$client->withProxyHost("192.168.0.57")->withProxyPort(12286);
}
$client->get('cgi-bin/user/info', $query); $client->get('cgi-bin/user/info', $query);
$client->close(); $client->close();
@@ -112,6 +118,12 @@ class Account extends SmallProgram
$sendBody['width'] = $width; $sendBody['width'] = $width;
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($url . $this->getConfig()->getAccessToken(), $sendBody); $client->post($url . $this->getConfig()->getAccessToken(), $sendBody);
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
+10
View File
@@ -261,6 +261,11 @@ class Message extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'multipart/form-data']); $client->withHeader(['Content-Type' => 'multipart/form-data']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($url, $data); $client->post($url, $data);
$client->close(); $client->close();
@@ -297,6 +302,11 @@ class Message extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($url, $this->msgData); $client->post($url, $this->msgData);
$client->close(); $client->close();
+5
View File
@@ -148,6 +148,11 @@ class PublicTemplate extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($url, $default); $client->post($url, $default);
$client->close(); $client->close();
+15
View File
@@ -36,6 +36,11 @@ class SecCheck extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'multipart/form-data']); $client->withHeader(['Content-Type' => 'multipart/form-data']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->upload($this->_url . '?access_token=' . $access_token, [ $client->upload($this->_url . '?access_token=' . $access_token, [
'media' => new \CURLFile($path) 'media' => new \CURLFile($path)
]); ]);
@@ -66,6 +71,11 @@ class SecCheck extends SmallProgram
$requestUrl = $this->_mediaCheckAsync . $this->config->getAccessToken(); $requestUrl = $this->_mediaCheckAsync . $this->config->getAccessToken();
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($requestUrl, ['media_url' => $url, 'media_type' => $type]); $client->post($requestUrl, ['media_url' => $url, 'media_type' => $type]);
$client->close(); $client->close();
@@ -104,6 +114,11 @@ class SecCheck extends SmallProgram
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($requestUrl, ['content' => $content]); $client->post($requestUrl, ['content' => $content]);
$client->close(); $client->close();
+5
View File
@@ -22,6 +22,11 @@ class Token extends SmallProgram
]; ];
$client = new Client('api.weixin.qq.com', 443, true); $client = new Client('api.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->get('cgi-bin/token', $query); $client->get('cgi-bin/token', $query);
$client->close(); $client->close();
if (!in_array($client->getStatusCode(), [101, 200, 201])) { if (!in_array($client->getStatusCode(), [101, 200, 201])) {
+5
View File
@@ -34,6 +34,11 @@ class WxV2AppPayment extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, true); $client = new Client('api.mch.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->withBody($this->sign($body)); $client->withBody($this->sign($body));
$client->post($this->uniformed); $client->post($this->uniformed);
$client->close(); $client->close();
+20
View File
@@ -37,6 +37,11 @@ class WxV2PayJsApi extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, true); $client = new Client('api.mch.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$client->withBody($this->sign($body)); $client->withBody($this->sign($body));
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->uniformed); $client->post($this->uniformed);
$client->close(); $client->close();
@@ -83,6 +88,11 @@ class WxV2PayJsApi extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, true); $client = new Client('api.mch.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$client->withBody($this->sign($body)); $client->withBody($this->sign($body));
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->uniformed); $client->post($this->uniformed);
$client->close(); $client->close();
@@ -129,6 +139,11 @@ class WxV2PayJsApi extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, true); $client = new Client('api.mch.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$client->withBody($this->sign($body)); $client->withBody($this->sign($body));
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->uniformed); $client->post($this->uniformed);
$client->close(); $client->close();
@@ -175,6 +190,11 @@ class WxV2PayJsApi extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, true); $client = new Client('api.mch.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$client->withBody($this->sign($body)); $client->withBody($this->sign($body));
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->uniformed); $client->post($this->uniformed);
$client->close(); $client->close();
+5
View File
@@ -40,6 +40,11 @@ class WxV2Withdrawal extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, true); $client = new Client('api.mch.weixin.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']); $client->withHeader(['Content-Type' => 'application/json']);
$client->withBody($body = Help::toXml($array)); $client->withBody($body = Help::toXml($array));
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post($this->transfers); $client->post($this->transfers);
$client->close(); $client->close();
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace wchat\wx\V3;
use Exception;
use JetBrains\PhpStorm\ArrayShape;
use Kiri\Client;
use Kiri\CurlClient;
use wchat\wx\SmallProgram;
class TransferBatches extends SmallProgram
{
use WxV3PaymentTait;
/**
* @param TransferDetail $detail
* @return array
* @throws Exception
*/
#[ArrayShape([])]
public function request(TransferDetail $detail): array
{
$body = [];
$body['appid'] = $this->getConfig()->getAppid();
$body['out_batch_no'] = $detail->out_detail_no;
$body["batch_name"] = $this->getConfig()->getBody();
$body["body"] = $this->getConfig()->getBody();
$body["batch_remark"] = $this->getConfig()->getBody();
$body["total_amount"] = $detail->transfer_amount;
$body["total_num"] = 1;
$body["transfer_detail_list"] = [$detail->toArray()];
$sign = $this->signature('POST', '/v3/transfer/batches', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
$client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign)->withContentType('application/json')
->withAgent('application/json')->withBody($json)->withAddedHeader("Accept", "*/*");
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post('/v3/transfer/batches');
$client->close();
$data = json_decode($client->getBody(), TRUE);
if (json_last_error() != JSON_ERROR_NONE) {
return ['code' => $client->getStatusCode(), 'message' => $client->getBody()];
} else {
return $data;
}
}
}
+8
View File
@@ -24,6 +24,14 @@ class TransferDetail
#[ArrayShape(['out_detail_no' => "string", 'transfer_amount' => "float|int", 'transfer_remark' => "string", 'openid' => "string", 'user_name' => "string"])] #[ArrayShape(['out_detail_no' => "string", 'transfer_amount' => "float|int", 'transfer_remark' => "string", 'openid' => "string", 'user_name' => "string"])]
public function toArray(): array public function toArray(): array
{ {
if (empty($this->user_name)) {
return [
'out_detail_no' => $this->out_detail_no,
'transfer_amount' => $this->transfer_amount,
'transfer_remark' => $this->transfer_remark,
'openid' => $this->openid,
];
}
return [ return [
'out_detail_no' => $this->out_detail_no, 'out_detail_no' => $this->out_detail_no,
'transfer_amount' => $this->transfer_amount, 'transfer_amount' => $this->transfer_amount,
+9 -2
View File
@@ -31,8 +31,15 @@ class WxV3AppPayment extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, TRUE); $client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign)->withContentType('application/json') $client->withAddedHeader('Authorization', $sign)->withContentType('application/json')
->withAgent('application/json')->withBody($json) ->withAgent('application/json')->withBody($json)->withAddedHeader("Accept", "*/*");
->post('/v3/pay/transactions/components');
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post('/v3/pay/transactions/components');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->getBody(), TRUE);
+9 -3
View File
@@ -4,7 +4,6 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client; use Kiri\Client;
use Kiri\Message\Stream;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
@@ -32,8 +31,15 @@ class WxV3NativePayment extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, TRUE); $client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign)->withContentType('application/json') $client->withAddedHeader('Authorization', $sign)->withContentType('application/json')
->withAgent('application/json')->withBody(new Stream($json)) ->withAgent('application/json')->withBody($json)->withAddedHeader("Accept", "*/*");
->post('/v3/pay/transactions/native');
$proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post('/v3/pay/transactions/native');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->getBody(), TRUE);
+10 -5
View File
@@ -4,7 +4,6 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client; use Kiri\Client;
use Kiri\Message\Stream;
use wchat\wx\SmallProgram; use wchat\wx\SmallProgram;
class WxV3Payment extends SmallProgram class WxV3Payment extends SmallProgram
@@ -32,10 +31,16 @@ class WxV3Payment extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, TRUE); $client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign) $client->withAddedHeader('Authorization', $sign)
->withContentType('application/json') ->withContentType('application/json')->withAddedHeader('User-Agent', 'application/json')
->withAddedHeader('User-Agent', 'application/json') ->withBody($json)->withAddedHeader("Accept", "*/*");
->withBody(new Stream($json))
->post('/v3/pay/transactions/jsapi'); $proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post('/v3/pay/transactions/jsapi');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->getBody(), TRUE);
+5 -2
View File
@@ -39,7 +39,10 @@ trait WxV3PaymentTait
*/ */
public function signature(string $http_method, string $canonical_url, string $body = ''): string public function signature(string $http_method, string $canonical_url, string $body = ''): string
{ {
$message = $http_method . "\n" . $canonical_url . "\n" . ($time = time()) . "\n" . ($rand = md5(random_bytes(32))) . "\n" . $body . "\n"; $rand = md5(random_bytes(32));
$time = time();
$message = sprintf("%s\n%s\n%d\n%s\n%s\n", $http_method, $canonical_url, $time, $rand, $body);
$sign = $this->openssl_signature($message); $sign = $this->openssl_signature($message);
@@ -54,7 +57,7 @@ trait WxV3PaymentTait
*/ */
public function openssl_signature($body): string public function openssl_signature($body): string
{ {
$pem = file_get_contents($this->getConfig()->getSslCert()); $pem = file_get_contents($this->getConfig()->getMchKey());
$mch_private_key = openssl_get_privatekey($pem); $mch_private_key = openssl_get_privatekey($pem);
+10 -4
View File
@@ -31,10 +31,16 @@ class WxV3Withdrawal extends SmallProgram
$client = new Client('api.mch.weixin.qq.com', 443, TRUE); $client = new Client('api.mch.weixin.qq.com', 443, TRUE);
$client->withAddedHeader('Authorization', $sign) $client->withAddedHeader('Authorization', $sign)
->withContentType('application/json') ->withContentType('application/json')->withAddedHeader('User-Agent', 'application/json')
->withAddedHeader('User-Agent', 'application/json') ->withBody($json)->withAddedHeader("Accept", "*/*");
->withBody(new Stream($json))
->post('/v3/pay/transactions/batches'); $proxyHost = $this->getConfig()->getProxyHost();
$proxyPort = $this->getConfig()->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
}
$client->post('/v3/pay/transactions/batches');
$client->close(); $client->close();
$json = json_decode($client->getBody(), TRUE); $json = json_decode($client->getBody(), TRUE);