新增MCIROPayRequest对象

This commit is contained in:
jinyu 2016-03-27 15:36:50 +08:00
parent 1f3ed92165
commit 8c70e0d53c
34 changed files with 477 additions and 670 deletions

View File

@ -657,4 +657,10 @@
+ weixin4j-base:新增查询结算金额接口
+ weixin4j-base:新增查询汇率接口
+ weixin4j-base:新增查询汇率接口
* 2016-03-27
+ weixin4j-base:删除Mciro支付接口,新增MCIROPayRequest对象
+ weixin4j-base:支付对象优化

View File

@ -59,8 +59,10 @@ public class CashApi extends MchApi {
*/
public RedpacketSendResult sendRedpack(InputStream certificate,
Redpacket redpacket) throws WeixinException {
redpacket.setSign(weixinSignature.sign(redpacket));
String param = XmlStream.map2xml((JSONObject) JSON.toJSON(redpacket));
JSONObject obj = (JSONObject) JSON.toJSON(redpacket);
obj.put("wxappid", obj.remove("appid"));
obj.put("sign", weixinSignature.sign(obj));
String param = XmlStream.map2xml(obj);
WeixinResponse response = null;
try {
response = createSSLRequestExecutor(certificate)
@ -75,8 +77,10 @@ public class CashApi extends MchApi {
}
}
}
return response.getAsObject(new TypeReference<RedpacketSendResult>() {
});
String text = response.getAsString()
.replaceFirst("<wxappid>", "<appid>")
.replaceFirst("</wxappid>", "</appid>");
return XmlStream.fromXML(text, RedpacketSendResult.class);
}
/**
@ -133,11 +137,8 @@ public class CashApi extends MchApi {
public CorpPaymentResult sendCorpPayment(InputStream certificate,
CorpPayment payment) throws WeixinException {
JSONObject obj = (JSONObject) JSON.toJSON(payment);
obj.put("nonce_str", RandomUtil.generateString(16));
obj.put("mchid", weixinAccount.getMchId());
obj.put("sub_mch_id", weixinAccount.getSubMchId());
obj.put("mch_appid", weixinAccount.getId());
obj.put("device_info", weixinAccount.getDeviceInfo());
obj.put("mchid", obj.remove("mch_id"));
obj.put("mch_appid", obj.remove("appid"));
obj.put("sign", weixinSignature.sign(obj));
String param = XmlStream.map2xml(obj);
WeixinResponse response = null;

View File

@ -23,12 +23,12 @@ import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.model.Consts;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.MicroPayPackage;
import com.foxinmy.weixin4j.payment.mch.APPPayRequest;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
import com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest;
import com.foxinmy.weixin4j.payment.mch.MICROPayRequest;
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
import com.foxinmy.weixin4j.payment.mch.MchPayRequest;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest;
import com.foxinmy.weixin4j.payment.mch.NativePayResponse;
import com.foxinmy.weixin4j.payment.mch.OpenIdResult;
@ -110,6 +110,7 @@ public class PayApi extends MchApi {
* @return 支付请求对象
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest JS支付
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest 扫码支付
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException
@ -128,7 +129,18 @@ public class PayApi extends MchApi {
} else if (TradeType.WAP.name().equalsIgnoreCase(tradeType)) {
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
} else if (TradeType.MICROPAY.name().equalsIgnoreCase(tradeType)) {
throw new WeixinPayException("maybe invoke createMicroPay method?");
String para = XmlStream.toXML(payPackage);
try {
WeixinResponse response = weixinExecutor.post(
getRequestUri("micropay_uri"), para);
MICROPayRequest microPayRequest = response
.getAsObject(new TypeReference<MICROPayRequest>() {
});
microPayRequest.setPaymentAccount(weixinAccount);
return microPayRequest;
} catch (WeixinException e) {
throw new WeixinPayException(e);
}
} else {
throw new WeixinPayException("unknown tradeType:" + tradeType);
}
@ -137,12 +149,6 @@ public class PayApi extends MchApi {
/**
* 创建支付请求对象完整参数
*
* @param tradeType
* 交易类型 <font color="red">必填项</font>
* @param openId
* 用户ID <font color="red">tradeType=JSAPI时必填</font>
* @param productId
* 产品ID <font color="red">tradeType=NATIVE时必填</font>
* @param body
* 商品描述 <font color="red">必填项</font>
* @param detail
@ -155,6 +161,12 @@ public class PayApi extends MchApi {
* 支付回调URL <font color="red">必填项</font>
* @param createIp
* 订单生成的机器IP <font color="red">必填项</font>
* @param tradeType
* 交易类型 <font color="red">必填项</font>
* @param openId
* 用户ID <font color="red">tradeType=JSAPI时必填</font>
* @param productId
* 产品ID <font color="red">tradeType=NATIVE时必填</font>
* @param attach
* 附加数据在查询API和支付通知中原样返回该字段主要用于商户携带订单的自定义数据 非必填项
* @param timeStart
@ -165,26 +177,31 @@ public class PayApi extends MchApi {
* 商品标记代金券或立减优惠功能的参数 非必填项
* @param limitPay
* 指定支付方式:no_credit--指定不能使用信用卡支付 非必填项
* @param subOpenId
* 用户在子商户appid下的唯一标识 非必填
* openid和sub_openid可以选传其中之一如果选择传sub_openid ,则必须传sub_appid
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest JS支付
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest 扫码支付
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException
*/
public MchPayRequest createPayRequest(TradeType tradeType, String openId,
String productId, String body, String detail, String outTradeNo,
double totalFee, String notifyUrl, String createIp, String attach,
Date timeStart, Date timeExpire, String goodsTag, String limitPay)
public MchPayRequest createPayRequest(String body, String detail,
String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String openId,
String productId, String attach, Date timeStart, Date timeExpire,
String goodsTag, String limitPay, String subOpenId)
throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, openId,
body, outTradeNo, totalFee, notifyUrl, createIp, tradeType);
payPackage.setProductId(productId);
payPackage.setAttach(attach);
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, notifyUrl, createIp, tradeType, openId,
null, productId, attach);
payPackage.setTimeStart(timeStart);
payPackage.setTimeExpire(timeExpire);
payPackage.setGoodsTag(goodsTag);
payPackage.setLimitPay(limitPay);
payPackage.setDetail(detail);
payPackage.setSubOpenId(subOpenId);
return createPayRequest(payPackage);
}
@ -203,16 +220,18 @@ public class PayApi extends MchApi {
* 支付通知地址
* @param createIp
* ip地址
* @param attach
* 附加数据 非必填
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest
* @return JSAPI支付对象
* @throws WeixinPayException
*/
public MchPayRequest createJSPayRequest(String openId, String body,
String outTradeNo, double totalFee, String notifyUrl,
String createIp) throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, openId,
body, outTradeNo, totalFee, notifyUrl, createIp,
TradeType.JSAPI);
String createIp, String attach) throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.JSAPI,
openId, null, null, attach);
return createPayRequest(payPackage);
}
@ -291,6 +310,8 @@ public class PayApi extends MchApi {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return Native回调对象
* @see com.foxinmy.weixin4j.payment.mch.NativePayResponse
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a>
@ -300,10 +321,10 @@ public class PayApi extends MchApi {
*/
public NativePayResponse createNativePayResponse(String productId,
String body, String outTradeNo, double totalFee, String notifyUrl,
String createIp) throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, null, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE);
payPackage.setProductId(productId);
String createIp, String attach) throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE,
null, null, productId, attach);
PrePay prePay = createPrePay(payPackage);
return new NativePayResponse(weixinAccount, prePay.getPrepayId());
}
@ -323,6 +344,8 @@ public class PayApi extends MchApi {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return Native支付对象
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a>
@ -332,9 +355,10 @@ public class PayApi extends MchApi {
*/
public MchPayRequest createNativePayRequest(String productId, String body,
String outTradeNo, double totalFee, String notifyUrl,
String createIp) throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, null, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE);
String createIp, String attach) throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE,
null, null, productId, attach);
return createPayRequest(payPackage);
}
@ -351,6 +375,8 @@ public class PayApi extends MchApi {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return APP支付对象
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
* @see <a
@ -358,10 +384,11 @@ public class PayApi extends MchApi {
* @throws WeixinPayException
*/
public MchPayRequest createAppPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp)
double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, null, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.APP);
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.APP, null,
null, null, attach);
return createPayRequest(payPackage);
}
@ -378,6 +405,8 @@ public class PayApi extends MchApi {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return WAP支付对象
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
* @see <a
@ -385,10 +414,11 @@ public class PayApi extends MchApi {
* @throws WeixinPayException
*/
public MchPayRequest createWAPPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp)
double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, null, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.WAP);
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.WAP, null,
null, null, attach);
return createPayRequest(payPackage);
}
@ -399,42 +429,28 @@ public class PayApi extends MchApi {
* 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息
* @param body
* 商品描述
* @param orderNo
* @param outTradeNo
* 商户内部唯一订单号
* @param orderFee
* @param totalFee
* 商品总额 单位元
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return 支付的订单信息
* @see {@link #createMicroPay(MicroPayPackage)}
* @throws WeixinException
*/
public Order createMicroPay(String authCode, String body, String orderNo,
double orderFee, String createIp) throws WeixinException {
MicroPayPackage payPackage = new MicroPayPackage(weixinAccount,
authCode, body, orderNo, orderFee, createIp);
return createMicroPay(payPackage);
}
/**
* 提交被扫支付:收银员使用扫码设备读取微信用户刷卡授权码以后二维码或条码信息传送至商户收银台由商户收银台或者商户后台调用该接口发起支付.
*
* @param payPackage
* 订单信息
* @return 支付的订单信息
* @throws WeixinException
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest
* @see com.foxinmy.weixin4j.payment.mch.Order
* @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">提交被扫支付API</a>
* @throws WeixinException
*/
public Order createMicroPay(MicroPayPackage payPackage)
public MchPayRequest createMICROPayRequest(String authCode, String body,
String outTradeNo, double totalFee, String createIp, String attach)
throws WeixinException {
payPackage.setSign(weixinSignature.sign(payPackage));
String para = XmlStream.toXML(payPackage);
WeixinResponse response = weixinExecutor.post(
getRequestUri("micropay_uri"), para);
return response.getAsObject(new TypeReference<Order>() {
});
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body,
outTradeNo, totalFee, null, createIp, TradeType.MICROPAY, null,
null, null, attach);
return createPayRequest(payPackage);
}
/**
@ -567,7 +583,7 @@ public class PayApi extends MchApi {
* @since V3
* @throws WeixinException
*/
public ApiResult reverseOrder(InputStream certificate, IdQuery idQuery)
public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery)
throws WeixinException {
try {
Map<String, String> map = createBaseRequestMap(idQuery);
@ -575,7 +591,7 @@ public class PayApi extends MchApi {
String param = XmlStream.map2xml(map);
WeixinResponse response = createSSLRequestExecutor(certificate)
.post(getRequestUri("order_reverse_uri"), param);
return response.getAsObject(new TypeReference<ApiResult>() {
return response.getAsObject(new TypeReference<MerchantResult>() {
});
} finally {
if (certificate != null) {
@ -629,14 +645,14 @@ public class PayApi extends MchApi {
* @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3">关闭订单API</a>
*/
public ApiResult closeOrder(String outTradeNo) throws WeixinException {
public MerchantResult closeOrder(String outTradeNo) throws WeixinException {
Map<String, String> map = createBaseRequestMap(new IdQuery(outTradeNo,
IdType.TRADENO));
map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post(
getRequestUri("order_close_uri"), param);
return response.getAsObject(new TypeReference<ApiResult>() {
return response.getAsObject(new TypeReference<MerchantResult>() {
});
}

View File

@ -19,4 +19,8 @@ public class WeixinPayException extends WeixinException {
public WeixinPayException(String errorCode, String errorMsg) {
super(errorCode, errorMsg);
}
public WeixinPayException(Throwable e) {
super(e);
}
}

View File

@ -161,12 +161,12 @@ public class WeixinRequestExecutor {
if ("0".equals(xmlResult.getReturnCode())) {
return;
}
if (!com.foxinmy.weixin4j.model.Consts.SUCCESS
if (!Consts.SUCCESS
.equalsIgnoreCase(xmlResult.getReturnCode())) {
throw new WeixinException(xmlResult.getReturnCode(),
xmlResult.getReturnMsg());
}
if (!com.foxinmy.weixin4j.model.Consts.SUCCESS
if (!Consts.SUCCESS
.equalsIgnoreCase(xmlResult.getResultCode())) {
throw new WeixinException(xmlResult.getErrCode(),
xmlResult.getErrCodeDes());

View File

@ -1,204 +0,0 @@
package com.foxinmy.weixin4j.payment;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.util.RandomUtil;
/**
* 刷卡支付订单详情
*
* @className MicroPayPackage
* @author jy
* @date 2014年11月17日
* @since JDK 1.6
* @see
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class MicroPayPackage extends PayPackage {
private static final long serialVersionUID = 8944928173669656177L;
/**
* 微信分配的公众账号 必须
*/
@XmlElement(name = "appid")
@JSONField(name = "appid")
private String appId;
/**
* 微信支付分配的商户号 必须
*/
@XmlElement(name = "mch_id")
@JSONField(name = "mch_id")
private String mchId;
/**
* 微信支付分配的终端设备号 非必须
*/
@XmlElement(name = "device_info")
@JSONField(name = "device_info")
private String deviceInfo;
/**
* 微信分配的子商户公众账号ID 非必须
*/
@XmlElement(name = "sub_id")
@JSONField(name = "sub_id")
private String subId;
/**
* 微信支付分配的子商户号 非必须
*/
@XmlElement(name = "sub_mch_id")
@JSONField(name = "sub_mch_id")
private String subMchId;
/**
* 随机字符串,不长于 32 必须
*/
@XmlElement(name = "nonce_str")
@JSONField(name = "nonce_str")
private String nonceStr;
/**
* 签名 <font color="red">调用者不必关注</font>
*/
private String sign;
/**
* 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息
*/
@XmlElement(name = "auth_code")
@JSONField(name = "auth_code")
private String authCode;
/**
* 指定支付方式:no_credit--指定不能使用信用卡支付
*/
@XmlElement(name = "limit_pay")
@JSONField(name = "limit_pay")
private String limitPay;
protected MicroPayPackage() {
// jaxb required
}
/**
*
* @param weixinAccount
* 商户信息
* @param authCode
* 授权码
* @param body
* 支付详情
* @param totalFee
* 支付金额(单位元) 必填
* @param createIp
* 发起支付的IP地址
*/
public MicroPayPackage(WeixinPayAccount weixinAccount, String authCode,
String body, String outTradeNo, double totalFee, String createIp) {
this(weixinAccount.getId(), weixinAccount.getMchId(), weixinAccount
.getDeviceInfo(), weixinAccount.getSubId(), weixinAccount
.getSubMchId(), authCode, body, outTradeNo, totalFee, createIp,
null, null, null, null, null);
}
/**
* 完整参数
*
* @param appId
* 公众号唯一标识 必填
* @param mchId
* 微信支付商户号 必填
* @param deviceInfo
* 微信支付设备号 非必填
* @param subId
* 子商户唯一标识 非必填
* @param subMchId
* 子商户商户号 非必填
* @param authCode
* 授权码 必填
* @param body
* 支付详情 必填
* @param outTradeNo
* 商户侧订单号 必填
* @param totalFee
* 支付金额(单位元) 必填
* @param createIp
* 发起支付的IP地址 必填
* @param attach
* 支付时附加信息 非必填
* @param timeStart
* 订单生成时间 非必填
* @param timeExpire
* 订单失效时间 非必填
* @param goodsTag
* 商品标记 非必填
* @param limitPay
* 指定支付方式 非必填
*/
public MicroPayPackage(String appId, String mchId, String deviceInfo,
String subId, String subMchId, String authCode, String body,
String outTradeNo, double totalFee, String createIp, String attach,
Date timeStart, Date timeExpire, String goodsTag, String limitPay) {
super(body, outTradeNo, totalFee, null, createIp, null, timeStart,
timeExpire, goodsTag);
this.appId = appId;
this.mchId = mchId;
this.deviceInfo = deviceInfo;
this.subId = subId;
this.subMchId = subMchId;
this.nonceStr = RandomUtil.generateString(16);
this.authCode = authCode;
this.limitPay = limitPay;
}
public String getAppId() {
return appId;
}
public String getMchId() {
return mchId;
}
public String getDeviceInfo() {
return deviceInfo;
}
public String getNonceStr() {
return nonceStr;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getAuthCode() {
return authCode;
}
public void setAuthCode(String authCode) {
this.authCode = authCode;
}
public String getLimitPay() {
return limitPay;
}
public void setLimitPay(String limitPay) {
this.limitPay = limitPay;
}
@Override
public String toString() {
return "MicroPayPackage [appId=" + appId + ", mchId=" + mchId
+ ", deviceInfo=" + deviceInfo + ", subId=" + subId
+ ", subMchId=" + subMchId + ", nonceStr=" + nonceStr
+ ", sign=" + sign + ", authCode=" + authCode + ", limitPay="
+ limitPay + ", " + super.toString() + "]";
}
}

View File

@ -1,6 +1,5 @@
package com.foxinmy.weixin4j.payment;
import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
@ -9,6 +8,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.util.DateUtil;
/**
@ -22,7 +23,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class PayPackage implements Serializable {
public class PayPackage extends MerchantResult {
private static final long serialVersionUID = 3450161267802545790L;
@ -90,29 +91,36 @@ public class PayPackage implements Serializable {
/**
* 订单对象
*
* @param weixinPayAccount
* 商户信息 必填
* @param body
* 订单描述
* 订单描述 必填
* @param detail
* 订单详情 非必填
* @param outTradeNo
* 商户内部ID
* 商户内部ID 必填
* @param totalFee
* 订单总额 <font color="red">单位为元</font>
* 订单总额 必填 <font color="red">单位为元</font>
* @param notifyUrl
* 回调地址
* 回调地址 必填
* @param createIp
* 生成订单数据的机器IP
* 生成订单数据的机器IP 必填
* @param attach
* 附加数据
* 附加数据 非必填
* @param timeStart
* 订单生成时间
* 订单生成时间 非必填
* @param timeExpire
* 订单失效时间
* 订单失效时间 非必填
* @param goodsTag
* 订单标记
* 订单标记 非必填
*/
public PayPackage(String body, String outTradeNo, double totalFee,
public PayPackage(WeixinPayAccount weixinPayAccount, String body,
String detail, String outTradeNo, double totalFee,
String notifyUrl, String createIp, String attach, Date timeStart,
Date timeExpire, String goodsTag) {
super(weixinPayAccount);
this.body = body;
this.detail = detail;
this.outTradeNo = outTradeNo;
this.totalFee = DateUtil.formaFee2Fen(totalFee);
this.notifyUrl = notifyUrl;
@ -223,10 +231,10 @@ public class PayPackage implements Serializable {
@Override
public String toString() {
return "PayPackage [body=" + body + ", detail=" + detail
+ ", outTradeNo=" + outTradeNo + ", totalFee=" + totalFee
+ ", notifyUrl=" + notifyUrl + ", createIp=" + createIp
+ ", attach=" + attach + ", timeStart=" + timeStart
+ ", timeExpire=" + timeExpire + ", goodsTag=" + goodsTag + "]";
return "body=" + body + ", detail=" + detail + ", outTradeNo="
+ outTradeNo + ", totalFee=" + totalFee + ", notifyUrl="
+ notifyUrl + ", createIp=" + createIp + ", attach=" + attach
+ ", timeStart=" + timeStart + ", timeExpire=" + timeExpire
+ ", goodsTag=" + goodsTag;
}
}
}

View File

@ -17,12 +17,12 @@ import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.coupon.CouponDetail;
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
import com.foxinmy.weixin4j.payment.mch.CorpPayment;
import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
import com.foxinmy.weixin4j.payment.mch.MchPayRequest;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.payment.mch.NativePayResponse;
import com.foxinmy.weixin4j.payment.mch.OpenIdResult;
import com.foxinmy.weixin4j.payment.mch.Order;
@ -124,6 +124,7 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest JS支付
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest 扫码支付
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException
@ -136,12 +137,6 @@ public class WeixinPayProxy {
/**
* 创建支付请求对象完整参数
*
* @param tradeType
* 交易类型 <font color="red">必填项</font>
* @param openId
* 用户ID <font color="red">tradeType=JSAPI时必填</font>
* @param productId
* 产品ID <font color="red">tradeType=NATIVE时必填</font>
* @param body
* 商品描述 <font color="red">必填项</font>
* @param detail
@ -154,6 +149,12 @@ public class WeixinPayProxy {
* 支付回调URL <font color="red">必填项</font>
* @param createIp
* 订单生成的机器IP <font color="red">必填项</font>
* @param tradeType
* 交易类型 <font color="red">必填项</font>
* @param openId
* 用户ID <font color="red">tradeType=JSAPI时必填</font>
* @param productId
* 产品ID <font color="red">tradeType=NATIVE时必填</font>
* @param attach
* 附加数据在查询API和支付通知中原样返回该字段主要用于商户携带订单的自定义数据 非必填项
* @param timeStart
@ -164,21 +165,26 @@ public class WeixinPayProxy {
* 商品标记代金券或立减优惠功能的参数 非必填项
* @param limitPay
* 指定支付方式:no_credit--指定不能使用信用卡支付 非必填项
* @param subOpenId
* 用户在子商户appid下的唯一标识 非必填
* openid和sub_openid可以选传其中之一如果选择传sub_openid ,则必须传sub_appid
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest JS支付
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest 扫码支付
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException
*/
public MchPayRequest createPayRequest(TradeType tradeType, String openId,
String productId, String body, String detail, String outTradeNo,
double totalFee, String notifyUrl, String createIp, String attach,
Date timeStart, Date timeExpire, String goodsTag, String limitPay)
public MchPayRequest createPayRequest(String body, String detail,
String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String openId,
String productId, String attach, Date timeStart, Date timeExpire,
String goodsTag, String limitPay, String subOpenId)
throws WeixinPayException {
return payApi.createPayRequest(tradeType, openId, productId, body,
detail, outTradeNo, totalFee, notifyUrl, createIp, attach,
timeStart, timeExpire, goodsTag, limitPay);
return payApi.createPayRequest(body, detail, outTradeNo, totalFee,
notifyUrl, createIp, tradeType, openId, productId, attach,
timeStart, timeExpire, goodsTag, limitPay, subOpenId);
}
/**
@ -196,6 +202,8 @@ public class WeixinPayProxy {
* 支付通知地址
* @param createIp
* ip地址
* @param attach
* 附加数据 非必填
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest
* @return JSAPI支付对象
@ -203,9 +211,9 @@ public class WeixinPayProxy {
*/
public MchPayRequest createJSPayRequest(String openId, String body,
String outTradeNo, double totalFee, String notifyUrl,
String createIp) throws WeixinPayException {
String createIp, String attach) throws WeixinPayException {
return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee,
notifyUrl, createIp);
notifyUrl, createIp, attach);
}
/**
@ -262,6 +270,8 @@ public class WeixinPayProxy {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return Native回调对象
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.NativePayResponse
@ -272,9 +282,9 @@ public class WeixinPayProxy {
*/
public NativePayResponse createNativePayResponse(String productId,
String body, String outTradeNo, double totalFee, String notifyUrl,
String createIp) throws WeixinPayException {
String createIp, String attach) throws WeixinPayException {
return payApi.createNativePayResponse(productId, body, outTradeNo,
totalFee, notifyUrl, createIp);
totalFee, notifyUrl, createIp, attach);
}
/**
@ -292,6 +302,8 @@ public class WeixinPayProxy {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return Native支付对象
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest
@ -302,9 +314,9 @@ public class WeixinPayProxy {
*/
public MchPayRequest createNativePayRequest(String productId, String body,
String outTradeNo, double totalFee, String notifyUrl,
String createIp) throws WeixinPayException {
String createIp, String attach) throws WeixinPayException {
return payApi.createNativePayRequest(productId, body, outTradeNo,
totalFee, notifyUrl, createIp);
totalFee, notifyUrl, createIp, attach);
}
/**
@ -320,6 +332,8 @@ public class WeixinPayProxy {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return APP支付对象
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
@ -328,10 +342,10 @@ public class WeixinPayProxy {
* @throws WeixinPayException
*/
public MchPayRequest createAppPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp)
double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException {
return payApi.createAppPayRequest(body, outTradeNo, totalFee,
notifyUrl, createIp);
notifyUrl, createIp, attach);
}
/**
@ -347,6 +361,8 @@ public class WeixinPayProxy {
* 支付回调URL
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return WAP支付对象
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
@ -355,10 +371,10 @@ public class WeixinPayProxy {
* @throws WeixinPayException
*/
public MchPayRequest createWAPPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp)
double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException {
return payApi.createWAPPayRequest(body, outTradeNo, totalFee,
notifyUrl, createIp);
notifyUrl, createIp, attach);
}
/**
@ -368,39 +384,27 @@ public class WeixinPayProxy {
* 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息
* @param body
* 商品描述
* @param orderNo
* @param outTradeNo
* 商户内部唯一订单号
* @param orderFee
* @param totalFee
* 商品总额 单位元
* @param createIp
* 订单生成的机器 IP
* @param attach
* 附加数据 非必填
* @return 支付的订单信息
* @see com.foxinmy.weixin4j.api.PayApi
* @see {@link #createMicroPay(MicroPayPackage)}
* @throws WeixinException
*/
public Order createMicroPay(String authCode, String body, String orderNo,
double orderFee, String createIp) throws WeixinException {
return payApi.createMicroPay(authCode, body, orderNo, orderFee,
createIp);
}
/**
* 提交被扫支付:收银员使用扫码设备读取微信用户刷卡授权码以后二维码或条码信息传送至商户收银台由商户收银台或者商户后台调用该接口发起支付.
*
* @param payPackage
* 订单信息
* @return 支付的订单信息
* @throws WeixinException
* @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.MicroPayPackage
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest
* @see com.foxinmy.weixin4j.payment.mch.Order
* @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">提交被扫支付API</a>
* @throws WeixinException
*/
public Order createMicroPay(MicroPayPackage payPackage)
public MchPayRequest createMICROPayRequest(String authCode, String body,
String outTradeNo, double totalFee, String createIp, String attach)
throws WeixinException {
return payApi.createMicroPay(payPackage);
return payApi.createMICROPayRequest(authCode, body, outTradeNo,
totalFee, createIp, attach);
}
/**
@ -544,7 +548,7 @@ public class WeixinPayProxy {
* @since V3
* @throws WeixinException
*/
public ApiResult reverseOrder(InputStream certificate, IdQuery idQuery)
public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery)
throws WeixinException {
return payApi.reverseOrder(certificate, idQuery);
}
@ -559,7 +563,7 @@ public class WeixinPayProxy {
* @throws WeixinException
* @throws IOException
*/
public ApiResult reverseOrder(IdQuery idQuery) throws WeixinException,
public MerchantResult reverseOrder(IdQuery idQuery) throws WeixinException,
IOException {
return payApi.reverseOrder(
new FileInputStream(settings.getCertificateFile0()), idQuery);
@ -581,7 +585,7 @@ public class WeixinPayProxy {
* @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3">关闭订单API</a>
*/
public ApiResult closeOrder(String outTradeNo) throws WeixinException {
public MerchantResult closeOrder(String outTradeNo) throws WeixinException {
return payApi.closeOrder(outTradeNo);
}

View File

@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.type.CouponStatus;
import com.foxinmy.weixin4j.type.CouponStockType;
import com.foxinmy.weixin4j.type.CouponType;
@ -25,7 +25,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CouponDetail extends ApiResult {
public class CouponDetail extends MerchantResult {
private static final long serialVersionUID = -311265355895457070L;

View File

@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
/**
* 代金券发放结果
@ -19,7 +19,7 @@ import com.foxinmy.weixin4j.payment.mch.ApiResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CouponResult extends ApiResult {
public class CouponResult extends MerchantResult {
private static final long serialVersionUID = -1996967923720149124L;

View File

@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.type.CouponStockStatus;
import com.foxinmy.weixin4j.type.CouponType;
import com.foxinmy.weixin4j.util.DateUtil;
@ -24,7 +24,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CouponStock extends ApiResult {
public class CouponStock extends MerchantResult {
private static final long serialVersionUID = -8627202879200080499L;

View File

@ -24,7 +24,7 @@ public class APPPayRequest extends AbstractPayRequest {
}
@Override
public TradeType getTradeType() {
public TradeType getPaymentType() {
return TradeType.APP;
}
@ -33,7 +33,7 @@ public class APPPayRequest extends AbstractPayRequest {
*/
@Override
public PayRequest toRequestObject() {
PayRequest payRequest = new PayRequest(getPayAccount().getId(),
PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
"Sign=WXPay");
payRequest.setPrepayId(getPrePayId());
return payRequest;
@ -45,13 +45,13 @@ public class APPPayRequest extends AbstractPayRequest {
String sign = DigestUtil.MD5(
String.format("%s&key=%s",
MapUtil.toJoinString(payRequest, false, true),
getPayAccount().getPaySignKey())).toUpperCase();
getPaymentAccount().getPaySignKey())).toUpperCase();
StringBuilder content = new StringBuilder();
content.append("<xml>");
content.append(String.format("<appid><![CDATA[%s]]></appid>",
payRequest.getAppId()));
content.append(String.format("<partnerid><![CDATA[%s]]></partnerid>",
getPayAccount().getPartnerId()));
getPaymentAccount().getPartnerId()));
content.append(String.format("<prepayid><![CDATA[%s]]></prepayid>",
payRequest.getPrepayId()));
content.append(String.format("<package><![CDATA[%s]]></package>",

View File

@ -7,13 +7,13 @@ import com.foxinmy.weixin4j.sign.WeixinSignature;
public abstract class AbstractPayRequest implements MchPayRequest {
private final String prePayId;
private final WeixinPayAccount payAccount;
private final WeixinPayAccount paymentAccount;
protected final WeixinSignature weixinSignature;
public AbstractPayRequest(String prePayId, WeixinPayAccount payAccount) {
public AbstractPayRequest(String prePayId, WeixinPayAccount paymentAccount) {
this.prePayId = prePayId;
this.payAccount = payAccount;
this.weixinSignature = new WeixinPaymentSignature(payAccount.getPaySignKey());
this.paymentAccount = paymentAccount;
this.weixinSignature = new WeixinPaymentSignature(paymentAccount.getPaySignKey());
}
@Override
@ -22,7 +22,7 @@ public abstract class AbstractPayRequest implements MchPayRequest {
}
@Override
public WeixinPayAccount getPayAccount() {
return this.payAccount;
public WeixinPayAccount getPaymentAccount() {
return this.paymentAccount;
}
}
}

View File

@ -1,13 +1,12 @@
package com.foxinmy.weixin4j.payment.mch;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.type.MPPaymentCheckNameType;
import com.foxinmy.weixin4j.util.DateUtil;
@ -22,8 +21,8 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CorpPayment implements Serializable {
public class CorpPayment extends MerchantResult {
private static final long serialVersionUID = 3734639674346425312L;
/**
* 商户订单号
@ -65,23 +64,33 @@ public class CorpPayment implements Serializable {
@XmlElement(name = "spbill_create_ip")
@JSONField(name = "spbill_create_ip")
private String clientIp;
protected CorpPayment() {
// jaxb required
}
/**
* 企业付款
* @param outTradeNo 商户的订单号
* @param openId 用户的openid
* @param checkNameType 校验用户姓名选项
* @param desc 描述
* @param amount 金额
* @param clientIp 调用接口IP
*
* @param weixinPayAccount
* 商户信息
* @param outTradeNo
* 商户的订单号
* @param openId
* 用户的openid
* @param checkNameType
* 校验用户姓名选项
* @param desc
* 描述
* @param amount
* 金额
* @param clientIp
* 调用接口IP
*/
public CorpPayment(String outTradeNo, String openId,
MPPaymentCheckNameType checkNameType, String desc, double amount,
String clientIp) {
public CorpPayment(WeixinPayAccount weixinPayAccount, String outTradeNo,
String openId, MPPaymentCheckNameType checkNameType, String desc,
double amount, String clientIp) {
super(weixinPayAccount);
this.outTradeNo = outTradeNo;
this.openId = openId;
this.checkNameType = checkNameType;
@ -127,6 +136,6 @@ public class CorpPayment implements Serializable {
return "CorpPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
+ ", checkNameType=" + checkNameType + ", userName=" + userName
+ ", desc=" + desc + ", amount=" + amount + ", clientIp="
+ clientIp + "]";
+ clientIp + ", " + super.toString() + "]";
}
}
}

View File

@ -22,7 +22,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CorpPaymentRecord extends ApiResult {
public class CorpPaymentRecord extends MerchantResult {
private static final long serialVersionUID = -1926873539419750498L;

View File

@ -18,7 +18,7 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CorpPaymentResult extends ApiResult {
public class CorpPaymentResult extends MerchantResult {
private static final long serialVersionUID = 1110472826089211646L;

View File

@ -30,13 +30,13 @@ public class JSAPIPayRequest extends AbstractPayRequest {
}
@Override
public TradeType getTradeType() {
public TradeType getPaymentType() {
return TradeType.JSAPI;
}
@Override
public PayRequest toRequestObject() {
PayRequest payRequest = new PayRequest(getPayAccount().getId(),
PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
"prepay_id=" + getPrePayId());
payRequest.setSignType(SignType.MD5);
payRequest.setPaySign(weixinSignature.sign(payRequest));

View File

@ -0,0 +1,75 @@
package com.foxinmy.weixin4j.payment.mch;
import javax.xml.bind.annotation.XmlTransient;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.PayRequest;
import com.foxinmy.weixin4j.type.TradeType;
/**
* MICROPAY刷卡支付
*
* @className MICROPayRequest
* @author jy
* @date 2015年12月25日
* @since JDK 1.6
* @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see com.foxinmy.weixin4j.payment.PayRequest
* @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1">刷卡支付</a>
*/
public class MICROPayRequest extends Order implements MchPayRequest {
private static final long serialVersionUID = 6147576305404111278L;
@XmlTransient
@JSONField(serialize = false)
private WeixinPayAccount paymentAccount;
protected MICROPayRequest() {
// jaxb required
}
@Override
@JSONField(serialize = false)
public TradeType getPaymentType() {
return TradeType.MICROPAY;
}
/**
* <font color="red">返回null,请不要尝试作为支付请求</font>
*/
@Override
@JSONField(serialize = false)
public String toRequestString() {
return null;
}
/**
* <font color="red">返回null,请不要尝试作为支付请求</font>
*/
@JSONField(serialize = false)
@Override
public PayRequest toRequestObject() {
return null;
}
/**
* <font color="red">返回null,请不要尝试作为支付请求</font>
*/
@JSONField(serialize = false)
@Override
public String getPrePayId() {
return null;
}
public void setPaymentAccount(WeixinPayAccount paymentAccount) {
this.paymentAccount = paymentAccount;
}
@Override
public WeixinPayAccount getPaymentAccount() {
return this.paymentAccount;
}
}

View File

@ -11,7 +11,6 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.PayPackage;
import com.foxinmy.weixin4j.type.TradeType;
import com.foxinmy.weixin4j.util.RandomUtil;
/**
* 支付订单详情
@ -28,52 +27,6 @@ public class MchPayPackage extends PayPackage {
private static final long serialVersionUID = 8944928173669656177L;
/**
* 微信分配的公众账号 必须
*/
@XmlElement(name = "appid")
@JSONField(name = "appid")
private String appId;
/**
* 微信支付分配的商户号 必须
*/
@XmlElement(name = "mch_id")
@JSONField(name = "mch_id")
private String mchId;
/**
* 微信支付分配的终端设备号 非必须
*/
@XmlElement(name = "device_info")
@JSONField(name = "device_info")
private String deviceInfo;
/**
* 微信分配的子商户公众账号ID 非必须
*/
@XmlElement(name = "sub_id")
@JSONField(name = "sub_id")
private String subId;
/**
* 微信支付分配的子商户号 非必须
*/
@XmlElement(name = "sub_mch_id")
@JSONField(name = "sub_mch_id")
private String subMchId;
/**
* 用户子标识 非必须
*/
@XmlElement(name = "sub_openid")
@JSONField(name = "sub_openid")
private String subOpenId;
/**
* 随机字符串,不长于 32 必须
*/
@XmlElement(name = "nonce_str")
@JSONField(name = "nonce_str")
private String nonceStr;
/**
* 签名 <font color="red">调用者无需关心</font>
*/
private String sign;
/**
* 交易类型JSAPINATIVEAPP 必须
*/
@ -86,96 +39,42 @@ public class MchPayPackage extends PayPackage {
@XmlElement(name = "openid")
@JSONField(name = "openid")
private String openId;
/**
* 只在 trade_type NATIVE 模式一 时需要填写 非必须
*/
@XmlElement(name = "product_id")
@JSONField(name = "product_id")
private String productId;
/**
* 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息
*/
@XmlElement(name = "auth_code")
@JSONField(name = "auth_code")
private String authCode;
/**
* 指定支付方式:no_credit--指定不能使用信用卡支付
*/
@XmlElement(name = "limit_pay")
@JSONField(name = "limit_pay")
private String limitPay;
/**
* 服务商下的用户子标识 非必须
*/
@XmlElement(name = "sub_openid")
@JSONField(name = "sub_openid")
private String subOpenId;
protected MchPayPackage() {
// jaxb required
}
/**
* 微信支付
*
* @param weixinAccount
* 商户信息 必填
* @param openId
* 用户唯一标识 JSAPI支付必填
* @param body
* 支付详情 必填
* @param outTradeNo
* 商户侧订单号 必填
* @param totalFee
* 支付金额(单位元) 必填
* @param notifyUrl
* 支付回调URL
* @param createIp
* 发起支付的IP地址
* @param tradeType
* 支付类型
*/
public MchPayPackage(WeixinPayAccount weixinAccount, String openId,
String body, String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType) {
this(weixinAccount, openId, body, outTradeNo, totalFee, notifyUrl,
createIp, tradeType, null);
}
/**
*
* @param weixinAccount
* 商户信息 必填
* @param openId
* 用户唯一标识 JSAPI支付必填
* @param body
* 支付详情 必填
* @param outTradeNo
* 商户侧订单号 必填
* @param totalFee
* 支付金额(单位元) 必填
* @param notifyUrl
* 支付回调URL
* @param createIp
* 发起支付的IP地址
* @param tradeType
* 支付类型
* @param attach
* 支付时附加信息
*/
public MchPayPackage(WeixinPayAccount weixinAccount, String openId,
String body, String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String attach) {
this(weixinAccount.getId(), weixinAccount.getMchId(), weixinAccount
.getDeviceInfo(), weixinAccount.getSubId(), weixinAccount
.getSubMchId(), null, body, outTradeNo, totalFee, notifyUrl,
createIp, tradeType, openId, attach, null, null, null, null,
null);
}
/**
* 完整参数
*
* @param appId
* 公众号唯一标识 必填
* @param mchId
* 微信支付商户号 必填
* @param deviceInfo
* 微信支付设备号 非必填
* @param subId
* 子商户唯一标识 非必填
* @param subMchId
* 子商户商户号 非必填
* @param subOpenId
* 用户在子商户appid下的唯一标识 非必填
* openid和sub_openid可以选传其中之一如果选择传sub_openid ,则必须传sub_appid
* @param body
* 支付详情 必填
* @param outTradeNo
@ -189,7 +88,48 @@ public class MchPayPackage extends PayPackage {
* @param tradeType
* 支付类型 必填
* @param openId
* 用户唯一标识 JSAPI支付必填
* 用户唯一标识 公众号JSAPI支付必填
* @param authCode
* 支付授权码 刷卡MICROPAY支付必填
* @param productId
* 商品ID 扫码NATIVE支付必填
* @param attach
* 支付时附加信息 非必填
*/
public MchPayPackage(WeixinPayAccount weixinAccount, String body,
String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String openId,
String authCode, String productId, String attach) {
this(weixinAccount, body, null, outTradeNo, totalFee, notifyUrl,
createIp, tradeType, openId, authCode, productId, attach, null,
null, null, null, null);
}
/**
* 完整参数
*
* @param weixinAccount
* 商户信息 必填
* @param body
* 支付详情 必填
* @param detail
* 订单详情 非必填
* @param outTradeNo
* 商户侧订单号 必填
* @param totalFee
* 支付金额(单位元) 必填
* @param notifyUrl
* 支付回调URL 必填
* @param createIp
* 发起支付的IP地址 必填
* @param tradeType
* 支付类型 必填
* @param openId
* 用户唯一标识 公众号JSAPI支付必填
* @param authCode
* 支付授权码 刷卡MICROPAY支付必填
* @param productId
* 商品ID 扫码NATIVE支付必填
* @param attach
* 支付时附加信息 非必填
* @param timeStart
@ -202,50 +142,24 @@ public class MchPayPackage extends PayPackage {
* 商品ID native支付必填
* @param limitPay
* 指定支付方式 非必填
* @param subOpenId
* 用户在子商户appid下的唯一标识 非必填
* openid和sub_openid可以选传其中之一如果选择传sub_openid ,则必须传sub_appid
*/
public MchPayPackage(String appId, String mchId, String deviceInfo,
String subId, String subMchId, String subOpenId, String body,
String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String openId, String attach,
Date timeStart, Date timeExpire, String goodsTag, String productId,
String limitPay) {
super(body, outTradeNo, totalFee, notifyUrl, createIp, attach,
timeStart, timeExpire, goodsTag);
this.appId = appId;
this.mchId = mchId;
this.deviceInfo = deviceInfo;
this.subId = subId;
this.subMchId = subMchId;
this.subOpenId = subOpenId;
this.nonceStr = RandomUtil.generateString(16);
public MchPayPackage(WeixinPayAccount weixinPayAccount, String body,
String detial, String outTradeNo, double totalFee,
String notifyUrl, String createIp, TradeType tradeType,
String openId, String authCode, String productId, String attach,
Date timeStart, Date timeExpire, String goodsTag, String limitPay,
String subOpenId) {
super(weixinPayAccount, body, detial, outTradeNo, totalFee, notifyUrl,
createIp, attach, timeStart, timeExpire, goodsTag);
this.tradeType = tradeType.name();
this.openId = openId;
this.authCode = authCode;
this.productId = productId;
this.limitPay = limitPay;
}
public String getAppId() {
return appId;
}
public String getMchId() {
return mchId;
}
public String getDeviceInfo() {
return deviceInfo;
}
public String getNonceStr() {
return nonceStr;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
this.subOpenId = subOpenId;
}
public String getTradeType() {
@ -256,12 +170,12 @@ public class MchPayPackage extends PayPackage {
return openId;
}
public String getProductId() {
return productId;
public String getAuthCode() {
return authCode;
}
public void setProductId(String productId) {
this.productId = productId;
public String getProductId() {
return productId;
}
public String getLimitPay() {
@ -272,13 +186,19 @@ public class MchPayPackage extends PayPackage {
this.limitPay = limitPay;
}
public String getSubOpenId() {
return subOpenId;
}
public void setSubOpenId(String subOpenId) {
this.subOpenId = subOpenId;
}
@Override
public String toString() {
return "MchPayPackage [appId=" + appId + ", mchId=" + mchId
+ ", deviceInfo=" + deviceInfo + ", subId=" + subId
+ ", subMchId=" + subMchId + ", subOpenId=" + subOpenId
+ ", nonceStr=" + nonceStr + ", sign=" + sign + ", tradeType="
+ tradeType + ", openId=" + openId + ", productId=" + productId
+ ", limitPay=" + limitPay + ", " + super.toString() + "]";
return "MchPayPackage [tradeType=" + tradeType + ", openId=" + openId
+ ", productId=" + productId + ", authCode=" + authCode
+ ", limitPay=" + limitPay + ", subOpenId=" + subOpenId + ", "
+ super.toString() + "]";
}
}

View File

@ -13,6 +13,7 @@ import com.foxinmy.weixin4j.type.TradeType;
* @since JDK 1.6
* @see JSAPIPayRequest JS支付
* @see NATIVEPayRequest 扫码支付
* @see MICROPayRequest 刷卡支付
* @see APPPayRequest APP支付
* @see WAPPayRequest WAP支付
*/
@ -25,18 +26,18 @@ public interface MchPayRequest {
public String getPrePayId();
/**
* 商户信息
* 支付账号
*
* @return
*/
public WeixinPayAccount getPayAccount();
public WeixinPayAccount getPaymentAccount();
/**
* 交易类型
* 支付类型
*
* @return
*/
public TradeType getTradeType();
public TradeType getPaymentType();
/**
* 支付请求字符串

View File

@ -7,11 +7,14 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.type.SignType;
import com.foxinmy.weixin4j.util.RandomUtil;
/**
* 调用商户平台接口返回的公用字段
*
* @className ApiResult
* @className MerchantResult
* @author jy
* @date 2014年10月21日
* @since JDK 1.6
@ -19,7 +22,7 @@ import com.foxinmy.weixin4j.http.weixin.XmlResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ApiResult extends XmlResult {
public class MerchantResult extends XmlResult {
private static final long serialVersionUID = -8430005768959715444L;
@ -57,6 +60,12 @@ public class ApiResult extends XmlResult {
* 签名 <font color="red">调用者无需关心</font>
*/
private String sign;
/**
* 签名类型 默认MD5
*/
@XmlElement(name = "sign_type")
@JSONField(name = "sign_type")
private String signType;
/**
* 微信支付分配的终端设备号 可能为空
*/
@ -68,14 +77,23 @@ public class ApiResult extends XmlResult {
*/
private String recall;
protected ApiResult() {
protected MerchantResult() {
// jaxb required
}
public ApiResult(String returnCode, String returnMsg) {
public MerchantResult(String returnCode, String returnMsg) {
super(returnCode, returnMsg);
}
public MerchantResult(WeixinPayAccount weixinPayAccount) {
this.appId = weixinPayAccount.getId();
this.mchId = weixinPayAccount.getMchId();
this.deviceInfo = weixinPayAccount.getDeviceInfo();
this.subId = weixinPayAccount.getSubId();
this.subMchId = weixinPayAccount.getSubMchId();
this.nonceStr = RandomUtil.generateString(16);
}
public String getAppId() {
return appId;
}
@ -124,6 +142,20 @@ public class ApiResult extends XmlResult {
this.sign = sign;
}
public String getSignType() {
return signType;
}
@JSONField(serialize = false)
public SignType getFormatSignType() {
return signType != null ? SignType.valueOf(signType.toUpperCase())
: null;
}
public void setSignType(String signType) {
this.signType = signType;
}
public String getDeviceInfo() {
return deviceInfo;
}

View File

@ -27,7 +27,7 @@ public class NATIVEPayRequest extends AbstractPayRequest {
}
@Override
public TradeType getTradeType() {
public TradeType getPaymentType() {
return TradeType.NATIVE;
}
@ -36,7 +36,7 @@ public class NATIVEPayRequest extends AbstractPayRequest {
*/
@Override
public PayRequest toRequestObject() {
return new PayRequest(getPayAccount().getId(), "code_url=" + codeUrl);
return new PayRequest(getPaymentAccount().getId(), "code_url=" + codeUrl);
}
@Override

View File

@ -23,7 +23,7 @@ import com.foxinmy.weixin4j.util.RandomUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class NativePayResponse extends ApiResult {
public class NativePayResponse extends MerchantResult {
private static final long serialVersionUID = 6119895998783333012L;

View File

@ -18,7 +18,7 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class OpenIdResult extends ApiResult {
public class OpenIdResult extends MerchantResult {
private static final long serialVersionUID = 902743989722741814L;

View File

@ -28,7 +28,7 @@ import com.foxinmy.weixin4j.xml.ListsuffixResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Order extends ApiResult {
public class Order extends MerchantResult {
private static final long serialVersionUID = 5636828325595317079L;
/**

View File

@ -18,7 +18,7 @@ import com.foxinmy.weixin4j.type.TradeType;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class PrePay extends ApiResult {
public class PrePay extends MerchantResult {
private static final long serialVersionUID = -8430005768959715444L;

View File

@ -1,7 +1,5 @@
package com.foxinmy.weixin4j.payment.mch;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@ -10,7 +8,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.util.DateUtil;
import com.foxinmy.weixin4j.util.RandomUtil;
/**
* 红包
@ -26,27 +23,9 @@ import com.foxinmy.weixin4j.util.RandomUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Redpacket implements Serializable {
public class Redpacket extends MerchantResult {
private static final long serialVersionUID = -7021352305575714281L;
/**
* 微信分配的公众账号 ID商户号 非空
*/
@XmlElement(name = "wxappid")
@JSONField(name = "wxappid")
private String appId;
/**
* 微信支付分配的商户号 非空
*/
@XmlElement(name = "mch_id")
@JSONField(name = "mch_id")
private String mchId;
/**
* 微信支付分配的子商户号 非必须
*/
@XmlElement(name = "sub_mch_id")
@JSONField(name = "sub_mch_id")
private String subMchId;
/**
* 服务商模式下触达用户时的appid(可填服务商自己的appid或子商户的appid)服务商模式下必填
* 服务商模式下填入的子商户appid必须在微信支付商户平台中先录入否则会校验不过 非必须
@ -66,16 +45,6 @@ public class Redpacket implements Serializable {
@XmlElement(name = "mch_billno")
@JSONField(name = "mch_billno")
private String outTradeNo;
/**
* 随机字符串,不长于 32 必须
*/
@XmlElement(name = "nonce_str")
@JSONField(name = "nonce_str")
private String nonceStr;
/**
* 签名 <font color="red">调用者无需关心</font>
*/
private String sign;
/**
* 红包发送者名称 必填
*/
@ -134,6 +103,8 @@ public class Redpacket implements Serializable {
/**
* 红包
*
* @param weixinPayAccount
* 商户信息
* @param outTradeNo
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用 必填
* @param sendName
@ -153,11 +124,10 @@ public class Redpacket implements Serializable {
* @param remark
* 备注 必填
*/
public Redpacket(WeixinPayAccount payAccount, String outTradeNo,
public Redpacket(WeixinPayAccount weixinPayAccount, String outTradeNo,
String sendName, String openid, double totalAmount, int totalNum,
String wishing, String clientIp, String actName, String remark) {
this(payAccount.getId(), payAccount.getMchId(), payAccount
.getSubMchId(), null, null, outTradeNo, sendName, openid,
this(weixinPayAccount, null, null, outTradeNo, sendName, openid,
totalAmount, totalNum, wishing, clientIp, actName, remark);
}
@ -193,13 +163,11 @@ public class Redpacket implements Serializable {
* @param remark
* 备注 必填
*/
public Redpacket(String appId, String mchId, String subMchId,
String subMsgId, String consumeMchId, String outTradeNo,
String sendName, String openid, double totalAmount, int totalNum,
String wishing, String clientIp, String actName, String remark) {
this.appId = appId;
this.mchId = mchId;
this.subMchId = subMchId;
public Redpacket(WeixinPayAccount weixinPayAccount, String subMsgId,
String consumeMchId, String outTradeNo, String sendName,
String openid, double totalAmount, int totalNum, String wishing,
String clientIp, String actName, String remark) {
super(weixinPayAccount);
this.subMsgId = subMsgId;
this.consumeMchId = consumeMchId;
this.outTradeNo = outTradeNo;
@ -210,7 +178,6 @@ public class Redpacket implements Serializable {
this.clientIp = clientIp;
this.actName = actName;
this.remark = remark;
this.nonceStr = RandomUtil.generateString(16);
this.totalAmount = DateUtil.formaFee2Fen(totalAmount);
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
}
@ -255,23 +222,14 @@ public class Redpacket implements Serializable {
return remark;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
@Override
public String toString() {
return "Redpacket [appId=" + appId + ", mchId=" + mchId + ", subMchId="
+ subMchId + ", subMsgId=" + subMsgId + ", consumeMchId="
+ consumeMchId + ", outTradeNo=" + outTradeNo + ", nonceStr="
+ nonceStr + ", sendName=" + sendName + ", openid=" + openid
+ ", totalAmount=" + totalAmount + ", totalNum=" + totalNum
+ ", amtType=" + amtType + ", wishing=" + wishing
+ ", clientIp=" + clientIp + ", actName=" + actName
+ ", remark=" + remark + ", sign=" + sign + "]";
return "Redpacket [subMsgId=" + subMsgId + ", consumeMchId="
+ consumeMchId + ", outTradeNo=" + outTradeNo + ", sendName="
+ sendName + ", openid=" + openid + ", totalAmount="
+ totalAmount + ", totalNum=" + totalNum + ", amtType="
+ amtType + ", wishing=" + wishing + ", clientIp=" + clientIp
+ ", actName=" + actName + ", remark=" + remark + ", "
+ super.toString() + "]";
}
}

View File

@ -8,7 +8,6 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.util.DateUtil;
/**
@ -22,21 +21,9 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RedpacketSendResult extends XmlResult {
public class RedpacketSendResult extends MerchantResult {
private static final long serialVersionUID = 5611847899634131711L;
/**
* 微信分配的公众账号
*/
@XmlElement(name = "wxappid")
@JSONField(name = "wxappid")
private String appId;
/**
* 微信支付分配的商户号
*/
@XmlElement(name = "mch_id")
@JSONField(name = "mch_id")
private String mchId;
/**
* 商户订单号每个订单号必须唯一 组成 mch_id+yyyymmdd+10位一天内不能重复的数字
*/
@ -72,14 +59,6 @@ public class RedpacketSendResult extends XmlResult {
// jaxb required
}
public String getAppId() {
return appId;
}
public String getMchId() {
return mchId;
}
public String getOutTradeNo() {
return outTradeNo;
}
@ -117,9 +96,8 @@ public class RedpacketSendResult extends XmlResult {
@Override
public String toString() {
return "RedpacketSendResult [appId=" + appId + ", mchId=" + mchId
+ ", outTradeNo=" + outTradeNo + ", openId=" + openId
+ ", totalAmount=" + totalAmount + ", " + super.toString()
+ "]";
return "RedpacketSendResult [outTradeNo=" + outTradeNo + ", openId="
+ openId + ", totalAmount=" + totalAmount + ", "
+ super.toString() + "]";
}
}
}

View File

@ -25,7 +25,7 @@ import com.foxinmy.weixin4j.xml.ListsuffixResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RefundDetail extends ApiResult {
public class RefundDetail extends MerchantResult {
private static final long serialVersionUID = -3687863914168618620L;

View File

@ -21,7 +21,7 @@ import com.foxinmy.weixin4j.xml.ListsuffixResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RefundRecord extends ApiResult {
public class RefundRecord extends MerchantResult {
private static final long serialVersionUID = -2971132874939642721L;

View File

@ -17,7 +17,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
* @since JDK 1.6
* @see
*/
public class SettlementRecord extends ApiResult {
public class SettlementRecord extends MerchantResult {
private static final long serialVersionUID = 7952659545609519979L;
@ -268,6 +268,6 @@ public class SettlementRecord extends ApiResult {
+ unSettleFee + ", settleFeeType=" + settleFeeType
+ ", payFee=" + payFee + ", refundFee=" + refundFee
+ ", payNetFee=" + payNetFee + ", poundageFee=" + poundageFee
+ "]";
+ ", " + super.toString() + "]";
}
}

View File

@ -27,7 +27,7 @@ public class WAPPayRequest extends AbstractPayRequest {
}
@Override
public TradeType getTradeType() {
public TradeType getPaymentType() {
return TradeType.WAP;
}
@ -36,8 +36,8 @@ public class WAPPayRequest extends AbstractPayRequest {
*/
@Override
public PayRequest toRequestObject() {
PayRequest payRequest = new PayRequest(getPayAccount().getId(),
getTradeType().name());
PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
getPaymentType().name());
payRequest.setPrepayId(getPrePayId());
return payRequest;
}
@ -47,7 +47,7 @@ public class WAPPayRequest extends AbstractPayRequest {
PayRequest payRequest = toRequestObject();
String original = MapUtil.toJoinString(payRequest, true, true);
String sign = DigestUtil.MD5(
String.format("%s&key=%s", original, getPayAccount()
String.format("%s&key=%s", original, getPaymentAccount()
.getPaySignKey())).toUpperCase();
return String.format("weixin://wap/pay?%s",
URLEncodingUtil.encoding(

View File

@ -44,11 +44,11 @@ public class CashTest extends PayTest {
@Test
public void sendCorpPayment() throws WeixinException, IOException {
CorpPayment payment = new CorpPayment("MP001",
CorpPayment payment = new CorpPayment(ACCOUNT, "MP001",
"ofW1gwok9vZIyle0YbA-eQe83Uk8",
MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1");
CorpPaymentResult result = PAY.sendCorpPayment(new FileInputStream(caFile),
payment);
CorpPaymentResult result = PAY.sendCorpPayment(new FileInputStream(
caFile), payment);
System.err.println(result);
}

View File

@ -14,8 +14,8 @@ import com.foxinmy.weixin4j.exception.WeixinPayException;
import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.WeixinPayProxy;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.payment.mch.Order;
import com.foxinmy.weixin4j.payment.mch.PrePay;
import com.foxinmy.weixin4j.payment.mch.RefundRecord;
@ -49,7 +49,7 @@ public class PayTest {
/**
* 商户证书文件
*/
protected File caFile = new File("证书文件:*.p12");
protected File caFile = new File("/Users/jy/Downloads/test.sql");
@Test
public void queryOrder() throws WeixinException {
@ -107,10 +107,9 @@ public class PayTest {
@Test
public void nativePay() throws WeixinException {
MchPayPackage payPackageV3 = new MchPayPackage(ACCOUNT,
"oyFLst1bqtuTcxK-ojF8hOGtLQao", "native测试", "T0001", 0.1d,
"notify_url", "127.0.0.1", TradeType.NATIVE);
payPackageV3.setProductId("0001");
MchPayPackage payPackageV3 = new MchPayPackage(ACCOUNT, "native测试",
"T0001", 0.1d, "notify_url", "127.0.0.1", TradeType.NATIVE,
null, null, "productId", null);
PrePay prePay = null;
try {
prePay = PAY.createPrePay(payPackageV3);
@ -122,7 +121,7 @@ public class PayTest {
@Test
public void closeOrder() throws WeixinException {
ApiResult result = PAY.closeOrder("D111");
MerchantResult result = PAY.closeOrder("D111");
System.err.println(result);
String sign = result.getSign();
result.setSign(null);