fixed #92,#93
This commit is contained in:
@@ -121,7 +121,7 @@ public class MchApi extends BaseApi {
|
||||
merchant.setAppId(weixinAccount.getId());
|
||||
merchant.setMchId(weixinAccount.getMchId());
|
||||
merchant.setDeviceInfo(weixinAccount.getDeviceInfo());
|
||||
merchant.setSubId(weixinAccount.getSubId());
|
||||
merchant.setSubAppId(weixinAccount.getSubId());
|
||||
merchant.setSubMchId(weixinAccount.getSubMchId());
|
||||
merchant.setNonceStr(RandomUtil.generateString(16));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
@@ -107,7 +108,10 @@ public class PayApi extends MchApi {
|
||||
String tradeType = payPackage.getTradeType().toUpperCase();
|
||||
if (TradeType.MICROPAY.name().equals(tradeType)) {
|
||||
super.declareMerchant(payPackage);
|
||||
payPackage.setSign(weixinSignature.sign(payPackage));
|
||||
JSONObject _payPackage = (JSONObject) JSON.toJSON(payPackage);
|
||||
// 不需要设置TradeType参数
|
||||
_payPackage.remove("tradeType");
|
||||
payPackage.setSign(weixinSignature.sign(_payPackage));
|
||||
String para = XmlStream.toXML(payPackage);
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
getRequestUri("micropay_uri"), para);
|
||||
|
||||
@@ -145,9 +145,6 @@ public class MchPayPackage extends PayPackage {
|
||||
String goodsTag, String limitPay, String subOpenId) {
|
||||
super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
||||
timeStart, timeExpire, goodsTag);
|
||||
if (tradeType.isPayRequestParameter()) {
|
||||
this.tradeType = tradeType.name();
|
||||
}
|
||||
this.openId = openId;
|
||||
this.authCode = authCode;
|
||||
this.productId = productId;
|
||||
|
||||
@@ -39,9 +39,9 @@ public class MerchantResult extends XmlResult {
|
||||
/**
|
||||
* 微信分配的子商户公众账号ID 非必须
|
||||
*/
|
||||
@XmlElement(name = "sub_id")
|
||||
@JSONField(name = "sub_id")
|
||||
private String subId;
|
||||
@XmlElement(name = "sub_appid")
|
||||
@JSONField(name = "sub_appid")
|
||||
private String subAppId;
|
||||
/**
|
||||
* 微信支付分配的子商户号 非必须
|
||||
*/
|
||||
@@ -99,12 +99,12 @@ public class MerchantResult extends XmlResult {
|
||||
this.mchId = mchId;
|
||||
}
|
||||
|
||||
public String getSubId() {
|
||||
return subId;
|
||||
public String getSubAppId() {
|
||||
return subAppId;
|
||||
}
|
||||
|
||||
public void setSubId(String subId) {
|
||||
this.subId = subId;
|
||||
public void setSubAppId(String subAppId) {
|
||||
this.subAppId = subAppId;
|
||||
}
|
||||
|
||||
public String getSubMchId() {
|
||||
@@ -168,7 +168,7 @@ public class MerchantResult extends XmlResult {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "appId=" + appId + ", mchId=" + mchId + ", subId=" + subId
|
||||
return "appId=" + appId + ", mchId=" + mchId + ", subAppId=" + subAppId
|
||||
+ ", subMchId=" + subMchId + ", nonceStr=" + nonceStr
|
||||
+ ", sign=" + sign + ", deviceInfo=" + deviceInfo + ", recall="
|
||||
+ getFormatRecall() + ", " + super.toString();
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.foxinmy.weixin4j.type;
|
||||
|
||||
/**
|
||||
* 微信支付类型
|
||||
*
|
||||
*
|
||||
* @className TradeType
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年10月21日
|
||||
@@ -10,39 +10,24 @@ package com.foxinmy.weixin4j.type;
|
||||
* @see
|
||||
*/
|
||||
public enum TradeType {
|
||||
/**
|
||||
* JS支付
|
||||
*/
|
||||
JSAPI(true),
|
||||
/**
|
||||
* 刷卡支付:不需要设置TradeType参数
|
||||
*/
|
||||
MICROPAY(false),
|
||||
/**
|
||||
* 扫码支付
|
||||
*/
|
||||
NATIVE(true),
|
||||
/**
|
||||
* APP支付
|
||||
*/
|
||||
APP(true),
|
||||
/**
|
||||
* WAP支付
|
||||
*/
|
||||
WAP(true);
|
||||
|
||||
boolean isPayRequestParameter;
|
||||
|
||||
private TradeType(boolean isPayRequestParameter) {
|
||||
this.isPayRequestParameter = isPayRequestParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否作为支付请求参数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isPayRequestParameter() {
|
||||
return isPayRequestParameter;
|
||||
}
|
||||
/**
|
||||
* JS支付
|
||||
*/
|
||||
JSAPI,
|
||||
/**
|
||||
* 刷卡支付
|
||||
*/
|
||||
MICROPAY,
|
||||
/**
|
||||
* 扫码支付
|
||||
*/
|
||||
NATIVE,
|
||||
/**
|
||||
* APP支付
|
||||
*/
|
||||
APP,
|
||||
/**
|
||||
* WAP支付
|
||||
*/
|
||||
WAP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user