新增微信支付类
This commit is contained in:
parent
186f92c4ea
commit
bdcbd26a8d
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ vendor/
|
||||
.DS_Store
|
||||
.phpunit*
|
||||
*.cache
|
||||
*.pem
|
||||
*.p12
|
||||
@ -48,6 +48,7 @@ WORKDIR /opt/www
|
||||
# RUN composer install --no-dev --no-scripts
|
||||
|
||||
COPY . /opt/www
|
||||
COPY /data/www/cret/wechat/pay/1636644248 /opt/www/extend/Wechat/certs
|
||||
RUN composer install --no-dev -o && php bin/hyperf.php
|
||||
|
||||
EXPOSE 9501
|
||||
|
||||
12
composer.lock
generated
12
composer.lock
generated
@ -6467,16 +6467,16 @@
|
||||
},
|
||||
{
|
||||
"name": "w7corp/easywechat",
|
||||
"version": "6.10.0",
|
||||
"version": "6.11.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/w7corp/easywechat.git",
|
||||
"reference": "558a58fd37e961027a5f81164feddc13b60362a3"
|
||||
"reference": "a0eead024a96c2158884cf36761941e95a7b1073"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://mirrors.huaweicloud.com/repository/php/w7corp/easywechat/6.10.0/w7corp-easywechat-6.10.0.zip",
|
||||
"reference": "558a58fd37e961027a5f81164feddc13b60362a3",
|
||||
"url": "https://mirrors.huaweicloud.com/repository/php/w7corp/easywechat/6.11.1/w7corp-easywechat-6.11.1.zip",
|
||||
"reference": "a0eead024a96c2158884cf36761941e95a7b1073",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -6486,7 +6486,7 @@
|
||||
"ext-openssl": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-sodium": "*",
|
||||
"monolog/monolog": "^2.2",
|
||||
"monolog/monolog": "^2.2|^3.0",
|
||||
"nyholm/psr7": "^1.5",
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"overtrue/socialite": "^3.5.4|^4.0.1",
|
||||
@ -6558,7 +6558,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-11-28T14:35:59+00:00"
|
||||
"time": "2023-02-17T10:13:40+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
||||
@ -44,11 +44,9 @@ return [
|
||||
]
|
||||
],
|
||||
"pay" => [
|
||||
"patient" => [
|
||||
"app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'),
|
||||
"mchid" => env('PATIENT_WECHAT_MCH_ID', '1636644248'),
|
||||
"apiv3_secret" => env('PATIENT_WECHAT_APIv3_SECRET', 'gdxz292sjSOadN3m2pCda03NfCsmNadY'),
|
||||
],
|
||||
"mch_id" => env('PATIENT_WECHAT_MCH_ID', '1636644248'),
|
||||
"app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'),
|
||||
"v3_api_secret" => env('PATIENT_WECHAT_APIv3_SECRET', 'gdxz292sjSOadN3m2pCda03NfCsmNadY'),
|
||||
]
|
||||
],
|
||||
"alibaba" => [// 阿里
|
||||
|
||||
@ -53,7 +53,7 @@ class Wechat
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function createApp(string $appId, string $appSecret)
|
||||
public function createApp(string $appId, string $appSecret): void
|
||||
{
|
||||
$config = array(
|
||||
"app_id" => $appId,
|
||||
@ -229,7 +229,8 @@ class Wechat
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function getUnlimitedQRCode(array $options){
|
||||
public function getUnlimitedQRCode(array $options): array|string
|
||||
{
|
||||
try {
|
||||
$this->createApp($this->config['app_id'], $this->config['secret']);
|
||||
|
||||
|
||||
45
extend/Wechat/WechatPay.php
Normal file
45
extend/Wechat/WechatPay.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\Wechat;
|
||||
|
||||
/**
|
||||
* 微信支付类
|
||||
*/
|
||||
class WechatPay
|
||||
{
|
||||
protected $app;
|
||||
|
||||
// 创建工厂类
|
||||
public function createApp(){
|
||||
$config = [
|
||||
'mch_id' => config("we_chat.pay.mch_id"),
|
||||
|
||||
// 商户证书
|
||||
'private_key' => __DIR__ . '/certs/1636644248/apiclient_key.pem',
|
||||
'certificate' => __DIR__ . '/certs/1636644248/apiclient_cert.pem',
|
||||
|
||||
// v3 API 秘钥
|
||||
'secret_key' => config("we_chat.pay.v3_api_secret"),
|
||||
|
||||
// v2 API 秘钥
|
||||
'v2_secret_key' => '',
|
||||
|
||||
// 平台证书:微信支付 APIv3 平台证书,需要使用工具下载
|
||||
// 下载工具:https://github.com/wechatpay-apiv3/CertificateDownloader
|
||||
'platform_certs' => [
|
||||
// 请使用绝对路径
|
||||
__DIR__ . '/certs/wechatpay_112FCCD1B9ECC8292703AB7363C73D74B6AFDC1A.pem',
|
||||
],
|
||||
|
||||
/**
|
||||
* 接口请求相关配置,超时时间等,具体可用参数请参考:
|
||||
* https://github.com/symfony/symfony/blob/5.3/src/Symfony/Contracts/HttpClient/HttpClientInterface.php
|
||||
*/
|
||||
'http' => [
|
||||
'throw' => false, // 状态码非 200、300 时是否抛出异常,默认为开启
|
||||
'timeout' => 5.0,
|
||||
// 'base_uri' => 'https://api.mch.weixin.qq.com/', // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user