-
-
Notifications
You must be signed in to change notification settings - Fork 9k
添加微信支付实名验证接口 #3814
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
添加微信支付实名验证接口 #3814
Conversation
Co-authored-by: binarywang <[email protected]>
Co-authored-by: binarywang <[email protected]>
Co-authored-by: binarywang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
本 PR 实现了微信支付实名验证相关接口,根据微信官方文档添加查询用户实名认证状态的功能。
主要变更:
- 新增
RealNameService接口和RealNameServiceImpl实现类,提供查询用户实名认证状态的功能 - 新增
RealNameRequest和RealNameResultBean 类,用于封装请求和响应数据 - 在
WxPayService中集成实名验证服务,通过getRealNameService()方法提供访问入口
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/realname/RealNameRequest.java | 新增实名验证请求对象,继承 BaseWxPayRequest,包含必填的 openid 字段 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/realname/RealNameResult.java | 新增实名验证响应对象,继承 BaseWxPayResult,包含认证状态、认证信息和引导链接字段 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/RealNameService.java | 新增实名验证服务接口,定义查询实名认证信息的方法(完整版本和简化版本) |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImpl.java | 实现实名验证服务,调用微信支付 API 并处理响应,使用商户证书进行安全请求 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java | 在主服务接口中添加 getRealNameService() 方法,提供实名验证服务访问入口 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java | 在基础实现类中初始化 RealNameService 实例,确保服务自动可用 |
| weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImplTest.java | 新增测试类,包含完整和简化两种调用方式的测试用例 |
| weixin-java-pay/REAL_NAME_USAGE.md | 新增详细的使用文档,包含接口说明、使用示例、注意事项和错误处理指南 |
|
|
||
| @Getter | ||
| private final RealNameService realNameService = new RealNameServiceImpl(this); | ||
|
|
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 BaseWxPayServiceImpl 中的 realNameService 字段初始化后存在多余的空行。为了保持代码风格一致性,应该删除第 142 行的空行,使其与其他服务字段的格式保持一致。
| * @return the real name service | ||
| */ | ||
| RealNameService getRealNameService(); | ||
|
|
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 WxPayService 接口中的 getRealNameService() 方法后存在多余的空行。为了保持代码风格一致性,应该删除第 1716 行的空行,使其与其他服务方法的格式保持一致。
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
| */ | ||
| @Data | ||
| @EqualsAndHashCode(callSuper = true) |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method overrides BaseWxPayResult.canEqual; it is advisable to add an Override annotation.
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
| */ | ||
| @Data | ||
| @EqualsAndHashCode(callSuper = true) |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method overrides BaseWxPayRequest.canEqual; it is advisable to add an Override annotation.
| @Getter | ||
| private final RealNameService realNameService = new RealNameServiceImpl(this); | ||
|
|
||
| @Getter | ||
| private final MiPayService miPayService = new MiPayServiceImpl(this); | ||
|
|
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method overrides WxPayService.getRealNameService; it is advisable to add an Override annotation.
| @Getter | |
| private final RealNameService realNameService = new RealNameServiceImpl(this); | |
| @Getter | |
| private final MiPayService miPayService = new MiPayServiceImpl(this); | |
| private final RealNameService realNameService = new RealNameServiceImpl(this); | |
| @Getter | |
| private final MiPayService miPayService = new MiPayServiceImpl(this); | |
| @Override | |
| public RealNameService getRealNameService() { | |
| return this.realNameService; | |
| } |
根据官方文档 https://pay.wechatpay.cn/doc/v2/merchant/4011987607 添加实名验证相关接口,用于查询用户实名认证状态。
新增组件
RealNameRequest/RealNameResult- 请求响应对象,包含认证状态、认证信息和引导链接RealNameService- 查询用户实名认证状态RealNameServiceImpl- 调用/userinfo/realnameauth/query接口,需要商户证书REAL_NAME_USAGE.md- 完整使用说明集成方式
在
WxPayService中添加getRealNameService()方法,在BaseWxPayServiceImpl中自动初始化服务实例。使用示例
返回字段说明:
is_certified: 认证状态 (Y/N)cert_info: 实名信息(加密,仅已认证时返回)guide_url: 认证引导链接(仅未认证时返回)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
pay.wechatpay.cn/usr/bin/curl curl -s REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.