Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 未配置微信证书时,自动获取证书后仍然使用之前的微信配置 #1026

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

Wsmallnews
Copy link
Contributor

当调用 商家转账到零钱 接口,配置中未设置 微信平台公钥证书路径 时,报错 参数异常: 微信公钥序列号为找到

经排查代码在 get_wechat_serial_no 方法中会做判断如果配置中未设置 微信平台公钥证书路径 时,会自动生成 微信平台公钥证书,并更新配置参数

但在接下来调用 get_wechat_public_key,方法获取证书时,使用的是之前获取的 config 信息,而这里面还没有包含新生成的 微信平台公钥证书,导致证书找不到报错 参数异常: 微信公钥序列号为找到

修复方式如下, 提现举例:

    protected function encryptSensitiveData(array $params, array $config, Collection $payload): array
    {
        $data['transfer_detail_list'] = $payload->get('transfer_detail_list', []);
        $data['_serial_no'] = get_wechat_serial_no($params);

        $config = get_provider_config('wechat', $params);      // 获取证书前,重新读取配置
        $publicKey = get_wechat_public_key($config, $data['_serial_no']);

        foreach ($data['transfer_detail_list'] as $key => $list) {
            if (!empty($list['user_name'])) {
                $data['transfer_detail_list'][$key]['user_name'] = encrypt_wechat_contents($list['user_name'], $publicKey);
            }
        }

        return $data;
    }

Copy link

netlify bot commented Sep 9, 2024

Deploy Preview for pay-yansongda canceled.

Name Link
🔨 Latest commit 68a41f3
🔍 Latest deploy log https://app.netlify.com/sites/pay-yansongda/deploys/66e10d24b011f3000829ed9d

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.41%. Comparing base (2ea20b7) to head (68a41f3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1026   +/-   ##
=========================================
  Coverage     97.41%   97.41%           
  Complexity     1032     1032           
=========================================
  Files           374      374           
  Lines          6763     6768    +5     
=========================================
+ Hits           6588     6593    +5     
  Misses          175      175           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yansongda yansongda changed the title 修复自动获取微信平台公钥证书相关接口提示 参数异常: 微信公钥序列号为找到 错误 fix: 未配置微信证书时,自动获取证书后仍然使用之前的微信配置 Sep 11, 2024
@yansongda yansongda merged commit 0aea5b2 into yansongda:master Sep 11, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants