修复备注链接不正确

This commit is contained in:
jinyu 2016-03-28 18:15:32 +08:00
parent 7f2c1ddaab
commit 9290eb2436
20 changed files with 1020 additions and 1041 deletions

View File

@ -32,10 +32,12 @@ import com.foxinmy.weixin4j.xml.XmlStream;
* @author jy * @author jy
* @date 2015年3月28日 * @date 2015年3月28日
* @since JDK 1.6 * @since JDK 1.6
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_1">现金红包</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_1">
* @see <a * 现金红包</a>
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a> * @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_1">
* 企业付款</a>
*/ */
public class CashApi extends MchApi { public class CashApi extends MchApi {
@ -53,12 +55,15 @@ public class CashApi extends MchApi {
* @return 发放结果 * @return 发放结果
* @see com.foxinmy.weixin4j.payment.mch.Redpacket * @see com.foxinmy.weixin4j.payment.mch.Redpacket
* @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult * @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5">发放红包接口说明</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5">
* 发放现金红包接口</a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_5">
* 发放裂变红包接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public RedpacketSendResult sendRedpack(InputStream certificate, public RedpacketSendResult sendRedpack(InputStream certificate, Redpacket redpacket) throws WeixinException {
Redpacket redpacket) throws WeixinException {
redpacket.declareWeixinPayAccount(weixinAccount); redpacket.declareWeixinPayAccount(weixinAccount);
JSONObject obj = (JSONObject) JSON.toJSON(redpacket); JSONObject obj = (JSONObject) JSON.toJSON(redpacket);
obj.put("wxappid", obj.remove("appid")); obj.put("wxappid", obj.remove("appid"));
@ -66,9 +71,8 @@ public class CashApi extends MchApi {
String param = XmlStream.map2xml(obj); String param = XmlStream.map2xml(obj);
WeixinResponse response = null; WeixinResponse response = null;
try { try {
response = createSSLRequestExecutor(certificate) response = createSSLRequestExecutor(certificate).post(redpacket.getTotalNum() > 1
.post(redpacket.getTotalNum() > 1 ? getRequestUri("groupredpack_send_uri") ? getRequestUri("groupredpack_send_uri") : getRequestUri("redpack_send_uri"), param);
: getRequestUri("redpack_send_uri"), param);
} finally { } finally {
if (certificate != null) { if (certificate != null) {
try { try {
@ -78,9 +82,8 @@ public class CashApi extends MchApi {
} }
} }
} }
String text = response.getAsString() String text = response.getAsString().replaceFirst("<wxappid>", "<appid>").replaceFirst("</wxappid>",
.replaceFirst("<wxappid>", "<appid>") "</appid>");
.replaceFirst("</wxappid>", "</appid>");
return XmlStream.fromXML(text, RedpacketSendResult.class); return XmlStream.fromXML(text, RedpacketSendResult.class);
} }
@ -93,12 +96,15 @@ public class CashApi extends MchApi {
* 商户发放红包的商户订单号 * 商户发放红包的商户订单号
* @return 红包记录 * @return 红包记录
* @see com.foxinmy.weixin4j.payment.mch.RedpacketRecord * @see com.foxinmy.weixin4j.payment.mch.RedpacketRecord
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_6">查询红包接口说明</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_7&index=6">
* 查询现金红包接口</a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_6">
* 查询裂变红包接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public RedpacketRecord queryRedpack(InputStream certificate, public RedpacketRecord queryRedpack(InputStream certificate, String outTradeNo) throws WeixinException {
String outTradeNo) throws WeixinException {
Map<String, String> para = createBaseRequestMap(null); Map<String, String> para = createBaseRequestMap(null);
para.put("bill_type", "MCHT"); para.put("bill_type", "MCHT");
para.put("mch_billno", outTradeNo); para.put("mch_billno", outTradeNo);
@ -106,8 +112,7 @@ public class CashApi extends MchApi {
String param = XmlStream.map2xml(para); String param = XmlStream.map2xml(para);
WeixinResponse response = null; WeixinResponse response = null;
try { try {
response = createSSLRequestExecutor(certificate).post( response = createSSLRequestExecutor(certificate).post(getRequestUri("redpack_query_uri"), param);
getRequestUri("redpack_query_uri"), param);
} finally { } finally {
if (certificate != null) { if (certificate != null) {
try { try {
@ -131,12 +136,12 @@ public class CashApi extends MchApi {
* @return 付款结果 * @return 付款结果
* @see com.foxinmy.weixin4j.payment.mch.CorpPayment * @see com.foxinmy.weixin4j.payment.mch.CorpPayment
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2">
* 企业付款接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CorpPaymentResult sendCorpPayment(InputStream certificate, public CorpPaymentResult sendCorpPayment(InputStream certificate, CorpPayment payment) throws WeixinException {
CorpPayment payment) throws WeixinException {
payment.declareWeixinPayAccount(weixinAccount); payment.declareWeixinPayAccount(weixinAccount);
JSONObject obj = (JSONObject) JSON.toJSON(payment); JSONObject obj = (JSONObject) JSON.toJSON(payment);
obj.put("mchid", obj.remove("mch_id")); obj.put("mchid", obj.remove("mch_id"));
@ -145,8 +150,7 @@ public class CashApi extends MchApi {
String param = XmlStream.map2xml(obj); String param = XmlStream.map2xml(obj);
WeixinResponse response = null; WeixinResponse response = null;
try { try {
response = createSSLRequestExecutor(certificate).post( response = createSSLRequestExecutor(certificate).post(getRequestUri("corppayment_send_uri"), param);
getRequestUri("corppayment_send_uri"), param);
} finally { } finally {
if (certificate != null) { if (certificate != null) {
try { try {
@ -156,10 +160,8 @@ public class CashApi extends MchApi {
} }
} }
} }
String text = response.getAsString() String text = response.getAsString().replaceFirst("<mch_appid>", "<appid>")
.replaceFirst("<mch_appid>", "<appid>") .replaceFirst("</mch_appid>", "</appid>").replaceFirst("<mchid>", "<mch_id>")
.replaceFirst("</mch_appid>", "</appid>")
.replaceFirst("<mchid>", "<mch_id>")
.replaceFirst("</mchid>", "</mch_id>"); .replaceFirst("</mchid>", "</mch_id>");
return XmlStream.fromXML(text, CorpPaymentResult.class); return XmlStream.fromXML(text, CorpPaymentResult.class);
} }
@ -173,12 +175,12 @@ public class CashApi extends MchApi {
* 商户调用企业付款API时使用的商户订单号 * 商户调用企业付款API时使用的商户订单号
* @return 付款记录 * @return 付款记录
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_3">企业付款查询</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3">
* 企业付款查询接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CorpPaymentRecord queryCorpPayment(InputStream certificate, public CorpPaymentRecord queryCorpPayment(InputStream certificate, String outTradeNo) throws WeixinException {
String outTradeNo) throws WeixinException {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("nonce_str", RandomUtil.generateString(16)); obj.put("nonce_str", RandomUtil.generateString(16));
obj.put("mch_id", weixinAccount.getMchId()); obj.put("mch_id", weixinAccount.getMchId());
@ -188,8 +190,7 @@ public class CashApi extends MchApi {
String param = XmlStream.map2xml(obj); String param = XmlStream.map2xml(obj);
WeixinResponse response = null; WeixinResponse response = null;
try { try {
response = createSSLRequestExecutor(certificate).post( response = createSSLRequestExecutor(certificate).post(getRequestUri("corppayment_query_uri"), param);
getRequestUri("corppayment_query_uri"), param);
} finally { } finally {
if (certificate != null) { if (certificate != null) {
try { try {
@ -217,11 +218,12 @@ public class CashApi extends MchApi {
* @return 结算金额记录 * @return 结算金额记录
* @throws WeixinException * @throws WeixinException
* @see com.foxinmy.weixin4j.payment.mch.SettlementRecord * @see com.foxinmy.weixin4j.payment.mch.SettlementRecord
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_14&index=7">查询结算资金</a> * "https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_14&index=7">
* 查询结算资金接口</a>
*/ */
public SettlementRecord querySettlement(boolean status, Pageable pageable, public SettlementRecord querySettlement(boolean status, Pageable pageable, Date start, Date end)
Date start, Date end) throws WeixinException { throws WeixinException {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("nonce_str", RandomUtil.generateString(16)); obj.put("nonce_str", RandomUtil.generateString(16));
obj.put("mch_id", weixinAccount.getMchId()); obj.put("mch_id", weixinAccount.getMchId());
@ -237,8 +239,7 @@ public class CashApi extends MchApi {
} }
obj.put("sign", weixinSignature.sign(obj)); obj.put("sign", weixinSignature.sign(obj));
String param = XmlStream.map2xml(obj); String param = XmlStream.map2xml(obj);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("settlement_query_uri"), param);
getRequestUri("settlement_query_uri"), param);
return response.getAsObject(new TypeReference<SettlementRecord>() { return response.getAsObject(new TypeReference<SettlementRecord>() {
}); });
} }
@ -252,11 +253,11 @@ public class CashApi extends MchApi {
* 日期 不填则默认当天 * 日期 不填则默认当天
* @return 汇率 例如美元兑换人民币的比例为6.5 * @return 汇率 例如美元兑换人民币的比例为6.5
* @throws WeixinException * @throws WeixinException
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_15&index=8">查询汇率</a> * "https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_15&index=8">
* 查询汇率接口</a>
*/ */
public double queryExchageRate(CurrencyType currencyType, Date date) public double queryExchageRate(CurrencyType currencyType, Date date) throws WeixinException {
throws WeixinException {
if (date == null) { if (date == null) {
date = new Date(); date = new Date();
} }
@ -268,10 +269,8 @@ public class CashApi extends MchApi {
obj.put("date", DateUtil.fortmat2yyyyMMdd(date)); obj.put("date", DateUtil.fortmat2yyyyMMdd(date));
obj.put("sign", weixinSignature.sign(obj)); obj.put("sign", weixinSignature.sign(obj));
String param = XmlStream.map2xml(obj); String param = XmlStream.map2xml(obj);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("exchagerate_query_uri"), param);
getRequestUri("exchagerate_query_uri"), param); BigDecimal rate = new BigDecimal(XmlStream.xml2map(response.getAsString()).get("rate"));
BigDecimal rate = new BigDecimal(XmlStream.xml2map(
response.getAsString()).get("rate"));
return rate.divide(new BigDecimal(100000000d)).doubleValue(); return rate.divide(new BigDecimal(100000000d)).doubleValue();
} }
} }

View File

@ -21,7 +21,7 @@ import com.foxinmy.weixin4j.xml.XmlStream;
* @author jy * @author jy
* @date 2015年3月25日 * @date 2015年3月25日
* @since JDK 1.6 * @since JDK 1.6
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php">代金券文档</a> * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_1">代金券</a>
*/ */
public class CouponApi extends MchApi { public class CouponApi extends MchApi {
@ -45,7 +45,7 @@ public class CouponApi extends MchApi {
* @return 发放结果 * @return 发放结果
* @see com.foxinmy.weixin4j.payment.coupon.CouponResult * @see com.foxinmy.weixin4j.payment.coupon.CouponResult
* @see <a * @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php?chapter=12_3">发放代金券接口</a> * href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_3">发放代金券接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CouponResult sendCoupon(InputStream certificate, public CouponResult sendCoupon(InputStream certificate,
@ -91,7 +91,7 @@ public class CouponApi extends MchApi {
* @return 代金券批次信息 * @return 代金券批次信息
* @see com.foxinmy.weixin4j.payment.coupon.CouponStock * @see com.foxinmy.weixin4j.payment.coupon.CouponStock
* @see <a * @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php?chapter=12_4">查询代金券批次信息</a> * href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_4">查询代金券批次信息接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CouponStock queryCouponStock(String couponStockId) public CouponStock queryCouponStock(String couponStockId)
@ -114,7 +114,7 @@ public class CouponApi extends MchApi {
* @return 代金券详细信息 * @return 代金券详细信息
* @see com.foxinmy.weixin4j.payment.coupon.CouponDetail * @see com.foxinmy.weixin4j.payment.coupon.CouponDetail
* @see <a * @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php?chapter=12_5">查询代金券详细信息</a> * href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_5">查询代金券详细信息接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CouponDetail queryCouponDetail(String couponId) public CouponDetail queryCouponDetail(String couponId)

View File

@ -38,7 +38,7 @@ public class CustomsApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrder * @see com.foxinmy.weixin4j.payment.mch.CustomsOrder
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a> * href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息提交接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder)
@ -64,7 +64,7 @@ public class CustomsApi extends MchApi {
* @return 报关记录 * @return 报关记录
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a> * href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息查询接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery,

View File

@ -51,13 +51,12 @@ import com.foxinmy.weixin4j.xml.ListsuffixResultDeserializer;
import com.foxinmy.weixin4j.xml.XmlStream; import com.foxinmy.weixin4j.xml.XmlStream;
/** /**
* (商户平台版)支付API * 支付API
* *
* @className Pay3Api * @className PayApi
* @author jy * @author jy
* @date 2014年10月28日 * @date 2014年10月28日
* @since JDK 1.6 * @since JDK 1.6
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/index.html">商户平台API</a>
*/ */
public class PayApi extends MchApi { public class PayApi extends MchApi {
@ -74,16 +73,16 @@ public class PayApi extends MchApi {
* 包含订单信息的对象 * 包含订单信息的对象
* @see com.foxinmy.weixin4j.payment.mch.MchPayPackage * @see com.foxinmy.weixin4j.payment.mch.MchPayPackage
* @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口
* </a>
* @return 预支付对象 * @return 预支付对象
*/ */
public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException { public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException {
payPackage.declareWeixinPayAccount(weixinAccount); payPackage.declareWeixinPayAccount(weixinAccount);
payPackage.setSign(weixinSignature.sign(payPackage)); payPackage.setSign(weixinSignature.sign(payPackage));
String payJsRequestXml = XmlStream.toXML(payPackage); String payJsRequestXml = XmlStream.toXML(payPackage);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("order_create_uri"), payJsRequestXml);
getRequestUri("order_create_uri"), payJsRequestXml);
return response.getAsObject(new TypeReference<PrePay>() { return response.getAsObject(new TypeReference<PrePay>() {
}); });
} }
@ -101,8 +100,7 @@ public class PayApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(MchPayPackage payPackage) public MchPayRequest createPayRequest(MchPayPackage payPackage) throws WeixinException {
throws WeixinException {
PrePay prePay = createPrePay(payPackage); PrePay prePay = createPrePay(payPackage);
String tradeType = payPackage.getTradeType(); String tradeType = payPackage.getTradeType();
if (TradeType.APP.name().equalsIgnoreCase(tradeType)) { if (TradeType.APP.name().equalsIgnoreCase(tradeType)) {
@ -110,17 +108,14 @@ public class PayApi extends MchApi {
} else if (TradeType.JSAPI.name().equalsIgnoreCase(tradeType)) { } else if (TradeType.JSAPI.name().equalsIgnoreCase(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().equalsIgnoreCase(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().equalsIgnoreCase(tradeType)) {
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount); return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
} else if (TradeType.MICROPAY.name().equalsIgnoreCase(tradeType)) { } else if (TradeType.MICROPAY.name().equalsIgnoreCase(tradeType)) {
String para = XmlStream.toXML(payPackage); String para = XmlStream.toXML(payPackage);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("micropay_uri"), para);
getRequestUri("micropay_uri"), para); MICROPayRequest microPayRequest = response.getAsObject(new TypeReference<MICROPayRequest>() {
MICROPayRequest microPayRequest = response });
.getAsObject(new TypeReference<MICROPayRequest>() {
});
microPayRequest.setPaymentAccount(weixinAccount); microPayRequest.setPaymentAccount(weixinAccount);
return microPayRequest; return microPayRequest;
} else { } else {
@ -169,15 +164,12 @@ public class PayApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(String body, String detail, public MchPayRequest createPayRequest(String body, String detail, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, TradeType tradeType, String openId, String productId, String attach,
String createIp, TradeType tradeType, String openId, Date timeStart, Date timeExpire, String goodsTag, String limitPay, String subOpenId)
String productId, String attach, Date timeStart, Date timeExpire,
String goodsTag, String limitPay, String subOpenId)
throws WeixinException { throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, tradeType, openId,
totalFee, notifyUrl, createIp, tradeType, openId, null, null, productId, attach);
productId, attach);
payPackage.setTimeStart(timeStart); payPackage.setTimeStart(timeStart);
payPackage.setTimeExpire(timeExpire); payPackage.setTimeExpire(timeExpire);
payPackage.setGoodsTag(goodsTag); payPackage.setGoodsTag(goodsTag);
@ -208,12 +200,10 @@ public class PayApi extends MchApi {
* @return JSAPI支付对象 * @return JSAPI支付对象
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createJSPayRequest(String openId, String body, public MchPayRequest createJSPayRequest(String openId, String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, String attach) throws WeixinException {
String createIp, String attach) throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, TradeType.JSAPI,
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, openId, null, null, attach);
totalFee, notifyUrl, createIp, TradeType.JSAPI, openId, null,
null, attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -222,18 +212,24 @@ public class PayApi extends MchApi {
* 生成编辑地址请求 * 生成编辑地址请求
* </p> * </p>
* *
* err_msg edit_address:ok获取编辑收货地址成功</br> edit_address:fail获取编辑收货地址失败</br> * err_msg edit_address:ok获取编辑收货地址成功</br>
* userName 收货人姓名</br> telNumber 收货人电话</br> addressPostalCode 邮编</br> * edit_address:fail获取编辑收货地址失败</br>
* proviceFirstStageName 国标收货地址第一级地址</br> addressCitySecondStageName * userName 收货人姓名</br>
* 国标收货地址第二级地址</br> addressCountiesThirdStageName 国标收货地址第三级地址</br> * telNumber 收货人电话</br>
* addressDetailInfo 详细收货地址信息</br> nationalCode 收货地址国家码</br> * addressPostalCode 邮编</br>
* proviceFirstStageName 国标收货地址第一级地址</br>
* addressCitySecondStageName 国标收货地址第二级地址</br>
* addressCountiesThirdStageName 国标收货地址第三级地址</br>
* addressDetailInfo 详细收货地址信息</br>
* nationalCode 收货地址国家码</br>
* *
* @param url * @param url
* 当前访问页的URL * 当前访问页的URL
* @param oauthToken * @param oauthToken
* oauth授权时产生的token * oauth授权时产生的token
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_8&index=7">收货地址共享</a> * "https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_8&index=7">
* 收货地址共享</a>
* @return 编辑地址请求JSON串 * @return 编辑地址请求JSON串
*/ */
public String createAddressRequestJSON(String url, String oauthToken) { public String createAddressRequestJSON(String url, String oauthToken) {
@ -258,9 +254,12 @@ public class PayApi extends MchApi {
* @param productId * @param productId
* 与订单ID等价 * 与订单ID等价
* @return 支付链接 * @return 支付链接
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href=
* @see <a * "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a> * </a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一
* </a>
*/ */
public String createNativePayRequestURL(String productId) { public String createNativePayRequestURL(String productId) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
@ -272,9 +271,8 @@ public class PayApi extends MchApi {
map.put("nonce_str", noncestr); map.put("nonce_str", noncestr);
map.put("product_id", productId); map.put("product_id", productId);
String sign = weixinSignature.sign(map); String sign = weixinSignature.sign(map);
return String.format(getRequestUri("native_pay_uri"), sign, return String.format(getRequestUri("native_pay_uri"), sign, weixinAccount.getId(), weixinAccount.getMchId(),
weixinAccount.getId(), weixinAccount.getMchId(), productId, productId, timestamp, noncestr);
timestamp, noncestr);
} }
/** /**
@ -296,17 +294,18 @@ public class PayApi extends MchApi {
* 附加数据 非必填 * 附加数据 非必填
* @return Native回调对象 * @return Native回调对象
* @see com.foxinmy.weixin4j.payment.mch.NativePayResponse * @see com.foxinmy.weixin4j.payment.mch.NativePayResponse
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href=
* @see <a * "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a> * </a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一
* </a>
* @throws WeixinException * @throws WeixinException
*/ */
public NativePayResponse createNativePayResponse(String productId, public NativePayResponse createNativePayResponse(String productId, String body, String outTradeNo, double totalFee,
String body, String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, String attach) throws WeixinException {
String createIp, String attach) throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE,
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, null, null, productId, attach);
totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
productId, attach);
PrePay prePay = createPrePay(payPackage); PrePay prePay = createPrePay(payPackage);
return new NativePayResponse(weixinAccount, prePay.getPrepayId()); return new NativePayResponse(weixinAccount, prePay.getPrepayId());
} }
@ -330,17 +329,18 @@ public class PayApi extends MchApi {
* 附加数据 非必填 * 附加数据 非必填
* @return Native支付对象 * @return Native支付对象
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest * @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href=
* @see <a * "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二</a> * </a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二
* </a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createNativePayRequest(String productId, String body, public MchPayRequest createNativePayRequest(String productId, String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, String attach) throws WeixinException {
String createIp, String attach) throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE,
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, null, null, productId, attach);
totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
productId, attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -361,16 +361,15 @@ public class PayApi extends MchApi {
* 附加数据 非必填 * 附加数据 非必填
* @return APP支付对象 * @return APP支付对象
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=8_1">APP支付</a> * "https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">
* APP支付</a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createAppPayRequest(String body, String outTradeNo, public MchPayRequest createAppPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl,
double totalFee, String notifyUrl, String createIp, String attach) String createIp, String attach) throws WeixinException {
throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, TradeType.APP,
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, null, null, null, attach);
totalFee, notifyUrl, createIp, TradeType.APP, null, null, null,
attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -391,16 +390,15 @@ public class PayApi extends MchApi {
* 附加数据 非必填 * 附加数据 非必填
* @return WAP支付对象 * @return WAP支付对象
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a> * "https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付
* </a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createWAPPayRequest(String body, String outTradeNo, public MchPayRequest createWAPPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl,
double totalFee, String notifyUrl, String createIp, String attach) String createIp, String attach) throws WeixinException {
throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, TradeType.WAP,
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, null, null, null, attach);
totalFee, notifyUrl, createIp, TradeType.WAP, null, null, null,
attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -422,24 +420,25 @@ public class PayApi extends MchApi {
* @return 支付的订单信息 * @return 支付的订单信息
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest
* @see com.foxinmy.weixin4j.payment.mch.Order * @see com.foxinmy.weixin4j.payment.mch.Order
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">提交被扫支付API</a> * "http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">
* 提交被扫支付API</a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createMICROPayRequest(String authCode, String body, public MchPayRequest createMICROPayRequest(String authCode, String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String createIp, String attach) String createIp, String attach) throws WeixinException {
throws WeixinException { MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, null, createIp, TradeType.MICROPAY,
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, null, null, null, attach);
totalFee, null, createIp, TradeType.MICROPAY, null, null, null,
attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
/** /**
* 订单查询 * 订单查询
* <p> * <p>
* 当商户后台网络服务器等出现异常商户系统最终未接收到支付通知</br> 调用支付接口后返回系统错误或未知交易状态情况</br> * 当商户后台网络服务器等出现异常商户系统最终未接收到支付通知</br>
* 调用被扫支付API返回USERPAYING的状态</br> 调用关单或撤销接口API之前需确认支付状态 * 调用支付接口后返回系统错误或未知交易状态情况</br>
* 调用被扫支付API返回USERPAYING的状态</br>
* 调用关单或撤销接口API之前需确认支付状态
* </P> * </P>
* *
* @param idQuery * @param idQuery
@ -447,8 +446,9 @@ public class PayApi extends MchApi {
* transaction_id> out_trade_no * transaction_id> out_trade_no
* @return 订单信息 * @return 订单信息
* @see com.foxinmy.weixin4j.payment.mch.Order * @see com.foxinmy.weixin4j.payment.mch.Order
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2">订单查询API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2">
* 订单查询API</a>
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
@ -456,10 +456,8 @@ public class PayApi extends MchApi {
Map<String, String> map = createBaseRequestMap(idQuery); Map<String, String> map = createBaseRequestMap(idQuery);
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("order_query_uri"), param);
getRequestUri("order_query_uri"), param); return ListsuffixResultDeserializer.deserialize(response.getAsString(), Order.class);
return ListsuffixResultDeserializer.deserialize(response.getAsString(),
Order.class);
} }
/** /**
@ -491,14 +489,14 @@ public class PayApi extends MchApi {
* 操作员帐号, 默认为商户号 * 操作员帐号, 默认为商户号
* @return 退款申请结果 * @return 退款申请结果
* @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see com.foxinmy.weixin4j.payment.mch.RefundResult
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">申请退款API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">
* 申请退款API</a>
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, String outRefundNo, double totalFee,
String outRefundNo, double totalFee, double refundFee, double refundFee, CurrencyType refundFeeType, String opUserId) throws WeixinException {
CurrencyType refundFeeType, String opUserId) throws WeixinException {
WeixinResponse response = null; WeixinResponse response = null;
try { try {
Map<String, String> map = createBaseRequestMap(idQuery); Map<String, String> map = createBaseRequestMap(idQuery);
@ -515,8 +513,7 @@ public class PayApi extends MchApi {
map.put("refund_fee_type", refundFeeType.name()); map.put("refund_fee_type", refundFeeType.name());
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
response = createSSLRequestExecutor(certificate).post( response = createSSLRequestExecutor(certificate).post(getRequestUri("refund_apply_uri"), param);
getRequestUri("refund_apply_uri"), param);
} finally { } finally {
if (certificate != null) { if (certificate != null) {
try { try {
@ -544,17 +541,18 @@ public class PayApi extends MchApi {
* 订单总金额,单位为元 * 订单总金额,单位为元
* @see {@link #applyRefund(InputStream, IdQuery, String, double, double,CurrencyType, String)} * @see {@link #applyRefund(InputStream, IdQuery, String, double, double,CurrencyType, String)}
*/ */
public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, String outRefundNo, double totalFee)
String outRefundNo, double totalFee) throws WeixinException { throws WeixinException {
return applyRefund(certificate, idQuery, outRefundNo, totalFee, return applyRefund(certificate, idQuery, outRefundNo, totalFee, totalFee, null, null);
totalFee, null, null);
} }
/** /**
* 冲正订单(需要证书)</br> 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br> 接口逻辑: * 冲正订单(需要证书)</br>
* 付失败的关单,支付成功的撤销支付</br> <font color="red">7天以内的单可撤销,其他正常支付的单 * 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br>
* 如需实现相同功能请调用退款接口</font></br> <font * 接口逻辑: 付失败的关单,支付成功的撤销支付</br>
* color="red">调用扣款接口后请勿立即调用撤销,需要等待5秒以上先调用查单接口,如果没有确切的返回,再调用撤销</font></br> * <font color="red">7天以内的单可撤销,其他正常支付的单 如需实现相同功能请调用退款接口</font></br>
* <font color="red">调用扣款接口后请勿立即调用撤销,需要等待5秒以上先调用查单接口,如果没有确切的返回,再调用撤销</font>
* </br>
* *
* @param certificate * @param certificate
* 后缀为*.p12的证书文件 * 后缀为*.p12的证书文件
@ -565,14 +563,13 @@ public class PayApi extends MchApi {
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) throws WeixinException {
throws WeixinException {
try { try {
Map<String, String> map = createBaseRequestMap(idQuery); Map<String, String> map = createBaseRequestMap(idQuery);
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = createSSLRequestExecutor(certificate) WeixinResponse response = createSSLRequestExecutor(certificate).post(getRequestUri("order_reverse_uri"),
.post(getRequestUri("order_reverse_uri"), param); param);
return response.getAsObject(new TypeReference<MerchantResult>() { return response.getAsObject(new TypeReference<MerchantResult>() {
}); });
} finally { } finally {
@ -594,8 +591,9 @@ public class PayApi extends MchApi {
* 具有native标识的支付URL * 具有native标识的支付URL
* @return 转换后的短链接 * @return 转换后的短链接
* @throws WeixinException * @throws WeixinException
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_9">转换短链接API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_9">
* 转换短链接API</a>
*/ */
public String getShorturl(String url) throws WeixinException { public String getShorturl(String url) throws WeixinException {
Map<String, String> map = createBaseRequestMap(null); Map<String, String> map = createBaseRequestMap(null);
@ -606,8 +604,7 @@ public class PayApi extends MchApi {
} }
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("longurl_convert_uri"), param);
getRequestUri("longurl_convert_uri"), param);
map = XmlStream.xml2map(response.getAsString()); map = XmlStream.xml2map(response.getAsString());
return map.get("short_url"); return map.get("short_url");
} }
@ -624,16 +621,15 @@ public class PayApi extends MchApi {
* @return 处理结果 * @return 处理结果
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3">关闭订单API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3">
* 关闭订单API</a>
*/ */
public MerchantResult closeOrder(String outTradeNo) throws WeixinException { public MerchantResult closeOrder(String outTradeNo) throws WeixinException {
Map<String, String> map = createBaseRequestMap(new IdQuery(outTradeNo, Map<String, String> map = createBaseRequestMap(new IdQuery(outTradeNo, IdType.TRADENO));
IdType.TRADENO));
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("order_close_uri"), param);
getRequestUri("order_close_uri"), param);
return response.getAsObject(new TypeReference<MerchantResult>() { return response.getAsObject(new TypeReference<MerchantResult>() {
}); });
} }
@ -654,12 +650,12 @@ public class PayApi extends MchApi {
* 对账单保存路径 * 对账单保存路径
* @return excel表格 * @return excel表格
* @since V3 * @since V3
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6">下载对账单API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6">
* 下载对账单API</a>
* @throws WeixinException * @throws WeixinException
*/ */
public File downloadBill(Date billDate, BillType billType, String billPath) public File downloadBill(Date billDate, BillType billType, String billPath) throws WeixinException {
throws WeixinException {
if (billDate == null) { if (billDate == null) {
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
now.add(Calendar.DAY_OF_MONTH, -1); now.add(Calendar.DAY_OF_MONTH, -1);
@ -669,8 +665,8 @@ public class PayApi extends MchApi {
billType = BillType.ALL; billType = BillType.ALL;
} }
String formatBillDate = DateUtil.fortmat2yyyyMMdd(billDate); String formatBillDate = DateUtil.fortmat2yyyyMMdd(billDate);
String fileName = String.format("%s_%s_%s.txt", formatBillDate, String fileName = String.format("%s_%s_%s.txt", formatBillDate, billType.name().toLowerCase(),
billType.name().toLowerCase(), weixinAccount.getId()); weixinAccount.getId());
File file = new File(String.format("%s/%s", billPath, fileName)); File file = new File(String.format("%s/%s", billPath, fileName));
if (file.exists()) { if (file.exists()) {
return file; return file;
@ -680,16 +676,14 @@ public class PayApi extends MchApi {
map.put("bill_type", billType.name()); map.put("bill_type", billType.name());
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("downloadbill_uri"), param);
getRequestUri("downloadbill_uri"), param);
BufferedReader reader = null; BufferedReader reader = null;
BufferedWriter writer = null; BufferedWriter writer = null;
try { try {
writer = new BufferedWriter(new OutputStreamWriter( writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Consts.GBK));
new FileOutputStream(file), Consts.GBK)); reader = new BufferedReader(
reader = new BufferedReader(new InputStreamReader( new InputStreamReader(response.getBody(), com.foxinmy.weixin4j.model.Consts.GBK));
response.getBody(), com.foxinmy.weixin4j.model.Consts.GBK));
String line = null; String line = null;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
writer.write(line); writer.write(line);
@ -726,8 +720,9 @@ public class PayApi extends MchApi {
* @return 退款记录 * @return 退款记录
* @see com.foxinmy.weixin4j.payment.mch.RefundRecord * @see com.foxinmy.weixin4j.payment.mch.RefundRecord
* @see com.foxinmy.weixin4j.payment.mch.RefundDetail * @see com.foxinmy.weixin4j.payment.mch.RefundDetail
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5">退款查询API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5">
* 退款查询API</a>
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
@ -735,10 +730,8 @@ public class PayApi extends MchApi {
Map<String, String> map = createBaseRequestMap(idQuery); Map<String, String> map = createBaseRequestMap(idQuery);
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("refund_query_uri"), param);
getRequestUri("refund_query_uri"), param); return ListsuffixResultDeserializer.deserialize(response.getAsString(), RefundRecord.class);
return ListsuffixResultDeserializer.deserialize(response.getAsString(),
RefundRecord.class);
} }
/** /**
@ -759,13 +752,13 @@ public class PayApi extends MchApi {
* 调用接口返回的基本数据 * 调用接口返回的基本数据
* @return 处理结果 * @return 处理结果
* @throws WeixinException * @throws WeixinException
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_8">接口测试上报API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_8">
* 接口测试上报API</a>
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public XmlResult interfaceReport(String interfaceUrl, int executeTime, public XmlResult interfaceReport(String interfaceUrl, int executeTime, String outTradeNo, String ip, Date time,
String outTradeNo, String ip, Date time, XmlResult returnXml) XmlResult returnXml) throws WeixinException {
throws WeixinException {
Map<String, String> map = createBaseRequestMap(null); Map<String, String> map = createBaseRequestMap(null);
map.put("interface_url", interfaceUrl); map.put("interface_url", interfaceUrl);
map.put("execute_time_", Integer.toString(executeTime)); map.put("execute_time_", Integer.toString(executeTime));
@ -775,8 +768,7 @@ public class PayApi extends MchApi {
map.putAll((Map<String, String>) JSON.toJSON(returnXml)); map.putAll((Map<String, String>) JSON.toJSON(returnXml));
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("interface_report_uri"), param);
getRequestUri("interface_report_uri"), param);
return response.getAsXmlResult(); return response.getAsXmlResult();
} }
@ -787,8 +779,9 @@ public class PayApi extends MchApi {
* 扫码支付授权码设备读取用户微信中的条码或者二维码信息 * 扫码支付授权码设备读取用户微信中的条码或者二维码信息
* @return 查询结果 * @return 查询结果
* @see com.foxinmy.weixin4j.payment.mch.OpenIdResult * @see com.foxinmy.weixin4j.payment.mch.OpenIdResult
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9">授权码查询OPENID</a> * "https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9">
* 授权码查询OPENID</a>
* @throws WeixinException * @throws WeixinException
*/ */
public OpenIdResult authCode2openId(String authCode) throws WeixinException { public OpenIdResult authCode2openId(String authCode) throws WeixinException {
@ -796,8 +789,7 @@ public class PayApi extends MchApi {
map.put("auth_code", authCode); map.put("auth_code", authCode);
map.put("sign", weixinSignature.sign(map)); map.put("sign", weixinSignature.sign(map));
String param = XmlStream.map2xml(map); String param = XmlStream.map2xml(map);
WeixinResponse response = weixinExecutor.post( WeixinResponse response = weixinExecutor.post(getRequestUri("authcode_openid_uri"), param);
getRequestUri("authcode_openid_uri"), param);
return response.getAsObject(new TypeReference<OpenIdResult>() { return response.getAsObject(new TypeReference<OpenIdResult>() {
}); });
} }

View File

@ -12,7 +12,7 @@ import com.alibaba.fastjson.annotation.JSONField;
* @date 2014年9月24日 * @date 2014年9月24日
* @since JDK 1.6 * @since JDK 1.6
* @see <a * @see <a
* href="http://mp.weixin.qq.com/wiki/17/fa4e1434e57290788bde25603fa2fcbd.html">公众平台全局返回码说明</a> * href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234&token=&lang=zh_CN">公众平台全局返回码说明</a>
* @see <a * @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E">企业号全局返回码说明</a> * href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E">企业号全局返回码说明</a>
*/ */

View File

@ -7,7 +7,12 @@ package com.foxinmy.weixin4j.jssdk;
* @author jy * @author jy
* @date 2015年12月23日 * @date 2015年12月23日
* @since JDK 1.6 * @since JDK 1.6
* @see * @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN">
* 公众平台JSSDK</a>
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BE%AE%E4%BF%A1JS-SDK%E6%8E%A5%E5%8F%A3">
* 企业号JSSDK</a>
*/ */
public enum JSSDKAPI { public enum JSSDKAPI {
/*** /***
@ -258,20 +263,17 @@ public enum JSSDKAPI {
/** /**
* 分享接口集合 * 分享接口集合
*/ */
public final static JSSDKAPI[] SHARE_APIS = { onMenuShareTimeline, public final static JSSDKAPI[] SHARE_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ,
onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, onMenuShareWeibo, onMenuShareQZone };
onMenuShareQZone };
/** /**
* 图像接口集合 * 图像接口集合
*/ */
public final static JSSDKAPI[] IMAGE_APIS = { chooseImage, previewImage, public final static JSSDKAPI[] IMAGE_APIS = { chooseImage, previewImage, uploadImage, downloadImage };
uploadImage, downloadImage };
/** /**
* 音频接口集合 * 音频接口集合
*/ */
public final static JSSDKAPI[] RECORD_APIS = { startRecord, stopRecord, public final static JSSDKAPI[] RECORD_APIS = { startRecord, stopRecord, onVoiceRecordEnd, playVoice, pauseVoice,
onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice };
uploadVoice, downloadVoice };
/** /**
* 智能接口集合 * 智能接口集合
*/ */
@ -287,14 +289,12 @@ public enum JSSDKAPI {
/** /**
* 摇一摇周边接口集合 * 摇一摇周边接口集合
*/ */
public final static JSSDKAPI[] BEACON_APIS = { startSearchBeacons, public final static JSSDKAPI[] BEACON_APIS = { startSearchBeacons, stopSearchBeacons, onSearchBeacons };
stopSearchBeacons, onSearchBeacons };
/** /**
* 界面操作接口集合 * 界面操作接口集合
*/ */
public final static JSSDKAPI[] UI_APIS = { hideOptionMenu, showOptionMenu, public final static JSSDKAPI[] UI_APIS = { hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems,
closeWindow, hideMenuItems, showMenuItems, hideAllNonBaseMenuItem, showMenuItems, hideAllNonBaseMenuItem, showAllNonBaseMenuItem };
showAllNonBaseMenuItem };
/** /**
* 微信扫一扫接口集合 * 微信扫一扫接口集合
*/ */
@ -306,8 +306,7 @@ public enum JSSDKAPI {
/** /**
* 微信卡券接口集合 * 微信卡券接口集合
*/ */
public final static JSSDKAPI[] CARD_APIS = { chooseCard, addCard, openCard, public final static JSSDKAPI[] CARD_APIS = { chooseCard, addCard, openCard, consumeAndShareCard };
consumeAndShareCard };
/** /**
* 微信支付接口集合 * 微信支付接口集合
*/ */
@ -320,29 +319,20 @@ public enum JSSDKAPI {
/** /**
* 公众平台全部接口集合 * 公众平台全部接口集合
*/ */
public final static JSSDKAPI[] MP_ALL_APIS = { onMenuShareTimeline, public final static JSSDKAPI[] MP_ALL_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ,
onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, onMenuShareWeibo, onMenuShareQZone, chooseImage, previewImage, uploadImage, downloadImage, startRecord,
onMenuShareQZone, chooseImage, previewImage, uploadImage, stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice,
downloadImage, startRecord, stopRecord, onVoiceRecordEnd, translateVoice, getNetworkType, openLocation, getLocation, startSearchBeacons, stopSearchBeacons,
playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, showMenuItems,
downloadVoice, translateVoice, getNetworkType, openLocation, hideAllNonBaseMenuItem, showAllNonBaseMenuItem, scanQRCode, openProductSpecificView, chooseCard, addCard,
getLocation, startSearchBeacons, stopSearchBeacons, openCard, consumeAndShareCard, chooseWXPay };
onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow,
hideMenuItems, showMenuItems, hideAllNonBaseMenuItem,
showAllNonBaseMenuItem, scanQRCode, openProductSpecificView,
chooseCard, addCard, openCard, consumeAndShareCard, chooseWXPay };
/** /**
* 企业号全部接口集合 * 企业号全部接口集合
*/ */
public final static JSSDKAPI[] QY_ALL_APIS = { onMenuShareTimeline, public final static JSSDKAPI[] QY_ALL_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ,
onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, onMenuShareWeibo, onMenuShareQZone, chooseImage, previewImage, uploadImage, downloadImage, startRecord,
onMenuShareQZone, chooseImage, previewImage, uploadImage, stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice,
downloadImage, startRecord, stopRecord, onVoiceRecordEnd, translateVoice, getNetworkType, openLocation, getLocation, startSearchBeacons, stopSearchBeacons,
playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, showMenuItems,
downloadVoice, translateVoice, getNetworkType, openLocation, hideAllNonBaseMenuItem, showAllNonBaseMenuItem, scanQRCode, openEnterpriseChat, openEnterpriseContact };
getLocation, startSearchBeacons, stopSearchBeacons,
onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow,
hideMenuItems, showMenuItems, hideAllNonBaseMenuItem,
showAllNonBaseMenuItem, scanQRCode, openEnterpriseChat,
openEnterpriseContact };
} }

View File

@ -13,7 +13,7 @@ import com.alibaba.fastjson.annotation.JSONField;
* @date 2014年4月5日 * @date 2014年4月5日
* @since JDK 1.6 * @since JDK 1.6
* @see <a * @see <a
* href="http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html">微信公众平台获取token</a> * href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN">微信公众平台获取token</a>
* @see <a * @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%BB%E5%8A%A8%E8%B0%83%E7%94%A8">微信企业号的主动模式</a> * href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%BB%E5%8A%A8%E8%B0%83%E7%94%A8">微信企业号的主动模式</a>
*/ */

View File

@ -115,8 +115,9 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.MchPayPackage * @see com.foxinmy.weixin4j.payment.mch.MchPayPackage
* @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口
* </a>
* @return 预支付对象 * @return 预支付对象
*/ */
public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException { public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException {
@ -137,8 +138,7 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(MchPayPackage payPackage) public MchPayRequest createPayRequest(MchPayPackage payPackage) throws WeixinException {
throws WeixinException {
return payApi.createPayRequest(payPackage); return payApi.createPayRequest(payPackage);
} }
@ -184,15 +184,12 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(String body, String detail, public MchPayRequest createPayRequest(String body, String detail, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, TradeType tradeType, String openId, String productId, String attach,
String createIp, TradeType tradeType, String openId, Date timeStart, Date timeExpire, String goodsTag, String limitPay, String subOpenId)
String productId, String attach, Date timeStart, Date timeExpire,
String goodsTag, String limitPay, String subOpenId)
throws WeixinException { throws WeixinException {
return payApi.createPayRequest(body, detail, outTradeNo, totalFee, return payApi.createPayRequest(body, detail, outTradeNo, totalFee, notifyUrl, createIp, tradeType, openId,
notifyUrl, createIp, tradeType, openId, productId, attach, productId, attach, timeStart, timeExpire, goodsTag, limitPay, subOpenId);
timeStart, timeExpire, goodsTag, limitPay, subOpenId);
} }
/** /**
@ -217,11 +214,9 @@ public class WeixinPayProxy {
* @return JSAPI支付对象 * @return JSAPI支付对象
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createJSPayRequest(String openId, String body, public MchPayRequest createJSPayRequest(String openId, String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, String attach) throws WeixinException {
String createIp, String attach) throws WeixinException { return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee, notifyUrl, createIp, attach);
return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee,
notifyUrl, createIp, attach);
} }
/** /**
@ -229,19 +224,25 @@ public class WeixinPayProxy {
* 生成编辑地址请求 * 生成编辑地址请求
* </p> * </p>
* *
* err_msg edit_address:ok获取编辑收货地址成功</br> edit_address:fail获取编辑收货地址失败</br> * err_msg edit_address:ok获取编辑收货地址成功</br>
* userName 收货人姓名</br> telNumber 收货人电话</br> addressPostalCode 邮编</br> * edit_address:fail获取编辑收货地址失败</br>
* proviceFirstStageName 国标收货地址第一级地址</br> addressCitySecondStageName * userName 收货人姓名</br>
* 国标收货地址第二级地址</br> addressCountiesThirdStageName 国标收货地址第三级地址</br> * telNumber 收货人电话</br>
* addressDetailInfo 详细收货地址信息</br> nationalCode 收货地址国家码</br> * addressPostalCode 邮编</br>
* proviceFirstStageName 国标收货地址第一级地址</br>
* addressCitySecondStageName 国标收货地址第二级地址</br>
* addressCountiesThirdStageName 国标收货地址第三级地址</br>
* addressDetailInfo 详细收货地址信息</br>
* nationalCode 收货地址国家码</br>
* *
* @param url * @param url
* 当前访问页的URL * 当前访问页的URL
* @param oauthToken * @param oauthToken
* oauth授权时产生的token * oauth授权时产生的token
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_8&index=7">收货地址共享</a> * "https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_8&index=7">
* 收货地址共享</a>
* @return 编辑地址请求JSON串 * @return 编辑地址请求JSON串
*/ */
public String createAddressRequestJSON(String url, String oauthToken) { public String createAddressRequestJSON(String url, String oauthToken) {
@ -255,9 +256,12 @@ public class WeixinPayProxy {
* 与订单ID等价 * 与订单ID等价
* @return 支付链接 * @return 支付链接
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href=
* @see <a * "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a> * </a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一
* </a>
*/ */
public String createNativePayRequestURL(String productId) { public String createNativePayRequestURL(String productId) {
return payApi.createNativePayRequestURL(productId); return payApi.createNativePayRequestURL(productId);
@ -283,16 +287,17 @@ public class WeixinPayProxy {
* @return Native回调对象 * @return Native回调对象
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.NativePayResponse * @see com.foxinmy.weixin4j.payment.mch.NativePayResponse
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href=
* @see <a * "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a> * </a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一
* </a>
* @throws WeixinException * @throws WeixinException
*/ */
public NativePayResponse createNativePayResponse(String productId, public NativePayResponse createNativePayResponse(String productId, String body, String outTradeNo, double totalFee,
String body, String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, String attach) throws WeixinException {
String createIp, String attach) throws WeixinException { return payApi.createNativePayResponse(productId, body, outTradeNo, totalFee, notifyUrl, createIp, attach);
return payApi.createNativePayResponse(productId, body, outTradeNo,
totalFee, notifyUrl, createIp, attach);
} }
/** /**
@ -315,16 +320,17 @@ public class WeixinPayProxy {
* @return Native支付对象 * @return Native支付对象
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest * @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href=
* @see <a * "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二</a> * </a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二
* </a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createNativePayRequest(String productId, String body, public MchPayRequest createNativePayRequest(String productId, String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, String attach) throws WeixinException {
String createIp, String attach) throws WeixinException { return payApi.createNativePayRequest(productId, body, outTradeNo, totalFee, notifyUrl, createIp, attach);
return payApi.createNativePayRequest(productId, body, outTradeNo,
totalFee, notifyUrl, createIp, attach);
} }
/** /**
@ -345,15 +351,14 @@ public class WeixinPayProxy {
* @return APP支付对象 * @return APP支付对象
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=8_1">APP支付</a> * "https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">
* APP支付</a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createAppPayRequest(String body, String outTradeNo, public MchPayRequest createAppPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl,
double totalFee, String notifyUrl, String createIp, String attach) String createIp, String attach) throws WeixinException {
throws WeixinException { return payApi.createAppPayRequest(body, outTradeNo, totalFee, notifyUrl, createIp, attach);
return payApi.createAppPayRequest(body, outTradeNo, totalFee,
notifyUrl, createIp, attach);
} }
/** /**
@ -374,15 +379,14 @@ public class WeixinPayProxy {
* @return WAP支付对象 * @return WAP支付对象
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a> * "https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付
* </a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createWAPPayRequest(String body, String outTradeNo, public MchPayRequest createWAPPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl,
double totalFee, String notifyUrl, String createIp, String attach) String createIp, String attach) throws WeixinException {
throws WeixinException { return payApi.createWAPPayRequest(body, outTradeNo, totalFee, notifyUrl, createIp, attach);
return payApi.createWAPPayRequest(body, outTradeNo, totalFee,
notifyUrl, createIp, attach);
} }
/** /**
@ -404,22 +408,23 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest
* @see com.foxinmy.weixin4j.payment.mch.Order * @see com.foxinmy.weixin4j.payment.mch.Order
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">提交被扫支付API</a> * "http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">
* 提交被扫支付API</a>
* @throws WeixinException * @throws WeixinException
*/ */
public MchPayRequest createMICROPayRequest(String authCode, String body, public MchPayRequest createMICROPayRequest(String authCode, String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String createIp, String attach) String createIp, String attach) throws WeixinException {
throws WeixinException { return payApi.createMICROPayRequest(authCode, body, outTradeNo, totalFee, createIp, attach);
return payApi.createMICROPayRequest(authCode, body, outTradeNo,
totalFee, createIp, attach);
} }
/** /**
* 订单查询 * 订单查询
* <p> * <p>
* 当商户后台网络服务器等出现异常商户系统最终未接收到支付通知</br> 调用支付接口后返回系统错误或未知交易状态情况</br> * 当商户后台网络服务器等出现异常商户系统最终未接收到支付通知</br>
* 调用被扫支付API返回USERPAYING的状态</br> 调用关单或撤销接口API之前需确认支付状态 * 调用支付接口后返回系统错误或未知交易状态情况</br>
* 调用被扫支付API返回USERPAYING的状态</br>
* 调用关单或撤销接口API之前需确认支付状态
* </P> * </P>
* *
* @param idQuery * @param idQuery
@ -428,8 +433,9 @@ public class WeixinPayProxy {
* @since V3 * @since V3
* @see com.foxinmy.weixin4j.payment.mch.Order * @see com.foxinmy.weixin4j.payment.mch.Order
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2">订单查询API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2">
* 订单查询API</a>
* @return 订单详情 * @return 订单详情
* @throws WeixinException * @throws WeixinException
*/ */
@ -468,16 +474,15 @@ public class WeixinPayProxy {
* @return 退款申请结果 * @return 退款申请结果
* @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see com.foxinmy.weixin4j.payment.mch.RefundResult
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">申请退款API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">
* 申请退款API</a>
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, String outRefundNo, double totalFee,
String outRefundNo, double totalFee, double refundFee, double refundFee, CurrencyType refundFeeType, String opUserId) throws WeixinException {
CurrencyType refundFeeType, String opUserId) throws WeixinException { return payApi.applyRefund(certificate, idQuery, outRefundNo, totalFee, refundFee, refundFeeType, opUserId);
return payApi.applyRefund(certificate, idQuery, outRefundNo, totalFee,
refundFee, refundFeeType, opUserId);
} }
/** /**
@ -487,11 +492,9 @@ public class WeixinPayProxy {
* *
* @see {@link #applyRefund(InputStream, IdQuery, String, double, double, String,CurrencyType)} * @see {@link #applyRefund(InputStream, IdQuery, String, double, double, String,CurrencyType)}
*/ */
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee)
double totalFee) throws WeixinException, IOException { throws WeixinException, IOException {
return payApi.applyRefund( return payApi.applyRefund(new FileInputStream(settings.getCertificateFile0()), idQuery, outRefundNo, totalFee);
new FileInputStream(settings.getCertificateFile0()), idQuery,
outRefundNo, totalFee);
} }
/** /**
@ -507,8 +510,9 @@ public class WeixinPayProxy {
* @return 退款记录 * @return 退款记录
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.RefundRecord * @see com.foxinmy.weixin4j.payment.mch.RefundRecord
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5">退款查询API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5">
* 退款查询API</a>
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
@ -531,20 +535,22 @@ public class WeixinPayProxy {
* @return excel表格 * @return excel表格
* @since V2 & V3 * @since V2 & V3
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6">下载对账单API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6">
* 下载对账单API</a>
* @throws WeixinException * @throws WeixinException
*/ */
public File downloadBill(Date billDate, BillType billType) public File downloadBill(Date billDate, BillType billType) throws WeixinException {
throws WeixinException {
return payApi.downloadBill(billDate, billType, settings.getTmpdir0()); return payApi.downloadBill(billDate, billType, settings.getTmpdir0());
} }
/** /**
* 冲正订单(需要证书)</br> 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br> 接口逻辑: * 冲正订单(需要证书)</br>
* 付失败的关单,支付成功的撤销支付</br> <font color="red">7天以内的单可撤销,其他正常支付的单 * 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br>
* 如需实现相同功能请调用退款接口</font></br> <font * 接口逻辑: 付失败的关单,支付成功的撤销支付</br>
* color="red">调用扣款接口后请勿立即调用撤销,需要等待5秒以上先调用查单接口,如果没有确切的返回,再调用撤销</font></br> * <font color="red">7天以内的单可撤销,其他正常支付的单 如需实现相同功能请调用退款接口</font></br>
* <font color="red">调用扣款接口后请勿立即调用撤销,需要等待5秒以上先调用查单接口,如果没有确切的返回,再调用撤销</font>
* </br>
* *
* @param certificate * @param certificate
* 证书文件(V2版本后缀为*.pfx,V3版本后缀为*.p12) * 证书文件(V2版本后缀为*.pfx,V3版本后缀为*.p12)
@ -556,8 +562,7 @@ public class WeixinPayProxy {
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) throws WeixinException {
throws WeixinException {
return payApi.reverseOrder(certificate, idQuery); return payApi.reverseOrder(certificate, idQuery);
} }
@ -571,10 +576,8 @@ public class WeixinPayProxy {
* @throws WeixinException * @throws WeixinException
* @throws IOException * @throws IOException
*/ */
public MerchantResult reverseOrder(IdQuery idQuery) throws WeixinException, public MerchantResult reverseOrder(IdQuery idQuery) throws WeixinException, IOException {
IOException { return payApi.reverseOrder(new FileInputStream(settings.getCertificateFile0()), idQuery);
return payApi.reverseOrder(
new FileInputStream(settings.getCertificateFile0()), idQuery);
} }
/** /**
@ -590,8 +593,9 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3">关闭订单API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3">
* 关闭订单API</a>
*/ */
public MerchantResult closeOrder(String outTradeNo) throws WeixinException { public MerchantResult closeOrder(String outTradeNo) throws WeixinException {
return payApi.closeOrder(outTradeNo); return payApi.closeOrder(outTradeNo);
@ -605,8 +609,9 @@ public class WeixinPayProxy {
* 具有native标识的支付URL * 具有native标识的支付URL
* @return 转换后的短链接 * @return 转换后的短链接
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_9">转换短链接API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_9">
* 转换短链接API</a>
* @since V3 * @since V3
* @throws WeixinException * @throws WeixinException
*/ */
@ -632,15 +637,14 @@ public class WeixinPayProxy {
* 调用接口返回的基本数据 * 调用接口返回的基本数据
* @return 处理结果 * @return 处理结果
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_8">接口测试上报API</a> * "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_8">
* 接口测试上报API</a>
* @throws WeixinException * @throws WeixinException
*/ */
public XmlResult interfaceReport(String interfaceUrl, int executeTime, public XmlResult interfaceReport(String interfaceUrl, int executeTime, String outTradeNo, String ip, Date time,
String outTradeNo, String ip, Date time, XmlResult returnXml) XmlResult returnXml) throws WeixinException {
throws WeixinException { return payApi.interfaceReport(interfaceUrl, executeTime, outTradeNo, ip, time, returnXml);
return payApi.interfaceReport(interfaceUrl, executeTime, outTradeNo,
ip, time, returnXml);
} }
/** /**
@ -659,15 +663,14 @@ public class WeixinPayProxy {
* @return 发放结果 * @return 发放结果
* @see com.foxinmy.weixin4j.api.CouponApi * @see com.foxinmy.weixin4j.api.CouponApi
* @see com.foxinmy.weixin4j.payment.coupon.CouponResult * @see com.foxinmy.weixin4j.payment.coupon.CouponResult
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php?chapter=12_3">发放代金券接口</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_3">
* 发放代金券接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CouponResult sendCoupon(InputStream certificate, public CouponResult sendCoupon(InputStream certificate, String couponStockId, String partnerTradeNo, String openId,
String couponStockId, String partnerTradeNo, String openId,
String opUserId) throws WeixinException { String opUserId) throws WeixinException {
return couponApi.sendCoupon(certificate, couponStockId, partnerTradeNo, return couponApi.sendCoupon(certificate, couponStockId, partnerTradeNo, openId, opUserId);
openId, opUserId);
} }
/** /**
@ -675,11 +678,10 @@ public class WeixinPayProxy {
* *
* @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#sendCoupon(InputStream, String, String, String, String)} * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#sendCoupon(InputStream, String, String, String, String)}
*/ */
public CouponResult sendCoupon(String couponStockId, String partnerTradeNo, public CouponResult sendCoupon(String couponStockId, String partnerTradeNo, String openId)
String openId) throws WeixinException, IOException { throws WeixinException, IOException {
return couponApi.sendCoupon( return couponApi.sendCoupon(new FileInputStream(settings.getCertificateFile0()), couponStockId, partnerTradeNo,
new FileInputStream(settings.getCertificateFile0()), openId, null);
couponStockId, partnerTradeNo, openId, null);
} }
/** /**
@ -690,12 +692,12 @@ public class WeixinPayProxy {
* @return 代金券批次信息 * @return 代金券批次信息
* @see com.foxinmy.weixin4j.api.CouponApi * @see com.foxinmy.weixin4j.api.CouponApi
* @see com.foxinmy.weixin4j.payment.coupon.CouponStock * @see com.foxinmy.weixin4j.payment.coupon.CouponStock
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php?chapter=12_4">查询代金券信息</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_4">
* 查询代金券批次信息接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CouponStock queryCouponStock(String couponStockId) public CouponStock queryCouponStock(String couponStockId) throws WeixinException {
throws WeixinException {
return couponApi.queryCouponStock(couponStockId); return couponApi.queryCouponStock(couponStockId);
} }
@ -707,12 +709,12 @@ public class WeixinPayProxy {
* @return 代金券详细信息 * @return 代金券详细信息
* @see com.foxinmy.weixin4j.api.CouponApi * @see com.foxinmy.weixin4j.api.CouponApi
* @see com.foxinmy.weixin4j.payment.coupon.CouponDetail * @see com.foxinmy.weixin4j.payment.coupon.CouponDetail
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/sp_coupon.php?chapter=12_5">查询代金券详细信息</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_5">
* 查询代金券详细信息接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CouponDetail queryCouponDetail(String couponId) public CouponDetail queryCouponDetail(String couponId) throws WeixinException {
throws WeixinException {
return couponApi.queryCouponDetail(couponId); return couponApi.queryCouponDetail(couponId);
} }
@ -727,12 +729,15 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see com.foxinmy.weixin4j.payment.mch.Redpacket * @see com.foxinmy.weixin4j.payment.mch.Redpacket
* @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult * @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5">红包接口说明</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5">
* 发放现金红包接口</a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_5">
* 发放裂变红包接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public RedpacketSendResult sendRedpack(InputStream certificate, public RedpacketSendResult sendRedpack(InputStream certificate, Redpacket redpacket) throws WeixinException {
Redpacket redpacket) throws WeixinException {
return cashApi.sendRedpack(certificate, redpacket); return cashApi.sendRedpack(certificate, redpacket);
} }
@ -741,10 +746,8 @@ public class WeixinPayProxy {
* *
* @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#sendRedpack(InputStream, Redpacket)} * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#sendRedpack(InputStream, Redpacket)}
*/ */
public RedpacketSendResult sendRedpack(Redpacket redpacket) public RedpacketSendResult sendRedpack(Redpacket redpacket) throws WeixinException, IOException {
throws WeixinException, IOException { return cashApi.sendRedpack(new FileInputStream(settings.getCertificateFile0()), redpacket);
return cashApi.sendRedpack(
new FileInputStream(settings.getCertificateFile0()), redpacket);
} }
/** /**
@ -757,12 +760,15 @@ public class WeixinPayProxy {
* @return 红包记录 * @return 红包记录
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see com.foxinmy.weixin4j.payment.mch.RedpacketRecord * @see com.foxinmy.weixin4j.payment.mch.RedpacketRecord
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_6">查询红包接口说明</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_7&index=6">
* 查询现金红包接口</a>
* @see <a href=
* "https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_6">
* 查询裂变红包接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public RedpacketRecord queryRedpack(InputStream certificate, public RedpacketRecord queryRedpack(InputStream certificate, String outTradeNo) throws WeixinException {
String outTradeNo) throws WeixinException {
return cashApi.queryRedpack(certificate, outTradeNo); return cashApi.queryRedpack(certificate, outTradeNo);
} }
@ -771,12 +777,8 @@ public class WeixinPayProxy {
* *
* @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#queryRedpack(InputStream,String)} * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#queryRedpack(InputStream,String)}
*/ */
public RedpacketRecord queryRedpack(String outTradeNo) public RedpacketRecord queryRedpack(String outTradeNo) throws WeixinException, IOException {
throws WeixinException, IOException { return cashApi.queryRedpack(new FileInputStream(settings.getCertificateFile0()), outTradeNo);
return cashApi
.queryRedpack(
new FileInputStream(settings.getCertificateFile0()),
outTradeNo);
} }
/** /**
@ -790,12 +792,12 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see com.foxinmy.weixin4j.payment.mch.CorpPayment * @see com.foxinmy.weixin4j.payment.mch.CorpPayment
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2">
* 企业付款接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CorpPaymentResult sendCorpPayment(InputStream certificate, public CorpPaymentResult sendCorpPayment(InputStream certificate, CorpPayment payment) throws WeixinException {
CorpPayment payment) throws WeixinException {
return cashApi.sendCorpPayment(certificate, payment); return cashApi.sendCorpPayment(certificate, payment);
} }
@ -804,10 +806,8 @@ public class WeixinPayProxy {
* *
* @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#senCorpPayment(InputStream, CorpPayment)} * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#senCorpPayment(InputStream, CorpPayment)}
*/ */
public CorpPaymentResult sendCorpPayment(CorpPayment payment) public CorpPaymentResult sendCorpPayment(CorpPayment payment) throws WeixinException, IOException {
throws WeixinException, IOException { return cashApi.sendCorpPayment(new FileInputStream(settings.getCertificateFile0()), payment);
return cashApi.sendCorpPayment(
new FileInputStream(settings.getCertificateFile0()), payment);
} }
/** /**
@ -820,12 +820,12 @@ public class WeixinPayProxy {
* @return 付款记录 * @return 付款记录
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord
* @see <a * @see <a href=
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_3">企业付款查询</a> * "https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3">
* 企业付款查询接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CorpPaymentRecord queryCorpPayment(InputStream certificate, public CorpPaymentRecord queryCorpPayment(InputStream certificate, String outTradeNo) throws WeixinException {
String outTradeNo) throws WeixinException {
return cashApi.queryCorpPayment(certificate, outTradeNo); return cashApi.queryCorpPayment(certificate, outTradeNo);
} }
@ -834,24 +834,21 @@ public class WeixinPayProxy {
* *
* @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#CorpPaymentRecord(InputStream, String)} * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#CorpPaymentRecord(InputStream, String)}
*/ */
public CorpPaymentRecord queryCorpPayment(String outTradeNo) public CorpPaymentRecord queryCorpPayment(String outTradeNo) throws WeixinException, IOException {
throws WeixinException, IOException { return cashApi.queryCorpPayment(new FileInputStream(settings.getCertificateFile0()), outTradeNo);
return cashApi
.queryCorpPayment(
new FileInputStream(settings.getCertificateFile0()),
outTradeNo);
} }
/** /**
* 授权码查询OPENID接口 * 授权码查询OPENID
* *
* @param authCode * @param authCode
* 扫码支付授权码设备读取用户微信中的条码或者二维码信息 * 扫码支付授权码设备读取用户微信中的条码或者二维码信息
* @return 查询结果 * @return 查询结果
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see com.foxinmy.weixin4j.payment.mch.OpenIdResult * @see com.foxinmy.weixin4j.payment.mch.OpenIdResult
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9">授权码查询OPENID</a> * "https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9">
* 授权码查询OPENID</a>
* @throws WeixinException * @throws WeixinException
*/ */
public OpenIdResult authCode2openId(String authCode) throws WeixinException { public OpenIdResult authCode2openId(String authCode) throws WeixinException {
@ -873,11 +870,12 @@ public class WeixinPayProxy {
* @throws WeixinException * @throws WeixinException
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see com.foxinmy.weixin4j.payment.mch.SettlementRecord * @see com.foxinmy.weixin4j.payment.mch.SettlementRecord
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_14&index=7">查询结算资金</a> * "https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_14&index=7">
* 查询结算资金接口</a>
*/ */
public SettlementRecord querySettlement(boolean status, Pageable pageable, public SettlementRecord querySettlement(boolean status, Pageable pageable, Date start, Date end)
Date start, Date end) throws WeixinException { throws WeixinException {
return cashApi.querySettlement(status, pageable, start, end); return cashApi.querySettlement(status, pageable, start, end);
} }
@ -891,11 +889,11 @@ public class WeixinPayProxy {
* @return 汇率对象 * @return 汇率对象
* @throws WeixinException * @throws WeixinException
* @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.api.CashApi
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_15&index=8">查询汇率</a> * "https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_15&index=8">
* 查询汇率接口</a>
*/ */
public double queryExchageRate(CurrencyType currencyType, Date date) public double queryExchageRate(CurrencyType currencyType, Date date) throws WeixinException {
throws WeixinException {
return cashApi.queryExchageRate(currencyType, date); return cashApi.queryExchageRate(currencyType, date);
} }
@ -908,12 +906,12 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.CustomsApi * @see com.foxinmy.weixin4j.api.CustomsApi
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrder * @see com.foxinmy.weixin4j.payment.mch.CustomsOrder
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a> * "https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">
* 附加订单信息提交接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) throws WeixinException {
throws WeixinException {
return customsApi.declareCustomsOrder(customsOrder); return customsApi.declareCustomsOrder(customsOrder);
} }
@ -927,12 +925,12 @@ public class WeixinPayProxy {
* @return 报关记录 * @return 报关记录
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord
* @see com.foxinmy.weixin4j.api.CustomsApi * @see com.foxinmy.weixin4j.api.CustomsApi
* @see <a * @see <a href=
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a> * "https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">
* 附加订单信息查询接口</a>
* @throws WeixinException * @throws WeixinException
*/ */
public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, CustomsCity customsCity) throws WeixinException {
CustomsCity customsCity) throws WeixinException {
return customsApi.queryCustomsOrder(idQuery, customsCity); return customsApi.queryCustomsOrder(idQuery, customsCity);
} }

View File

@ -16,7 +16,7 @@ import com.foxinmy.weixin4j.util.MapUtil;
* @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see com.foxinmy.weixin4j.payment.PayRequest * @see com.foxinmy.weixin4j.payment.PayRequest
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=8_1">APP支付</a> * href="https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">APP支付</a>
*/ */
public class APPPayRequest extends AbstractPayRequest { public class APPPayRequest extends AbstractPayRequest {
public APPPayRequest(String prePayId, WeixinPayAccount payAccount) { public APPPayRequest(String prePayId, WeixinPayAccount payAccount) {

View File

@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.MPPaymentCheckNameType; import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType;
import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DateUtil;
/** /**
@ -38,11 +38,11 @@ public class CorpPayment extends MerchantResult {
/** /**
* 校验用户姓名选项 * 校验用户姓名选项
* *
* @see com.foxinmy.weixin4j.mp.type.MPPaymentCheckNameType * @see com.foxinmy.weixin4j.CorpPaymentCheckNameType.type.MPPaymentCheckNameType
*/ */
@XmlElement(name = "check_name") @XmlElement(name = "check_name")
@JSONField(name = "check_name") @JSONField(name = "check_name")
private MPPaymentCheckNameType checkNameType; private CorpPaymentCheckNameType checkNameType;
/** /**
* 收款用户真实姓名 如果check_name设置为FORCE_CHECK或OPTION_CHECK则必填用户真实姓名 可选 * 收款用户真实姓名 如果check_name设置为FORCE_CHECK或OPTION_CHECK则必填用户真实姓名 可选
*/ */
@ -85,7 +85,7 @@ public class CorpPayment extends MerchantResult {
* 调用接口IP * 调用接口IP
*/ */
public CorpPayment(String outTradeNo, String openId, public CorpPayment(String outTradeNo, String openId,
MPPaymentCheckNameType checkNameType, String desc, double amount, CorpPaymentCheckNameType checkNameType, String desc, double amount,
String clientIp) { String clientIp) {
this.outTradeNo = outTradeNo; this.outTradeNo = outTradeNo;
this.openId = openId; this.openId = openId;
@ -103,7 +103,7 @@ public class CorpPayment extends MerchantResult {
return openId; return openId;
} }
public MPPaymentCheckNameType getCheckNameType() { public CorpPaymentCheckNameType getCheckNameType() {
return checkNameType; return checkNameType;
} }

View File

@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.MPPaymentCheckNameType; import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType;
import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DateUtil;
/** /**
@ -77,7 +77,7 @@ public class CorpPaymentRecord extends MerchantResult {
/** /**
* 校验用户姓名选项 * 校验用户姓名选项
* *
* @see com.foxinmy.weixin4j.mp.type.MPPaymentCheckNameType * @see com.foxinmy.weixin4j.CorpPaymentCheckNameType.type.MPPaymentCheckNameType
*/ */
@XmlElement(name = "check_name") @XmlElement(name = "check_name")
@JSONField(name = "check_name") @JSONField(name = "check_name")
@ -166,8 +166,8 @@ public class CorpPaymentRecord extends MerchantResult {
} }
@JSONField(serialize = false) @JSONField(serialize = false)
public MPPaymentCheckNameType getFormatCheckNameType() { public CorpPaymentCheckNameType getFormatCheckNameType() {
return checkNameType != null ? MPPaymentCheckNameType return checkNameType != null ? CorpPaymentCheckNameType
.valueOf(checkNameType) : null; .valueOf(checkNameType) : null;
} }

View File

@ -21,7 +21,7 @@ import com.foxinmy.weixin4j.type.TradeType;
* @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see com.foxinmy.weixin4j.payment.PayRequest * @see com.foxinmy.weixin4j.payment.PayRequest
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6">网页端调起支付API</a> * href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_1">网页端调起支付API</a>
*/ */
public class JSAPIPayRequest extends AbstractPayRequest { public class JSAPIPayRequest extends AbstractPayRequest {

View File

@ -17,7 +17,7 @@ import com.foxinmy.weixin4j.type.TradeType;
* @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see com.foxinmy.weixin4j.payment.PayRequest * @see com.foxinmy.weixin4j.payment.PayRequest
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1">刷卡支付</a> * href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1">刷卡支付</a>
*/ */
public class MICROPayRequest extends Order implements MchPayRequest { public class MICROPayRequest extends Order implements MchPayRequest {

View File

@ -14,7 +14,7 @@ import com.foxinmy.weixin4j.type.TradeType;
* @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see com.foxinmy.weixin4j.payment.PayRequest * @see com.foxinmy.weixin4j.payment.PayRequest
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">NATIVE扫码支付(模式二)</a> * href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">NATIVE扫码支付(模式二)</a>
*/ */
public class NATIVEPayRequest extends AbstractPayRequest { public class NATIVEPayRequest extends AbstractPayRequest {

View File

@ -17,9 +17,9 @@ import com.foxinmy.weixin4j.util.DateUtil;
* @date 2015年3月28日 * @date 2015年3月28日
* @since JDK 1.6 * @since JDK 1.6
* @see <a * @see <a
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_1">普通红包</a> * href="https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_1">普通红包</a>
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=16_1">裂变红包</a> * href="https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_1">裂变红包</a>
*/ */
@XmlRootElement @XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)

View File

@ -9,7 +9,7 @@ import com.foxinmy.weixin4j.util.DigestUtil;
* @author jy * @author jy
* @date 2016年3月26日 * @date 2016年3月26日
* @since JDK 1.6 * @since JDK 1.6
* @see * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/external/jsapi.php?chapter=4_3">支付签名说明</a>
*/ */
public class WeixinPaymentSignature extends AbstractWeixinSignature { public class WeixinPaymentSignature extends AbstractWeixinSignature {
/** /**

View File

@ -12,7 +12,7 @@ package com.foxinmy.weixin4j.type;
* @date 2014年9月30日 * @date 2014年9月30日
* @since JDK 1.6 * @since JDK 1.6
* @see <a * @see <a
* href="http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html">按钮类型</a> * href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN">按钮类型</a>
*/ */
public enum ButtonType { public enum ButtonType {
/** /**

View File

@ -3,13 +3,13 @@ package com.foxinmy.weixin4j.type;
/** /**
* 企业付款检查收款人姓名的策略 * 企业付款检查收款人姓名的策略
* *
* @className MPPaymentCheckType * @className CorpPaymentCheckNameType
* @author jy * @author jy
* @date 2015年4月1日 * @date 2015年4月1日
* @since JDK 1.6 * @since JDK 1.6
* @see * @see
*/ */
public enum MPPaymentCheckNameType { public enum CorpPaymentCheckNameType {
/** /**
* 不校验真实姓名 * 不校验真实姓名
*/ */

View File

@ -2,8 +2,8 @@ package com.foxinmy.weixin4j.util;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -27,7 +27,7 @@ public final class WeixinErrorUtil {
private static byte[] errorXmlByteArray; private static byte[] errorXmlByteArray;
private final static Map<String, String> errorCacheMap; private final static Map<String, String> errorCacheMap;
static { static {
errorCacheMap = new HashMap<String, String>(); errorCacheMap = new ConcurrentHashMap<String, String>();
try { try {
errorXmlByteArray = IOUtil.toByteArray(WeixinResponse.class errorXmlByteArray = IOUtil.toByteArray(WeixinResponse.class
.getResourceAsStream("error.xml")); .getResourceAsStream("error.xml"));

View File

@ -11,7 +11,7 @@ import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
import com.foxinmy.weixin4j.payment.mch.Redpacket; import com.foxinmy.weixin4j.payment.mch.Redpacket;
import com.foxinmy.weixin4j.payment.mch.RedpacketRecord; import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult; import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
import com.foxinmy.weixin4j.type.MPPaymentCheckNameType; import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType;
/** /**
* 现金发放测试 * 现金发放测试
@ -46,7 +46,7 @@ public class CashTest extends PayTest {
public void sendCorpPayment() throws WeixinException, IOException { public void sendCorpPayment() throws WeixinException, IOException {
CorpPayment payment = new CorpPayment("MP001", CorpPayment payment = new CorpPayment("MP001",
"ofW1gwok9vZIyle0YbA-eQe83Uk8", "ofW1gwok9vZIyle0YbA-eQe83Uk8",
MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1"); CorpPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1");
CorpPaymentResult result = PAY.sendCorpPayment(new FileInputStream( CorpPaymentResult result = PAY.sendCorpPayment(new FileInputStream(
caFile), payment); caFile), payment);
System.err.println(result); System.err.println(result);