微信企业付款到零钱突然升级商家转账到零钱,有没有已经对接了的~
五月中旬的时候还看到微信企业付款到零钱,连续支付了一个月,突然发现微信企业付款不见了,于是打了客服电话,客服说五月中下旬升级为商家转账到零钱。网上文档很少,官方文档
一直都是用easywechat
有没有支持商家转账到零钱的包~
推荐一下
用了wechatpay-php出现报错
// 商户号
$merchantId = env('WXAPP_MCH_ID');
// 从本地文件中加载「商户API私钥」,「商户API私钥」会用来生成请求的签名
$merchantPrivateKeyFilePath = file_get_contents(base_path(env('WXAPP_KEY_PATH')));
$merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
// 「商户API证书」的「证书序列号」
$merchantCertificateSerial = '4D15C9C132BDA318198D27E7797753AE5B07AF09';
// 从本地文件中加载「微信支付平台证书」,用来验证微信支付应答的签名
$platformCertificateFilePath = file_get_contents(base_path(env('WXAPP_CERT_PATH')));
$platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
// 从「微信支付平台证书」中获取「证书序列号」
$platformCertificateSerial = PemUtil::parseCertificateSerialNo($platformCertificateFilePath);
// 构造一个 APIv3 客户端实例
$instance = Builder::factory([
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => [
$platformCertificateSerial => $platformPublicKeyInstance,
],
]);
// 发送请求
$resp = $instance->chain('v3/certificates')->get(
['debug' => true] // 调试模式,https://docs.guzzlephp.org/en/stable/request-options.html#debug
);
echo $resp->getBody(), PHP_EOL;
The `certs()` contains the merchant's certificate serial number() which is not allowed here.
感谢 微信v3支付-WeChatPay\Exception\InvalidArgumentExcept ?
$obj = new AesUtil('v3 key');
$str = openssl_x509_parse(file_get_contents(base_path(env('WXAPP_CERT_PATH'))));
$merchant_id = env('WXAPP_MCH_ID');//商户号
$serial_no = $str['serialNumberHex'];//API证书序列号
$sign = $this->get_Sign("https://api.mch.weixin.qq.com/v3/certificates", "GET", "", $this->get_Privatekey(), $merchant_id, $serial_no);//$http_method要大写
$header[] = 'User-Agent:https://zh.wikipedia.org/wiki/User_agent';
$header[] = 'Accept:application/json';
$header[] = 'Authorization:WECHATPAY2-SHA256-RSA2048 ' . $sign;
$back = $this->http_Request("https://api.mch.weixin.qq.com/v3/certificates", $header);
$result = json_decode($back, true);
$aa = $obj->decryptToString($result['data'][0]['encrypt_certificate']['associated_data'], $result['data'][0]['encrypt_certificate']['nonce'], $result['data'][0]['encrypt_certificate']['ciphertext']);
// dd($result);//解密后的内容,就是证书内容
dump($aa); //证书
以上证书替换
<?php
namespace App\Utils;
class AesUtil
{
/**
* AES key * * @var string
*/
private $aesKey;
const KEY_LENGTH_BYTE = 32;
const AUTH_TAG_LENGTH_BYTE = 16;
/**
* Constructor */ public function __construct($aesKey)
{
if (strlen($aesKey) != self::KEY_LENGTH_BYTE) {
throw new InvalidArgumentException('无效的ApiV3Key,长度应为32个字节');
}
$this->aesKey = $aesKey;
}
/**
* Decrypt AEAD_AES_256_GCM ciphertext * * @param string $associatedData AES GCM additional authentication data
* @param string $nonceStr AES GCM nonce
* @param string $ciphertext AES GCM cipher text
* * @return string|bool Decrypted string on success or FALSE on failure
*/ public function decryptToString($associatedData, $nonceStr, $ciphertext)
{
$ciphertext = \base64_decode($ciphertext);
if (strlen($ciphertext) <= self::AUTH_TAG_LENGTH_BYTE) {
return false;
}
// ext-sodium (default installed on >= PHP 7.2)
if (function_exists('\sodium_crypto_aead_aes256gcm_is_available') &&
\sodium_crypto_aead_aes256gcm_is_available()) {
return \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $this->aesKey);
}
// ext-libsodium (need install libsodium-php 1.x via pecl)
if (function_exists('\Sodium\crypto_aead_aes256gcm_is_available') &&
\Sodium\crypto_aead_aes256gcm_is_available()) {
return \Sodium\crypto_aead_aes256gcm_decrypt($ciphertext, $associatedData, $nonceStr, $this->aesKey);
}
// openssl (PHP >= 7.1 support AEAD)
if (PHP_VERSION_ID >= 70100 && in_array('aes-256-gcm', \openssl_get_cipher_methods())) {
$ctext = substr($ciphertext, 0, -self::AUTH_TAG_LENGTH_BYTE);
$authTag = substr($ciphertext, -self::AUTH_TAG_LENGTH_BYTE);
return \openssl_decrypt($ctext, 'aes-256-gcm', $this->aesKey, \OPENSSL_RAW_DATA, $nonceStr,
$authTag, $associatedData);
}
throw new \RuntimeException('AEAD_AES_256_GCM需要PHP 7.1以上或者安装libsodium-php');
}
}
某种情况下巨坑
$resp = $instance->chain("v3/transfer/batches/out-batch-no/{$out_batch_no}/details/out-detail-no/{$out_detail_no}")->get();
return $resp->getBody()
返回结果
GuzzleHttp\Psr7\Stream^ {#1209
-stream: stream resource {@685
wrapper_type: "PHP"
stream_type: "TEMP"
mode: "w+b"
unread_bytes: 0
seekable: true
uri: "php://temp"
options: []
}
-size: null
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}
解决
return $resp->getBody()->__toString();
推荐文章: