#78 我太粗心了,谢谢提醒。:-)
This commit is contained in:
parent
1b12f59344
commit
47a9eaee31
@ -103,8 +103,11 @@ public class PayApi extends MchApi {
|
|||||||
*/
|
*/
|
||||||
public MchPayRequest createPayRequest(MchPayPackage payPackage)
|
public MchPayRequest createPayRequest(MchPayPackage payPackage)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
String tradeType = payPackage.getTradeType();
|
if (StringUtil.isBlank(payPackage.getTradeType())) {
|
||||||
if (TradeType.MICROPAY.name().equalsIgnoreCase(tradeType)) {
|
throw new WeixinException("tradeType not be empty");
|
||||||
|
}
|
||||||
|
String tradeType = payPackage.getTradeType().toUpperCase();
|
||||||
|
if (TradeType.MICROPAY.name().equals(tradeType)) {
|
||||||
super.declareMerchant(payPackage);
|
super.declareMerchant(payPackage);
|
||||||
payPackage.setSign(weixinSignature.sign(payPackage));
|
payPackage.setSign(weixinSignature.sign(payPackage));
|
||||||
String para = XmlStream.toXML(payPackage);
|
String para = XmlStream.toXML(payPackage);
|
||||||
@ -117,14 +120,14 @@ public class PayApi extends MchApi {
|
|||||||
return microPayRequest;
|
return microPayRequest;
|
||||||
}
|
}
|
||||||
PrePay prePay = createPrePay(payPackage);
|
PrePay prePay = createPrePay(payPackage);
|
||||||
if (TradeType.APP.name().equalsIgnoreCase(tradeType)) {
|
if (TradeType.APP.name().equals(tradeType)) {
|
||||||
return new APPPayRequest(prePay.getPrepayId(), weixinAccount);
|
return new APPPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else if (TradeType.JSAPI.name().equalsIgnoreCase(tradeType)) {
|
} else if (TradeType.JSAPI.name().equals(tradeType)) {
|
||||||
return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount);
|
return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else if (TradeType.NATIVE.name().equalsIgnoreCase(tradeType)) {
|
} else if (TradeType.NATIVE.name().equals(tradeType)) {
|
||||||
return new NATIVEPayRequest(prePay.getPrepayId(),
|
return new NATIVEPayRequest(prePay.getPrepayId(),
|
||||||
prePay.getCodeUrl(), weixinAccount);
|
prePay.getCodeUrl(), weixinAccount);
|
||||||
} else if (TradeType.WAP.name().equalsIgnoreCase(tradeType)) {
|
} else if (TradeType.WAP.name().equals(tradeType)) {
|
||||||
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
|
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("unknown tradeType:" + tradeType);
|
throw new WeixinException("unknown tradeType:" + tradeType);
|
||||||
@ -386,9 +389,9 @@ public class PayApi extends MchApi {
|
|||||||
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
||||||
String outTradeNo, double totalFee, String createIp, String attach)
|
String outTradeNo, double totalFee, String createIp, String attach)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
// 刷卡支付不需要设置TradeType.MICROPAY
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||||
totalFee, null, createIp, null, null, authCode, null, attach);
|
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
||||||
|
null, attach);
|
||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,9 @@ public class MchPayPackage extends PayPackage {
|
|||||||
String goodsTag, String limitPay, String subOpenId) {
|
String goodsTag, String limitPay, String subOpenId) {
|
||||||
super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
||||||
timeStart, timeExpire, goodsTag);
|
timeStart, timeExpire, goodsTag);
|
||||||
this.tradeType = tradeType.name();
|
if (tradeType.isPayRequestParameter()) {
|
||||||
|
this.tradeType = tradeType.name();
|
||||||
|
}
|
||||||
this.openId = openId;
|
this.openId = openId;
|
||||||
this.authCode = authCode;
|
this.authCode = authCode;
|
||||||
this.productId = productId;
|
this.productId = productId;
|
||||||
|
|||||||
@ -13,21 +13,36 @@ public enum TradeType {
|
|||||||
/**
|
/**
|
||||||
* JS支付
|
* JS支付
|
||||||
*/
|
*/
|
||||||
JSAPI,
|
JSAPI(true),
|
||||||
/**
|
/**
|
||||||
* 刷卡支付
|
* 刷卡支付:不需要设置TradeType参数
|
||||||
*/
|
*/
|
||||||
MICROPAY,
|
MICROPAY(false),
|
||||||
/**
|
/**
|
||||||
* 扫码支付
|
* 扫码支付
|
||||||
*/
|
*/
|
||||||
NATIVE,
|
NATIVE(true),
|
||||||
/**
|
/**
|
||||||
* APP支付
|
* APP支付
|
||||||
*/
|
*/
|
||||||
APP,
|
APP(true),
|
||||||
/**
|
/**
|
||||||
* WAP支付
|
* WAP支付
|
||||||
*/
|
*/
|
||||||
WAP;
|
WAP(true);
|
||||||
|
|
||||||
|
boolean isPayRequestParameter;
|
||||||
|
|
||||||
|
private TradeType(boolean isPayRequestParameter) {
|
||||||
|
this.isPayRequestParameter = isPayRequestParameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否作为支付请求参数
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isPayRequestParameter() {
|
||||||
|
return isPayRequestParameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user