微信企业付款到零钱突然升级商家转账到零钱,有没有已经对接了的~

五月中旬的时候还看到微信企业付款到零钱,连续支付了一个月,突然发现微信企业付款不见了,于是打了客服电话,客服说五月中下旬升级为商家转账到零钱。网上文档很少,官方文档

一直都是用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();
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

不是官方包报错,是官方给的文档像sb一样,不停的让我猜,前天搞了一整天才搞定 我用的也是官方推荐的 wechatpay

1年前 评论
讨论数量: 16

yansongda/pay 了解一下?

1年前 评论
sharejia 1年前
my38778570 (楼主) 1年前
ieras 1年前

没有的话只能自己封装, 然后注册到 easywechat 中了

// 参考这个自己实现
// 服务提供者 EasyWeChat\Payment\Transfer\ServiceProvider
// 支付客户端: EasyWeChat\Payment\Transfer\Client

$app = Factory::payment($config); // 或其他工厂类
$app->registerProviders([Self\Payment\Transfer\ServiceProvider::class]); // 这里注册自己实现的服务提供者

或者提交代码,更新就可以用了

PS: 官方有推荐 sdk pay.weixin.qq.com/wiki/doc/apiv3/w...

1年前 评论
my38778570 (楼主) 1年前
云客网络工作室

官方包出错,你排查一下错误,根据报错看下是不是自己配置哪里有问题,我没用过这个包,不过官方都发出来了肯定是经过测试的

1年前 评论
my38778570 (楼主) 1年前

你这个报错跟扩展包没有关系,只是因为转账接口必须使用V3版本的接口,调用V3版本接口必须传证书序列号,你没传这个参数而已。

1年前 评论
my38778570 (楼主) 1年前

不是官方包报错,是官方给的文档像sb一样,不停的让我猜,前天搞了一整天才搞定 我用的也是官方推荐的 wechatpay

1年前 评论

搞得我一度怀疑人生,接个代付接一天,丢死人 :joy:

1年前 评论

加我qq 1552519081 我来帮你 能帮一个是一个

1年前 评论
PHP-Coder 1年前
my38778570 (楼主) 1年前

yansongda/pay 了解一下?

1年前 评论
sharejia 1年前
my38778570 (楼主) 1年前
ieras 1年前

感谢楼主提供的解决方案。除了楼主的办法获得cert外,也可以使用官方提供的平台证书的命令行下载工具,参考链接:

pay.weixin.qq.com/wiki/doc/apiv3/w...

github.com/wechatpay-apiv3/wechatp...

file

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!