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

微信查询企业付款接口实现错误 #67

Closed
99246255 opened this issue Dec 28, 2020 · 6 comments
Closed

微信查询企业付款接口实现错误 #67

99246255 opened this issue Dec 28, 2020 · 6 comments
Assignees
Labels

Comments

@99246255
Copy link

99246255 commented Dec 28, 2020

WxPayService.transferQuery 实现错误

public Map<String, Object> transferQuery(String outNo, String wxTransferType) {
        Map<String, Object> parameters = new TreeMap();
        parameters.put("mch_id", ((WxPayConfigStorage)this.payConfigStorage).getPid());
        parameters.put("partner_trade_no", outNo);
        parameters.put("nonce_str", SignUtils.randomStr());
        parameters.put("sign", this.createSign(SignUtils.parameterText(parameters, "&", new String[]{"sign"}), ((WxPayConfigStorage)this.payConfigStorage).getInputCharset()));
        if (StringUtils.isEmpty(wxTransferType)) {
            throw new PayErrorException(new WxPayError("failure", "微信转账类型 #transferQuery(String outNo, String wxTransferType) 必填,详情com.egzosn.pay.wx.bean.WxTransferType"));
        } else {
            return !WxTransferType.TRANSFERS.getType().equals(wxTransferType) && !WxTransferType.GETTRANSFERINFO.getType().equals(wxTransferType) ? (Map)this.getHttpRequestTemplate().postForObject(this.getReqUrl(WxTransferType.QUERY_BANK), XML.getMap2Xml(parameters), JSONObject.class, new Object[0]) : (Map)this.getHttpRequestTemplate().postForObject(this.getReqUrl(WxTransferType.GETTRANSFERINFO), XML.getMap2Xml(parameters), JSONObject.class, new Object[0]);
        }
    }

微信查询企业付款接口,https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3
service.transferQuery("XXX", WxTransferType.GETTRANSFERINFO.name());

<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[参数错误:必须输入appid]]></return_msg>
<result_code><![CDATA[FAIL]]></result_code>
<err_code><![CDATA[PARAM_ERROR]]></err_code>
<err_code_des><![CDATA[参数错误:必须输入appid]]></err_code_des>
</xml>
@egzosn
Copy link
Owner

egzosn commented Feb 25, 2021

文档没有说明nonce_str 是转账支付完成之后返回参数吧,你在进行查询的时候返回什么异常信息,能否提供一下,或者能否说下你是怎么进行矫正的

@egzosn egzosn self-assigned this Feb 25, 2021
@99246255
Copy link
Author

文档没有说明nonce_str 是转账支付完成之后返回参数吧,你在进行查询的时候返回什么异常信息,能否提供一下,或者能否说下你是怎么进行矫正的
service.transferQuery("XXXX", WxTransferType.GETTRANSFERINFO.name());
后来看了下好像确实这个参数可以是随机的,但是缺少appId

@egzosn
Copy link
Owner

egzosn commented Mar 2, 2021

你在配置的时候没有设置appid嘛,
图片

@99246255
Copy link
Author

99246255 commented Mar 2, 2021

你在配置的时候没有设置appid嘛,
图片

单元测试如下


public static void main(String[] args) {
			WxPayConfigStorage wxPayConfigStorage = new WxPayConfigStorage();
			wxPayConfigStorage.setMchId("XXX");
			wxPayConfigStorage.setAppid("XXX");
			wxPayConfigStorage.setKeyPrivate("XXX");
			wxPayConfigStorage.setKeyPublic("XXX");
			wxPayConfigStorage.setPayType("wxPay");
			wxPayConfigStorage.setSignType("MD5");
			wxPayConfigStorage.setInputCharset("utf-8");

			HttpConfigStorage httpConfigStorage = new HttpConfigStorage();
			httpConfigStorage.setStorePassword("XX");
			String certPath = "XXX";
			httpConfigStorage.setKeystore(certPath);
			//设置ssl证书对应的存储方式输入流,这里默认为文件地址
			httpConfigStorage.setCertStoreType(CertStoreType.PATH);

                        // 有问题的
			WxPayService service = new WxPayService(wxPayConfigStorage, httpConfigStorage);
			Map<String, Object> map = service.transferQuery("XXX", WxTransferType.GETTRANSFERINFO.name());

                        //  没有问题的方式
                        Map<String, Object> parameters = new TreeMap();
			WxPayConfigStorage payConfigStorage = service.getPayConfigStorage();
			parameters.put("appid", payConfigStorage.getAppid());
			parameters.put("mch_id", payConfigStorage.getPid());
			parameters.put("partner_trade_no", "XXX");
			parameters.put("nonce_str", SignUtils.randomStr());
			parameters.put("sign", service.createSign(SignUtils.parameterText(parameters, "&", new String[]{"sign"}), payConfigStorage.getInputCharset()));
			map = (Map) service.getHttpRequestTemplate().postForObject(service.getReqUrl(WxTransferType.GETTRANSFERINFO), XML.getMap2Xml(parameters), JSONObject.class, new Object[0]);
	}

@egzosn egzosn added the bug label Mar 13, 2021
@egzosn
Copy link
Owner

egzosn commented Mar 13, 2021

对不住,只实现了转账到卡的实现

@egzosn
Copy link
Owner

egzosn commented Oct 6, 2021

之前已经修复,关闭

@egzosn egzosn closed this as completed Oct 6, 2021
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

2 participants