Skip to content

Commit d700e32

Browse files
committed
允许微信证书为空
1 parent bab9555 commit d700e32

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/App/Http/Controllers/Api/ConfigController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function publicGatewayForm($gateway,$configs)
107107
->item(['name' => 'app_id', 'type' => 'text', 'label' => 'appId', 'placeholder' => '开发者ID(AppID)'])
108108
->item(['name' => 'seller_id', 'type' => 'text', 'label' => 'mchId', 'placeholder' => '微信商户号'])
109109
->item(['name' => 'other', 'type' => 'text', 'label' => 'AppSecret', 'placeholder' => '开发者密码(AppSecret)'])
110-
->item(array_merge(['name' => 'public_key','type' => 'file', 'label' => 'apiclientCert.',
110+
->item(array_merge(['name' => 'public_key','type' => 'file', 'label' => 'apiclientCert',
111111
'placeholder' => '微信公钥','fileName'=> $this->getFileName($configs->public_key)
112112
],$upload))
113113
->item(array_merge(['name' => 'private_key','type' => 'file', 'label' => 'apiclientKey',

src/App/Http/Controllers/OmnipayController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function wechat($gateway,$order)
6161
'body' => $order['name'],
6262
'total_fee' => $order['fee']*100, //=0.01
6363
'spbill_create_ip' => '127.0.0.1',
64-
'fee_type' => 'CNY'
64+
'fee_type' => 'CNY',
6565
];
6666
return $gateway->purchase($order)->send();
6767
}

src/App/Models/Config.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function gatewayRegister()
3535
$this->where('status', true)->get()->map(function ($item) {
3636
//获取证书密钥文件路径
3737
$upload = new Upload();
38-
$private_key = storage_path('app/'.$upload->getUploadWhereFirst($item->private_key)->path);
39-
$public_key = storage_path('app/'.$upload->getUploadWhereFirst($item->public_key)->path);
38+
$private_key = $item->private_key? storage_path('app/'.$upload->getUploadWhereFirst($item->private_key)->path):null;
39+
$public_key = $item->public_key? storage_path('app/'.$upload->getUploadWhereFirst($item->public_key)->path):null;
4040
switch ($item->gateway) {
4141
case 'alipay':
4242
config(['laravel-omnipay.gateways.'.$item->gateway.'.driver' => $item->driver]);
@@ -50,6 +50,19 @@ public function gatewayRegister()
5050
'notifyUrl' => $item->notify_url
5151
]]);
5252
break;
53+
case 'wechat':
54+
config(['laravel-omnipay.gateways.'.$item->gateway.'.driver' => $item->driver]);
55+
config(['laravel-omnipay.gateways.'.$item->gateway.'.options' => [
56+
'appId' => $item->app_id,
57+
'mchId' => $item->seller_id,
58+
'apiKey' => $item->other,
59+
'keyPath' => $private_key,
60+
'certPath' => $public_key,
61+
'returnUrl' => $item->return_url,
62+
'notifyUrl' => $item->notify_url,
63+
'tradeType' => 'JSAPI',
64+
]]);
65+
break;
5366
case 'unionpay':
5467
config(['laravel-omnipay.gateways.'.$item->gateway.'.driver' => $item->driver]);
5568
config(['laravel-omnipay.gateways.'.$item->gateway.'.options' => [

0 commit comments

Comments
 (0)