微信支付证书 php 格式,微信支付下载微信平台证书 apiV3(1)

namespace App\Http\Controllers\WxPay;

// 该文件复制自 \vendor\wechatpay\wechatpay-guzzle-middleware\tool\CertificateDownloader.php

use Illuminate\Http\Request;

use App\Http\Controllers\Controller;

use GuzzleHttp\HandlerStack;

use GuzzleHttp\Handler\CurlHandler;

use GuzzleHttp\Client;

use GuzzleHttp\Exception\RequestException;

use WechatPay\GuzzleMiddleware\WechatPayMiddleware;

use WechatPay\GuzzleMiddleware\Validator;

use WechatPay\GuzzleMiddleware\Util\PemUtil;

use WechatPay\GuzzleMiddleware\Util\AesUtil;

use WechatPay\GuzzleMiddleware\Auth\CertificateVerifier;

use WechatPay\GuzzleMiddleware\Auth\WechatPay2Validator;

class CertificateDownloader extends Controller{

const VERSION = '0.1.0';

public function index(){

$opts=[

'mchid'=> config('globaldatas.mchid'),

'serialno'=> config('globaldatas.serial_no'),

'privatekey'=> "apiclient_cert.pem",

'wechatpay-cert'=> null,

'key'=> config('globaldatas.apiv'),

'output'=> '微信平台证书存放目录'

];

$this->downloadCert($opts);

}

public function run(){

$opts = $this->parseOpts();

if (!$opts) {

$this->printHelp();

exit(1);

}

if (isset($opts['help'])) {

$this->printHelp();

exit(0);

}

if (isset($opts['version'])) {

echo self::VERSION . "\n";

exit(0);

}

$this->downloadCert($opts);

}

private function parseOpts(){

$opts = [

[ 'key', 'k', true ],

[ 'mchid', 'm', true ],

[ 'privatekey', 'f', true ],

[ 'serialno', 's', true ],

[ 'output', 'o', true ],

[ 'wechatpay-cert', 'c', false ],

];

$shortopts = 'hV';

$longopts = [ 'help', 'version' ];

foreach ($opts as $opt) {

$shortopts .= $opt[1].':';

$longopts[] = $opt[0].':';

}

$parsed = getopt($shortopts, $longopts);

if (!$parsed) {

return false;

}

$args = [];

foreach ($opts as $opt) {

if (isset($parsed[$opt[0]])) {

$args[$opt[0]] = $parsed[$opt[0]];

}

else if (isset($parsed[$opt[1]])) {

$args[$opt[0]] = $parsed[$opt[1]];

}

else if ($opt[2]) {

return false;

}

}

if (isset($parsed['h']) || isset($parsed['help'])) {

$args['help'] = true;

}

if (isset($parsed['V']) || isset($parsed['version'])) {

$args['version'] = true;

}

return $args;

}

private function printHelp(){

echo <<

Usage: 微信支付平台证书下载工具 [-hV] [-c=]

-f= -k= -m=

-o= -s=

-m, --mchid= 商户号

-s, --serialno= 商户证书的序列号

-f, --privatekey=

商户的私钥文件

-k, --key= ApiV3Key

-c, --wechatpay-cert=

微信支付平台证书,验证签名

-o, --output=

下载成功后保存证书的路径

-V, --version Print version information and exit.

-h, --help Show this help message and exit.

EOD;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值