Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add service provider mode support for WeChat Pay codepay interface #3686

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

Draft
Copilot wants to merge 2 commits into develop
base: develop
Choose a base branch
Loading
from copilot/fix-3676

Conversation

Copy link
Contributor

@Copilot Copilot AI commented Aug 31, 2025
edited
Loading

The current WxPayCodepayRequest class only supports direct merchant mode but lacks support for service provider mode, which requires the sub_mch_id parameter. When using the codepay interface in service provider mode, users encounter the error:

受理机构必须传入sub_mch_id

This PR adds service provider mode support by:

  1. Adding service provider fields to WxPayCodepayRequest:

    • sp_appid - Service provider application ID
    • sp_mchid - Service provider merchant ID
    • sub_appid - Sub-merchant application ID
    • sub_mchid - Sub-merchant ID (the key field that was missing)
  2. Updating the service implementation to handle both modes:

    • Auto-detects service provider mode when any of sp_appid, sp_mchid, or sub_mchid is set
    • Uses partner API endpoint /v3/pay/partner/transactions/codepay for service provider mode
    • Uses direct API endpoint /v3/pay/transactions/codepay for direct merchant mode
    • Automatically fills missing fields from WxPayConfig

The implementation maintains backward compatibility - existing direct merchant mode usage continues to work unchanged. The new service provider mode can be used like this:

WxPayCodepayRequest request = new WxPayCodepayRequest();
request.setSpMchid("17085xxxxx");
request.setSubMchid("1230000109"); // This was the missing field causing the error
request.setDescription("订单支付");
request.setOutTradeNo("1234567890");
// ... other fields
WxPayCodepayResult result = wxPayService.codepay(request);

Fixes #3676.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
@Copilot Copilot AI changed the title (削除) [WIP] 微信支付在服务商模式下使用codepay接口时,会报缺少sub_mch_id参数错误 (削除ここまで) (追記) Add service provider mode support for WeChat Pay codepay interface (追記ここまで) Aug 31, 2025
@Copilot Copilot AI requested a review from binarywang August 31, 2025 14:59
Copilot finished work on behalf of binarywang August 31, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@binarywang binarywang Awaiting requested review from binarywang

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

微信支付在服务商模式下使用codepay接口时,会报缺少sub_mch_id参数错误

AltStyle によって変換されたページ (->オリジナル) /