Skip to content
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

weixin-pay模块能否支持服务商模式呢? #65

Open
showcup opened this issue Jan 17, 2018 · 1 comment
Open

weixin-pay模块能否支持服务商模式呢? #65

showcup opened this issue Jan 17, 2018 · 1 comment
Labels

Comments

@showcup
Copy link

showcup commented Jan 17, 2018

weixin-pay模块能否支持服务商模式呢?目前看统一下单接口的输入没有sub_mch_id字段。

@rplees
Copy link

rplees commented May 10, 2018

其实可以fork下项目自己扩展下, 我看了下源码结构很清晰的, 我的思路是在BaseSettings.java 里新增俩字段

 @JsonProperty("sub_appid")
    private String subAppId; //微信分配的子商户公众账号ID
    
    @JsonProperty("sub_mch_id")
    private String subMchId; //微信支付分配的子商户号

然后在Payments 新增方法

 /**
     * 设置子商户信息 
     * @param subAppId
     * @param subMchId
     * @return
     */
    public Payments subMInfo(String subAppId, String subMchId) {
    		this.subAppId = subAppId;
    		this.subMchId = subMchId;
    		return this;
    }

//在setBaseSettings方法追加

private void setBaseSettings(BaseSettings wrapper) {
        wrapper.setAppId(paySetting.getAppId());
        wrapper.setMchId(paySetting.getMchId());
        
        if(subAppId != null && subAppId.length() > 0) {
        		wrapper.setSubAppId(subAppId);
        }
        if(subMchId != null && subMchId.length() > 0) {
        		wrapper.setSubMchId(subMchId);
        }
    }

最后调用的时候 Payments.defaultPayments().subMInfo("", "").unifiedOrder(unifiedOrderRequest)
(由于子商户号一般是不同商户会变的,所以没写在paySetting)

我也是刚这样弄的,并没有测试过,我debug的时候Wrapper=>SortedMap后观察请求参数是包含了sub_appid,sub_mch_id字段

仅供参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants