Skip to content

feat: 支持微信支付服务商电子发票#4070

Merged
binarywang merged 6 commits into
developfrom
codex/partner-invoice-clean
Jul 18, 2026
Merged

feat: 支持微信支付服务商电子发票#4070
binarywang merged 6 commits into
developfrom
codex/partner-invoice-clean

Conversation

@binarywang

@binarywang binarywang commented Jul 18, 2026

Copy link
Copy Markdown
Owner

内容

实现微信支付 V3 服务商电子发票 API:

  • 服务商邀请、邀请商户查询与子商户能力状态
  • 卡券模板、开发配置、用户抬头链接及查询
  • 通用/不动产租赁/成品油开票、查询、冲红、下载信息、文件上传及插卡

Closes #4066

同时对应 Gitee Issue IDMETW(其文档链接为同一服务商电子发票产品)。

验证

  • mvn -pl weixin-java-pay -am -DskipTests compile
  • TestNG:PartnerInvoiceServiceImplTest 6/6、GeneralInvoiceRequestTest 1/1

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 在 weixin-java-pay 模块新增了微信支付 V3「服务商电子发票」能力的 SDK 封装,补齐服务商侧邀请/能力状态、模板与开发配置、抬头链接与查询、开票/查询/冲红、文件上传与下载、插卡等相关接口,并增加了基础的单元测试与调研对比文档,用于响应 Issue #4066 的需求。

Changes:

  • 新增 PartnerInvoiceService 及其实现 PartnerInvoiceServiceImpl,并将其挂载到 WxPayService/BaseWxPayServiceImpl
  • 新增服务商电子发票相关的请求/响应 Bean(invoice 包)以及文件上传请求构造扩展(WechatPayUploadHttpPost)。
  • 新增接口调用与序列化字段名的单元测试,并补充公众号旧体系与支付 V3 体系的对比说明文档。

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerInvoiceServiceImplTest.java 覆盖服务商电子发票核心接口的 URL/请求体拼装行为测试
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/invoice/GeneralInvoiceRequestTest.java 验证开票请求对象序列化字段名与微信支付字段一致
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/WechatPayUploadHttpPost.java 扩展支持电子发票文件上传的自定义 meta multipart 构造
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java 在顶层服务接口新增服务商电子发票 service 获取入口
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerInvoiceService.java 新增服务商电子发票 API 服务接口定义
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerInvoiceServiceImpl.java 新增服务商电子发票 API 的具体 v3 调用实现
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java 将 PartnerInvoiceServiceImpl 注入/暴露到 WxPayService 实现中
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/TitleUrlResult.java 新增“抬头填写小程序跳转信息”响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/TitleUrlRequest.java 新增“获取用户抬头填写链接”请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/SubMerchantInvoiceStatus.java 新增子商户电子发票能力状态响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/ReverseInvoiceRequest.java 新增冲红电子发票请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InvoiceResult.java 新增查询电子发票响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InvoiceFileUploadResult.java 新增上传电子发票文件响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InvoiceFileUploadRequest.java 新增上传电子发票 PDF 文件请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InvoiceFileResult.java 新增发票文件下载信息响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InviteUrlResult.java 新增服务商邀请链接响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InviteMerchantResult.java 新增邀请商户查询响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InviteMerchantQuery.java 新增邀请商户查询条件对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/InsertCardRequest.java 新增“插卡到用户卡包”请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/IndustryInvoiceRequest.java 新增行业开票请求对象(不动产租赁/成品油)
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/GeneralInvoiceRequest.java 新增通用行业开票请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/DevelopmentConfigResult.java 新增开发配置响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/DevelopmentConfigRequest.java 新增开发配置请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/CardTemplateResult.java 新增卡券模板创建响应对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/CardTemplateRequest.java 新增卡券模板创建请求对象
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/invoice/BuyerInformation.java 新增购买方抬头信息对象
docs/ELECTRONIC_INVOICE_API_COMPARISON.md 补充公众号旧体系与支付 V3 服务商电子发票体系对比说明

@augmentcode

augmentcode Bot commented Jul 18, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: 本 PR 在 weixin-java-pay 模块新增微信支付 V3「服务商电子发票(new-tax-control-fapiao)」能力封装,覆盖邀约、抬头、开票、冲红、文件上传/下载等核心接口。

Changes:

  • 新增 PartnerInvoiceServicePartnerInvoiceServiceImpl,对接多条 /v3/new-tax-control-fapiao/* 端点
  • 新增电子发票相关请求/响应 Bean:邀请、子商户能力状态、卡券模板、开发配置、用户抬头、开票/冲红、文件上传/下载等
  • WxPayService / BaseWxPayServiceImpl 中暴露 getPartnerInvoiceService()
  • 扩展 WechatPayUploadHttpPost:支持电子发票文件上传所需的自定义 meta 签名与 multipart 表单构造
  • 补充 TestNG 单测:验证通用开票请求序列化字段名、以及部分接口 URL/请求体拼装
  • 新增对比文档,澄清公众号旧电子发票接口与支付 V3 服务商电子发票体系的差异

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fd8effade

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@binarywang

Copy link
Copy Markdown
Owner Author

已处理本轮评审意见:

  • 所有 path/query 参数改为 UTF-8 URL 编码;必填参数为空时立即失败,避免发送 null
  • getUserTitleUrl 补齐 seller_name 与手机号/邮箱开关等可选参数。
  • 复用公共 BuyerInformation,移除通用开票请求中的重复定义。
  • JSON 序列化统一使用 WxGsonBuilder.create()
  • 上传文件 MIME 类型按扩展名推断,支持 OFD 等类型。
  • digest_alogrithm 保持不变:这是微信支付该接口官方文档及示例规定的字段拼写,已增加注释以避免误改。

验证:PartnerInvoiceServiceImplTest 7/7 通过,模块 Maven 构建通过。

@binarywang

Copy link
Copy Markdown
Owner Author

补充修复已推送:892c86fe7

  • Apache HttpClient 与 HttpComponents 实现均接受 HTTP 202,支持电子发票异步受理成功。
  • 开发配置请求改为 PATCH。
  • 抬头结果新增 title_url
  • 冲红信息补充 fapiao_code;子商户数电状态补充 ability_info
  • 新增 InviteUrlRequest,支持完整邀请查询参数。

验证:模块构建成功,PartnerInvoiceServiceImplTest 7/7、GeneralInvoiceRequestTest 1/1 通过。

@binarywang
binarywang merged commit 2d496ed into develop Jul 18, 2026
1 check passed
@binarywang
binarywang deleted the codex/partner-invoice-clean branch July 18, 2026 12:54
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