小程序
小游戏
企业微信
微信支付
扫描小程序码分享
微信下载对账单问题返回的是二进制的字符串,对于这个字符串后续应该怎么处理呢?它是一个压缩包的二进制还是单个excel文件的二进制?
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
传了tar_type就是压缩包,没传就是数据流
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
'handler' => $handler,
'query' => $download['query'],
'base_uri' => $download['base_uri'],
]);
return $download + ['stream' => $stream];
})
// 5. 从第一步获取的帐单哈希签名及上一步的文件流,验证存储的文件签名是否相符
->then(static function(array $verify): ?string {
$hashAlgo = strtolower($verify['hash_type'] ?? 'sha1');
$hashValue = $verify['hash_value'] ?? null;
$stream = $verify['stream'];
$signature = \GuzzleHttp\Psr7\Utils::hash(new \GuzzleHttp\Psr7\InflateStream($stream), $hashAlgo);
if (\WeChatPay\Crypto\Hash::equals($signature, $hashValue)) {
$stream->close();
return sprintf('Verified (%s) with %s digest(%s) OK', $stream->getMetadata('uri'), $hashAlgo, $hashValue);
}
// TODO: 更多逻辑,比如验签失败,删除掉已存的文件等
throw new \UnexpectedValueException('Bad digest verification');
// 6. 等待1-5链接的步骤执行完毕
->wait();
<?php
// filename: bill.all.php
require_once('./vendor/autoload.php');
//帐单日期 YYYY-mm-dd 格式
$billDate = '2021-11-27';
//帐单保存文件地址
$csvFilePath = './bills/all.2021-11-27.csv.gz';
$merchantPrivateKeyFilePath = 'file:///path/to/merchant/apiclient_key.pem';
$platformCertificateFilePath = 'file:///path/to/wechatpay/cert.pem';
$privateKey = \WeChatPay\Crypto\Rsa::from($merchantPrivateKeyFilePath, \WeChatPay\Crypto\Rsa::KEY_TYPE_PRIVATE);
$publicKey = \WeChatPay\Crypto\Rsa::from($platformCertificateFilePath, \WeChatPay\Crypto\Rsa::KEY_TYPE_PUBLIC);
$platformCertificateSerial = \WeChatPay\Util\PemUtil::parseCertificateSerialNo($platformCertificateFilePath);
$instance = \WeChatPay\Builder::factory([
'mchid' => '190000****',
'serial' => '3775B6A45ACD588826D15E583A95F5DD********',
'privateKey' => $privateKey,
'certs' => [$platformCertificateSerial => $publicKey],
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
传了tar_type就是压缩包,没传就是数据流
'handler' => $handler,
'query' => $download['query'],
'base_uri' => $download['base_uri'],
]);
return $download + ['stream' => $stream];
})
// 5. 从第一步获取的帐单哈希签名及上一步的文件流,验证存储的文件签名是否相符
->then(static function(array $verify): ?string {
$hashAlgo = strtolower($verify['hash_type'] ?? 'sha1');
$hashValue = $verify['hash_value'] ?? null;
$stream = $verify['stream'];
$signature = \GuzzleHttp\Psr7\Utils::hash(new \GuzzleHttp\Psr7\InflateStream($stream), $hashAlgo);
if (\WeChatPay\Crypto\Hash::equals($signature, $hashValue)) {
$stream->close();
return sprintf('Verified (%s) with %s digest(%s) OK', $stream->getMetadata('uri'), $hashAlgo, $hashValue);
}
// TODO: 更多逻辑,比如验签失败,删除掉已存的文件等
$stream->close();
throw new \UnexpectedValueException('Bad digest verification');
})
// 6. 等待1-5链接的步骤执行完毕
->wait();
<?php
// filename: bill.all.php
require_once('./vendor/autoload.php');
//帐单日期 YYYY-mm-dd 格式
$billDate = '2021-11-27';
//帐单保存文件地址
$csvFilePath = './bills/all.2021-11-27.csv.gz';
$merchantPrivateKeyFilePath = 'file:///path/to/merchant/apiclient_key.pem';
$platformCertificateFilePath = 'file:///path/to/wechatpay/cert.pem';
$privateKey = \WeChatPay\Crypto\Rsa::from($merchantPrivateKeyFilePath, \WeChatPay\Crypto\Rsa::KEY_TYPE_PRIVATE);
$publicKey = \WeChatPay\Crypto\Rsa::from($platformCertificateFilePath, \WeChatPay\Crypto\Rsa::KEY_TYPE_PUBLIC);
$platformCertificateSerial = \WeChatPay\Util\PemUtil::parseCertificateSerialNo($platformCertificateFilePath);
$instance = \WeChatPay\Builder::factory([
'mchid' => '190000****',
'serial' => '3775B6A45ACD588826D15E583A95F5DD********',
'privateKey' => $privateKey,
'certs' => [$platformCertificateSerial => $publicKey],
]);