Fix WeChat Pay V3 public key transfer signature verification failure#3731
Merged
binarywang merged 2 commits intodevelopfrom Nov 15, 2025
Merged
Conversation
When using public key mode for transfer APIs, WeChat Pay may return a response with a platform certificate serial number in the Wechatpay-Serial header, but the signature is actually signed with the public key. The previous logic would fail to verify this. Changes: - Modified PublicCertificateVerifier.verify() to fallback to public key verification when certificate verification fails - This ensures both platform certificate and public key signatures can be verified - Fixes the issue where funds are locked but verification fails for transfer APIs Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] 4.7.6.B 微信v3支付公钥转账出现应答的微信支付签名验证失败,实际已经锁定了资金
Fix WeChat Pay V3 public key transfer signature verification failure
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
When using WeChat Pay V3 public key mode for transfer APIs (商户转账 - merchant transfer to user's balance), signature verification would fail with error "应答的微信支付签名验证失败" (WeChat Pay response signature verification failed) even though the transfer operation was successful and funds were locked in the merchant account.
This issue specifically affects the new transfer API endpoint
/v3/fund-app/mch-transfer/transfer-billswhen using public key authentication mode.Root Cause
The
PublicCertificateVerifier.verify()method had a logic flaw when handling WeChat Pay responses:Wechatpay-Serialheader (not containing "PUB_KEY_ID")Solution
Modified
PublicCertificateVerifier.verify()to implement a fallback mechanism:Key improvements:
Impact
✅ Fixes: Public key transfer signature verification failures
✅ Maintains: Full backward compatibility with platform certificate mode
✅ Supports: Both full public key mode and hybrid mode configurations
✅ User Impact: No changes required in user code - fix is transparent
Testing
Related Documentation
This fix supports the new transfer API documented in:
Fixes #[issue number]
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.