修复商家转账电子回单接口至微信支付新版 fund-app 路径并兼容新字段#3994
Conversation
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/8e47db93-4c11-4263-a22d-8823b3f7d2b8 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/8e47db93-4c11-4263-a22d-8823b3f7d2b8 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06dc88f1db
ℹ️ 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".
| @Override | ||
| public ElectronicBillResult applyElectronicBill(ElectronicBillApplyRequest request) throws WxPayException { | ||
| String url = String.format("%s/v3/transfer/bill-receipt", this.wxPayService.getPayBaseUrl()); | ||
| String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no", this.wxPayService.getPayBaseUrl()); |
There was a problem hiding this comment.
Preserve batch-transfer receipt endpoint
When this service is used for the existing batch-transfer APIs, applyElectronicBill still receives an outBatchNo from ElectronicBillApplyRequest, but this line now sends it to the new single-transfer out_bill_no endpoint. The current WeChat docs keep batch receipt applications on /v3/transfer/bill-receipt with out_batch_no (https://pay.wechatpay.cn/doc/v3/merchant/4012458946), while the new endpoint is for ordinary-merchant user-confirm transfer bills and requires a transfer bill number (https://pay.wechatpay.cn/doc/v3/merchant/4012716452). Existing callers applying/querying receipts for batch transfers will therefore get parameter/not-found errors instead of their batch receipt.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
该 PR 对齐微信支付新版「商家转账-电子回单」接口规范:将直连商户/服务商的电子回单申请与查询接口从旧版 v3/transfer/bill-receipt 切换到新版 v3/fund-app/mch-transfer/elecsign/out-bill-no/*,并通过 Gson @SerializedName(alternate=...) 兼容新旧字段命名(out_bill_no/out_batch_no、state/signature_status),同时补充了兼容性测试来验证路径与字段映射。
Changes:
- 将电子回单申请/查询接口请求路径切换到新版 fund-app 路径(直连商户与服务商实现)。
- 请求/响应对象增加新旧字段名兼容反序列化/序列化映射。
- 新增测试验证:请求 URL 是否为新版路径、请求体是否使用
out_bill_no、结果对象是否可反序列化state/out_bill_no。
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/TransferReceiptApiCompatibilityTest.java | 新增兼容性测试,断言新版路径与新字段反序列化行为 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerTransferService.java | 更新服务商电子回单接口文档链接/URL 注释与参数语义 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java | 更新直连商户电子回单接口文档链接/URL 注释与参数语义 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImpl.java | 服务商侧电子回单申请/查询改用新版 fund-app 路径 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java | 直连商户侧电子回单申请/查询改用新版 fund-app 路径 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillResult.java | 响应对象兼容 out_bill_no/out_batch_no 与 state/signature_status |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillApplyRequest.java | 请求对象兼容 out_bill_no/out_batch_no |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ReceiptBillRequest.java | 请求对象兼容 out_bill_no/out_batch_no |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BillReceiptResult.java | 响应对象兼容 out_bill_no/out_batch_no 与 state/signature_status |
| @Override | ||
| public BillReceiptResult receiptBill(ReceiptBillRequest request) throws WxPayException { | ||
| String url = String.format("%s/v3/transfer/bill-receipt", this.payService.getPayBaseUrl()); | ||
| String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no", this.payService.getPayBaseUrl()); |
| * 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/elecsign/out-bill-no | ||
| * 请求方式:POST | ||
| * | ||
| * @param request 商家批次单号 |
| public ElectronicBillResult queryElectronicBill(String outBillNo) throws WxPayException { | ||
| String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no/%s", this.wxPayService.getPayBaseUrl(), outBillNo); | ||
| String response = wxPayService.getV3(url); |
| public BillReceiptResult queryBillReceipt(String outBatchNo) throws WxPayException { | ||
| String url = String.format("%s/v3/transfer/bill-receipt/%s", this.payService.getPayBaseUrl(), outBatchNo); | ||
| public BillReceiptResult queryBillReceipt(String outBillNo) throws WxPayException { | ||
| String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no/%s", this.payService.getPayBaseUrl(), outBillNo); |
| @SerializedName(value = "out_bill_no", alternate = {"out_batch_no"}) | ||
| private String outBatchNo; |
| @SerializedName(value = "state", alternate = {"signature_status"}) | ||
| private String signatureStatus; |
| @SerializedName(value = "out_bill_no", alternate = {"out_batch_no"}) | ||
| private String outBatchNo; |
| @SerializedName(value = "state", alternate = {"signature_status"}) | ||
| private String signatureStatus; |
| * 示例值:plfk2020042013 | ||
| * </pre> | ||
| */ | ||
| @SerializedName("out_batch_no") | ||
| @SerializedName(value = "out_bill_no", alternate = {"out_batch_no"}) | ||
| private String outBatchNo; |
| * </pre> | ||
| */ | ||
| @SerializedName(value = "out_batch_no") | ||
| @SerializedName(value = "out_bill_no", alternate = {"out_batch_no"}) | ||
| private String outBatchNo; |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/a12a98fa-8363-4088-8250-377242395520 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
已按该评审线程逐条完成修改并推送,涵盖文档链接/参数说明一致性、字段注释同步以及超长行修复。对应提交:fc60838。 |
当前“商家转账-申请/获取电子回单”仍走旧版
v3/transfer/bill-receipt,与微信支付新版文档不一致。该改动将相关实现切换到新版v3/fund-app/mch-transfer/elecsign/*,并同步处理新旧字段命名兼容。问题背景(简述)
接口路径切换(核心变更)
MerchantTransferServiceImplapplyElectronicBill→POST /v3/fund-app/mch-transfer/elecsign/out-bill-noqueryElectronicBill→GET /v3/fund-app/mch-transfer/elecsign/out-bill-no/{out_bill_no}PartnerTransferServiceImplreceiptBill→POST /v3/fund-app/mch-transfer/elecsign/out-bill-noqueryBillReceipt→GET /v3/fund-app/mch-transfer/elecsign/out-bill-no/{out_bill_no}请求/响应字段兼容
out_bill_no(兼容旧out_batch_no)state(兼容旧signature_status)ElectronicBillApplyRequestReceiptBillRequestElectronicBillResultBillReceiptResult接口契约与注释同步
MerchantTransferService、PartnerTransferService更新为新版文档与 URL 注释。outBillNo,减少语义歧义。示例(路径与字段)
https://pay.weixin.qq.com/doc/v3/merchant/4012716452https://pay.weixin.qq.com/doc/v3/merchant/4012716436https://pay.weixin.qq.com/doc/v3/merchant/4012716455Warning
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:
wx.gtimg.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either: