ComposerUpdate

This commit is contained in:
邹景立 2021-04-17 13:23:49 +08:00
parent 9f5ccf2005
commit 8402d815d3
7 changed files with 63 additions and 25 deletions

View File

@ -889,17 +889,17 @@
}, },
{ {
"name": "zoujingli/wechat-developer", "name": "zoujingli/wechat-developer",
"version": "v1.2.29", "version": "v1.2.30",
"version_normalized": "1.2.29.0", "version_normalized": "1.2.30.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/WeChatDeveloper.git", "url": "https://github.com/zoujingli/WeChatDeveloper.git",
"reference": "0b086a29d799ac1c7e04fedddd5ea38e4a885657" "reference": "4ba213dceae358c028dd23a0572e0c85cb6be2aa"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/0b086a29d799ac1c7e04fedddd5ea38e4a885657", "url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/4ba213dceae358c028dd23a0572e0c85cb6be2aa",
"reference": "0b086a29d799ac1c7e04fedddd5ea38e4a885657", "reference": "4ba213dceae358c028dd23a0572e0c85cb6be2aa",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -919,7 +919,7 @@
"ext-xml": "*", "ext-xml": "*",
"php": ">=5.4" "php": ">=5.4"
}, },
"time": "2021-03-23T10:12:26+00:00", "time": "2021-04-15T03:16:50+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2021-04-14 10:13:59 // This file is automatically generated at:2021-04-17 13:23:25
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\admin\\Library', 0 => 'think\\admin\\Library',

View File

@ -88,7 +88,7 @@ class We
* 定义当前版本 * 定义当前版本
* @var string * @var string
*/ */
const VERSION = '1.2.29'; const VERSION = '1.2.30';
/** /**
* 静态配置 * 静态配置

View File

@ -170,7 +170,7 @@ class BasicWePay
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
protected function callPostApi($url, array $data, $isCert = false, $signType = 'HMAC-SHA256', $needSignType = true) protected function callPostApi($url, array $data, $isCert = false, $signType = 'HMAC-SHA256', $needSignType = true, $needNonceStr = true)
{ {
$option = []; $option = [];
if ($isCert) { if ($isCert) {
@ -192,7 +192,8 @@ class BasicWePay
} }
} }
$params = $this->params->merge($data); $params = $this->params->merge($data);
$needSignType && ($params['sign_type'] = strtoupper($signType)); if (!$needNonceStr) unset($params['nonce_str']);
if ($needSignType) $params['sign_type'] = strtoupper($signType);
$params['sign'] = $this->getPaySign($params, $signType); $params['sign'] = $this->getPaySign($params, $signType);
$result = Tools::xml2arr(Tools::post($url, Tools::arr2xml($params), $option)); $result = Tools::xml2arr(Tools::post($url, Tools::arr2xml($params), $option));
if ($result['return_code'] !== 'SUCCESS') { if ($result['return_code'] !== 'SUCCESS') {

View File

@ -1,11 +1,23 @@
<?php <?php
// +----------------------------------------------------------------------
// | WeChatDeveloper
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
namespace WePay; namespace WePay;
use WeChat\Contracts\BasicWePay; use WeChat\Contracts\BasicWePay;
/** /**
* 商户提交订单到海关 * 微信扩展上报海关
* Class Custom * Class Custom
* @package WePay * @package WePay
*/ */
@ -22,7 +34,7 @@ class Custom extends BasicWePay
public function add(array $options = []) public function add(array $options = [])
{ {
$url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclareorder'; $url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclareorder';
return $this->callPostApi($url, $options, false, 'MD5'); return $this->callPostApi($url, $options, false, 'MD5', false, false);
} }
/** /**
@ -35,7 +47,7 @@ class Custom extends BasicWePay
public function get(array $options = []) public function get(array $options = [])
{ {
$url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclarequery'; $url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclarequery';
return $this->callPostApi($url, $options, false, 'MD5'); return $this->callPostApi($url, $options, false, 'MD5', true, false);
} }
@ -49,7 +61,7 @@ class Custom extends BasicWePay
public function reset(array $options = []) public function reset(array $options = [])
{ {
$url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/newcustoms/customdeclareredeclare'; $url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/newcustoms/customdeclareredeclare';
return $this->callPostApi($url, $options, false, 'MD5'); return $this->callPostApi($url, $options, false, 'MD5', true, false);
} }
} }

View File

@ -71,6 +71,22 @@ abstract class BasicWePay
throw new InvalidArgumentException("Missing Config -- [cert_public]"); throw new InvalidArgumentException("Missing Config -- [cert_public]");
} }
if (stripos($options['cert_public'], '-----BEGIN CERTIFICATE-----') === false) {
if (file_exists($options['cert_public'])) {
$options['cert_public'] = file_get_contents($options['cert_public']);
} else {
throw new InvalidArgumentException("File Non-Existent -- [cert_public]");
}
}
if (stripos($options['cert_private'], '-----BEGIN PRIVATE KEY-----') === false) {
if (file_exists($options['cert_private'])) {
$options['cert_private'] = file_get_contents($options['cert_private']);
} else {
throw new InvalidArgumentException("File Non-Existent -- [cert_private]");
}
}
$this->config['appid'] = isset($options['appid']) ? $options['appid'] : ''; $this->config['appid'] = isset($options['appid']) ? $options['appid'] : '';
$this->config['mch_id'] = $options['mch_id']; $this->config['mch_id'] = $options['mch_id'];
$this->config['mch_v3_key'] = $options['mch_v3_key']; $this->config['mch_v3_key'] = $options['mch_v3_key'];
@ -88,7 +104,7 @@ abstract class BasicWePay
* @param array $config * @param array $config
* @return static * @return static
*/ */
public static function instance(array $config) public static function instance($config)
{ {
$key = md5(get_called_class() . serialize($config)); $key = md5(get_called_class() . serialize($config));
if (isset(self::$cache[$key])) return self::$cache[$key]; if (isset(self::$cache[$key])) return self::$cache[$key];

View File

@ -1,17 +1,26 @@
<?php <?php
return [ $certPublic = <<<CERT
'appid' => '绑定的APPID',
'mch_id' => '您的商户编号',
'mch_v3_key' => '您的V3接口密码',
'cert_public' => <<<EOF
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
您的证书内容 你的微信商户证书公钥内容
-----END CERTIFICATE----- -----END CERTIFICATE-----
EOF, CERT;
'cert_private' => <<<EOF
$certPrivate = <<<CERT
-----BEGIN PRIVATE KEY----- -----BEGIN PRIVATE KEY-----
您的证书内容 你的微信商户证书私钥内容
-----END PRIVATE KEY----- -----END PRIVATE KEY-----
EOF, CERT;
return [
// 商户绑定的公众号APPID
'appid' => '',
// 微信商户编号ID
'mch_id' => '',
// 微信商户V3接口密钥
'mch_v3_key' => '',
// 微信商户证书公钥,支持证书内容或文件路径
'cert_public' => $certPublic,
// 微信商户证书私钥,支持证书内容或文件路径
'cert_private' => $certPrivate,
]; ];