修复备注链接不正确

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

@ -1,348 +1,338 @@
package com.foxinmy.weixin4j.jssdk; package com.foxinmy.weixin4j.jssdk;
/** /**
* JSSDK接口列表 * JSSDK接口列表
* *
* @className JSSDKAPI * @className JSSDKAPI
* @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">
public enum JSSDKAPI { * 公众平台JSSDK</a>
/*** * @see <a href=
* <a href= * "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BE%AE%E4%BF%A1JS-SDK%E6%8E%A5%E5%8F%A3">
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0.E6.9C.8B.E5.8F.8B.E5.9C.88.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3" * 企业号JSSDK</a>
* >分享接口-获取分享到朋友圈按钮点击状态及自定义分享内容接口</a> */
*/ public enum JSSDKAPI {
onMenuShareTimeline, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0.E6.9C.8B.E5.8F.8B.E5.9C.88.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E7.BB.99.E6.9C.8B.E5.8F.8B.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3" * >分享接口-获取分享到朋友圈按钮点击状态及自定义分享内容接口</a>
* >分享接口-获取分享给朋友按钮点击状态及自定义分享内容接口</a> */
*/ onMenuShareTimeline,
onMenuShareAppMessage, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E7.BB.99.E6.9C.8B.E5.8F.8B.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0QQ.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3" * >分享接口-获取分享给朋友按钮点击状态及自定义分享内容接口</a>
* >分享接口-获取分享到QQ按钮点击状态及自定义分享内容接口</a> */
*/ onMenuShareAppMessage,
onMenuShareQQ, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0QQ.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0.E8.85.BE.E8.AE.AF.E5.BE.AE.E5.8D.9A.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3" * >分享接口-获取分享到QQ按钮点击状态及自定义分享内容接口</a>
* >分享接口-获取分享到腾讯微博按钮点击状态及自定义分享内容接口</a> */
*/ onMenuShareQQ,
onMenuShareWeibo, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0.E8.85.BE.E8.AE.AF.E5.BE.AE.E5.8D.9A.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0QQ.E7.A9.BA.E9.97.B4.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3" * >分享接口-获取分享到腾讯微博按钮点击状态及自定义分享内容接口</a>
* >分享接口-获取分享到QQ空间按钮点击状态及自定义分享内容接口</a> */
*/ onMenuShareWeibo,
onMenuShareQZone, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E2.80.9C.E5.88.86.E4.BA.AB.E5.88.B0QQ.E7.A9.BA.E9.97.B4.E2.80.9D.E6.8C.89.E9.92.AE.E7.82.B9.E5.87.BB.E7.8A.B6.E6.80.81.E5.8F.8A.E8.87.AA.E5.AE.9A.E4.B9.89.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.8B.8D.E7.85.A7.E6.88.96.E4.BB.8E.E6.89.8B.E6.9C.BA.E7.9B.B8.E5.86.8C.E4.B8.AD.E9.80.89.E5.9B.BE.E6.8E.A5.E5.8F.A3" * >分享接口-获取分享到QQ空间按钮点击状态及自定义分享内容接口</a>
* >图像接口-拍照或从手机相册中选图接口</a> */
*/ onMenuShareQZone,
chooseImage, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.8B.8D.E7.85.A7.E6.88.96.E4.BB.8E.E6.89.8B.E6.9C.BA.E7.9B.B8.E5.86.8C.E4.B8.AD.E9.80.89.E5.9B.BE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.A2.84.E8.A7.88.E5.9B.BE.E7.89.87.E6.8E.A5.E5.8F.A3" * >图像接口-拍照或从手机相册中选图接口</a>
* >图像接口-预览图片接口</a> */
*/ chooseImage,
previewImage, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.A2.84.E8.A7.88.E5.9B.BE.E7.89.87.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8A.E4.BC.A0.E5.9B.BE.E7.89.87.E6.8E.A5.E5.8F.A3" * >图像接口-预览图片接口</a>
* >图像接口-上传图片接口</a> */
*/ previewImage,
uploadImage, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8A.E4.BC.A0.E5.9B.BE.E7.89.87.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8B.E8.BD.BD.E5.9B.BE.E7.89.87.E6.8E.A5.E5.8F.A3" * >图像接口-上传图片接口</a>
* >图像接口-下载图片接口</a> */
*/ uploadImage,
downloadImage, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8B.E8.BD.BD.E5.9B.BE.E7.89.87.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.BC.80.E5.A7.8B.E5.BD.95.E9.9F.B3.E6.8E.A5.E5.8F.A3" * >图像接口-下载图片接口</a>
* >音频接口-开始录音接口</a> */
*/ downloadImage,
startRecord, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.BC.80.E5.A7.8B.E5.BD.95.E9.9F.B3.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.81.9C.E6.AD.A2.E5.BD.95.E9.9F.B3.E6.8E.A5.E5.8F.A3" * >音频接口-开始录音接口</a>
* >音频接口-停止录音接口</a> */
*/ startRecord,
stopRecord, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.81.9C.E6.AD.A2.E5.BD.95.E9.9F.B3.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E7.9B.91.E5.90.AC.E5.BD.95.E9.9F.B3.E8.87.AA.E5.8A.A8.E5.81.9C.E6.AD.A2.E6.8E.A5.E5.8F.A3" * >音频接口-停止录音接口</a>
* >音频接口-监听录音自动停止接口</a> */
*/ stopRecord,
onVoiceRecordEnd, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E7.9B.91.E5.90.AC.E5.BD.95.E9.9F.B3.E8.87.AA.E5.8A.A8.E5.81.9C.E6.AD.A2.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.92.AD.E6.94.BE.E8.AF.AD.E9.9F.B3.E6.8E.A5.E5.8F.A3" * >音频接口-监听录音自动停止接口</a>
* >音频接口-播放语音接口</a> */
*/ onVoiceRecordEnd,
playVoice, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.92.AD.E6.94.BE.E8.AF.AD.E9.9F.B3.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.9A.82.E5.81.9C.E6.92.AD.E6.94.BE.E6.8E.A5.E5.8F.A3" * >音频接口-播放语音接口</a>
* >音频接口-暂停播放接口</a> */
*/ playVoice,
pauseVoice, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.9A.82.E5.81.9C.E6.92.AD.E6.94.BE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.81.9C.E6.AD.A2.E6.92.AD.E6.94.BE.E6.8E.A5.E5.8F.A3" * >音频接口-暂停播放接口</a>
* >音频接口-停止播放接口</a> */
*/ pauseVoice,
stopVoice, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.81.9C.E6.AD.A2.E6.92.AD.E6.94.BE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E7.9B.91.E5.90.AC.E8.AF.AD.E9.9F.B3.E6.92.AD.E6.94.BE.E5.AE.8C.E6.AF.95.E6.8E.A5.E5.8F.A3" * >音频接口-停止播放接口</a>
* >音频接口-监听语音播放完毕接口</a> */
*/ stopVoice,
onVoicePlayEnd, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E7.9B.91.E5.90.AC.E8.AF.AD.E9.9F.B3.E6.92.AD.E6.94.BE.E5.AE.8C.E6.AF.95.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8A.E4.BC.A0.E8.AF.AD.E9.9F.B3.E6.8E.A5.E5.8F.A3" * >音频接口-监听语音播放完毕接口</a>
* >音频接口-上传语音接口</a> */
*/ onVoicePlayEnd,
uploadVoice, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8A.E4.BC.A0.E8.AF.AD.E9.9F.B3.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8B.E8.BD.BD.E8.AF.AD.E9.9F.B3.E6.8E.A5.E5.8F.A3" * >音频接口-上传语音接口</a>
* >音频接口-下载语音接口</a> */
*/ uploadVoice,
downloadVoice, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.B8.8B.E8.BD.BD.E8.AF.AD.E9.9F.B3.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.AF.86.E5.88.AB.E9.9F.B3.E9.A2.91.E5.B9.B6.E8.BF.94.E5.9B.9E.E8.AF.86.E5.88.AB.E7.BB.93.E6.9E.9C.E6.8E.A5.E5.8F.A3" * >音频接口-下载语音接口</a>
* >智能接口-识别音频并返回识别结果接口</a> */
*/ downloadVoice,
translateVoice, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.AF.86.E5.88.AB.E9.9F.B3.E9.A2.91.E5.B9.B6.E8.BF.94.E5.9B.9E.E8.AF.86.E5.88.AB.E7.BB.93.E6.9E.9C.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E7.BD.91.E7.BB.9C.E7.8A.B6.E6.80.81.E6.8E.A5.E5.8F.A3" * >智能接口-识别音频并返回识别结果接口</a>
* >设备信息-获取网络状态接口</a> */
*/ translateVoice,
getNetworkType, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E7.BD.91.E7.BB.9C.E7.8A.B6.E6.80.81.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.BD.BF.E7.94.A8.E5.BE.AE.E4.BF.A1.E5.86.85.E7.BD.AE.E5.9C.B0.E5.9B.BE.E6.9F.A5.E7.9C.8B.E4.BD.8D.E7.BD.AE.E6.8E.A5.E5.8F.A3" * >设备信息-获取网络状态接口</a>
* >地理位置-使用微信内置地图查看位置接口</a> */
*/ getNetworkType,
openLocation, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E4.BD.BF.E7.94.A8.E5.BE.AE.E4.BF.A1.E5.86.85.E7.BD.AE.E5.9C.B0.E5.9B.BE.E6.9F.A5.E7.9C.8B.E4.BD.8D.E7.BD.AE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E5.9C.B0.E7.90.86.E4.BD.8D.E7.BD.AE.E6.8E.A5.E5.8F.A3" * >地理位置-使用微信内置地图查看位置接口</a>
* >地理位置-获取地理位置接口</a> */
*/ openLocation,
getLocation, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.8E.B7.E5.8F.96.E5.9C.B0.E7.90.86.E4.BD.8D.E7.BD.AE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.BC.80.E5.90.AF.E6.9F.A5.E6.89.BE.E5.91.A8.E8.BE.B9ibeacon.E8.AE.BE.E5.A4.87.E6.8E.A5.E5.8F.A3" * >地理位置-获取地理位置接口</a>
* >摇一摇周边-开启查找周边ibeacon设备接口</a> */
*/ getLocation,
startSearchBeacons, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.BC.80.E5.90.AF.E6.9F.A5.E6.89.BE.E5.91.A8.E8.BE.B9ibeacon.E8.AE.BE.E5.A4.87.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.85.B3.E9.97.AD.E6.9F.A5.E6.89.BE.E5.91.A8.E8.BE.B9ibeacon.E8.AE.BE.E5.A4.87.E6.8E.A5.E5.8F.A3" * >摇一摇周边-开启查找周边ibeacon设备接口</a>
* >摇一摇周边-关闭查找周边ibeacon设备接口</a> */
*/ startSearchBeacons,
stopSearchBeacons, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.85.B3.E9.97.AD.E6.9F.A5.E6.89.BE.E5.91.A8.E8.BE.B9ibeacon.E8.AE.BE.E5.A4.87.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E7.9B.91.E5.90.AC.E5.91.A8.E8.BE.B9ibeacon.E8.AE.BE.E5.A4.87.E6.8E.A5.E5.8F.A3" * >摇一摇周边-关闭查找周边ibeacon设备接口</a>
* >摇一摇周边-监听周边ibeacon设备接口</a> */
*/ stopSearchBeacons,
onSearchBeacons, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E7.9B.91.E5.90.AC.E5.91.A8.E8.BE.B9ibeacon.E8.AE.BE.E5.A4.87.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.9A.90.E8.97.8F.E5.8F.B3.E4.B8.8A.E8.A7.92.E8.8F.9C.E5.8D.95.E6.8E.A5.E5.8F.A3" * >摇一摇周边-监听周边ibeacon设备接口</a>
* >界面操作-隐藏右上角菜单接口</a> */
*/ onSearchBeacons,
hideOptionMenu, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.9A.90.E8.97.8F.E5.8F.B3.E4.B8.8A.E8.A7.92.E8.8F.9C.E5.8D.95.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.98.BE.E7.A4.BA.E5.8F.B3.E4.B8.8A.E8.A7.92.E8.8F.9C.E5.8D.95.E6.8E.A5.E5.8F.A3" * >界面操作-隐藏右上角菜单接口</a>
* >界面操作-显示右上角菜单接口</a> */
*/ hideOptionMenu,
showOptionMenu, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.98.BE.E7.A4.BA.E5.8F.B3.E4.B8.8A.E8.A7.92.E8.8F.9C.E5.8D.95.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.85.B3.E9.97.AD.E5.BD.93.E5.89.8D.E7.BD.91.E9.A1.B5.E7.AA.97.E5.8F.A3.E6.8E.A5.E5.8F.A3" * >界面操作-显示右上角菜单接口</a>
* >界面操作-关闭当前网页窗口接口</a> */
*/ showOptionMenu,
closeWindow, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.85.B3.E9.97.AD.E5.BD.93.E5.89.8D.E7.BD.91.E9.A1.B5.E7.AA.97.E5.8F.A3.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.89.B9.E9.87.8F.E9.9A.90.E8.97.8F.E5.8A.9F.E8.83.BD.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3" * >界面操作-关闭当前网页窗口接口</a>
* >界面操作-批量隐藏功能按钮接口</a> */
*/ closeWindow,
hideMenuItems, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.89.B9.E9.87.8F.E9.9A.90.E8.97.8F.E5.8A.9F.E8.83.BD.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.89.B9.E9.87.8F.E6.98.BE.E7.A4.BA.E5.8A.9F.E8.83.BD.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3" * >界面操作-批量隐藏功能按钮接口</a>
* >界面操作-批量显示功能按钮接口</a> */
*/ hideMenuItems,
showMenuItems, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.89.B9.E9.87.8F.E6.98.BE.E7.A4.BA.E5.8A.9F.E8.83.BD.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.9A.90.E8.97.8F.E6.89.80.E6.9C.89.E9.9D.9E.E5.9F.BA.E7.A1.80.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3" * >界面操作-批量显示功能按钮接口</a>
* >界面操作-隐藏所有非基础按钮接口</a> */
*/ showMenuItems,
hideAllNonBaseMenuItem, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.9A.90.E8.97.8F.E6.89.80.E6.9C.89.E9.9D.9E.E5.9F.BA.E7.A1.80.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.98.BE.E7.A4.BA.E6.89.80.E6.9C.89.E5.8A.9F.E8.83.BD.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3" * >界面操作-隐藏所有非基础按钮接口</a>
* >界面操作-显示所有功能按钮接口</a> */
*/ hideAllNonBaseMenuItem,
showAllNonBaseMenuItem, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.98.BE.E7.A4.BA.E6.89.80.E6.9C.89.E5.8A.9F.E8.83.BD.E6.8C.89.E9.92.AE.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.B0.83.E8.B5.B7.E5.BE.AE.E4.BF.A1.E6.89.AB.E4.B8.80.E6.89.AB.E6.8E.A5.E5.8F.A3" * >界面操作-显示所有功能按钮接口</a>
* >微信扫一扫-调起微信扫一扫接口</a> */
*/ showAllNonBaseMenuItem,
scanQRCode, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.B0.83.E8.B5.B7.E5.BE.AE.E4.BF.A1.E6.89.AB.E4.B8.80.E6.89.AB.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.B7.B3.E8.BD.AC.E5.BE.AE.E4.BF.A1.E5.95.86.E5.93.81.E9.A1.B5.E6.8E.A5.E5.8F.A3" * >微信扫一扫-调起微信扫一扫接口</a>
* >微信小店-跳转微信商品页接口</a> */
*/ scanQRCode,
openProductSpecificView, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E8.B7.B3.E8.BD.AC.E5.BE.AE.E4.BF.A1.E5.95.86.E5.93.81.E9.A1.B5.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.8B.89.E5.8F.96.E9.80.82.E7.94.A8.E5.8D.A1.E5.88.B8.E5.88.97.E8.A1.A8.E5.B9.B6.E8.8E.B7.E5.8F.96.E7.94.A8.E6.88.B7.E9.80.89.E6.8B.A9.E4.BF.A1.E6.81.AF" * >微信小店-跳转微信商品页接口</a>
* >微信卡券-拉取适用卡券列表并获取用户选择信息</a> */
*/ openProductSpecificView,
chooseCard, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.8B.89.E5.8F.96.E9.80.82.E7.94.A8.E5.8D.A1.E5.88.B8.E5.88.97.E8.A1.A8.E5.B9.B6.E8.8E.B7.E5.8F.96.E7.94.A8.E6.88.B7.E9.80.89.E6.8B.A9.E4.BF.A1.E6.81.AF"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.89.B9.E9.87.8F.E6.B7.BB.E5.8A.A0.E5.8D.A1.E5.88.B8.E6.8E.A5.E5.8F.A3" * >微信卡券-拉取适用卡券列表并获取用户选择信息</a>
* >微信卡券-批量添加卡券接口</a> */
*/ chooseCard,
addCard, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.89.B9.E9.87.8F.E6.B7.BB.E5.8A.A0.E5.8D.A1.E5.88.B8.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.9F.A5.E7.9C.8B.E5.BE.AE.E4.BF.A1.E5.8D.A1.E5.8C.85.E4.B8.AD.E7.9A.84.E5.8D.A1.E5.88.B8.E6.8E.A5.E5.8F.A3" * >微信卡券-批量添加卡券接口</a>
* >微信卡券-查看微信卡包中的卡券接口</a> */
*/ addCard,
openCard, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.9F.A5.E7.9C.8B.E5.BE.AE.E4.BF.A1.E5.8D.A1.E5.8C.85.E4.B8.AD.E7.9A.84.E5.8D.A1.E5.88.B8.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.A0.B8.E9.94.80.E5.90.8E.E5.86.8D.E6.AC.A1.E8.B5.A0.E9.80.81.E5.8D.A1.E5.88.B8.E6.8E.A5.E5.8F.A3" * >微信卡券-查看微信卡包中的卡券接口</a>
* >微信卡券-核销后再次赠送卡券接口</a> */
*/ openCard,
consumeAndShareCard, /***
/*** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E6.A0.B8.E9.94.80.E5.90.8E.E5.86.8D.E6.AC.A1.E8.B5.A0.E9.80.81.E5.8D.A1.E5.88.B8.E6.8E.A5.E5.8F.A3"
* "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82" * >微信卡券-核销后再次赠送卡券接口</a>
* >微信支付-发起一个微信支付请求</a> */
*/ consumeAndShareCard,
chooseWXPay, /***
/** * <a href=
* <a href= * "http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82"
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BE%AE%E4%BF%A1JS-SDK%E6%8E%A5%E5%8F%A3#.E5.88.9B.E5.BB.BA.E4.BC.81.E4.B8.9A.E5.8F.B7.E4.BC.9A.E8.AF.9D" * >微信支付-发起一个微信支付请求</a>
* >企业号会话-创建企业号会话</a> */
*/ chooseWXPay,
openEnterpriseChat, /**
/** * <a href=
* 企业号-选取联系人(内测) * "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BE%AE%E4%BF%A1JS-SDK%E6%8E%A5%E5%8F%A3#.E5.88.9B.E5.BB.BA.E4.BC.81.E4.B8.9A.E5.8F.B7.E4.BC.9A.E8.AF.9D"
*/ * >企业号会话-创建企业号会话</a>
openEnterpriseContact; */
openEnterpriseChat,
/** /**
* 分享接口集合 * 企业号-选取联系人(内测)
*/ */
public final static JSSDKAPI[] SHARE_APIS = { onMenuShareTimeline, openEnterpriseContact;
onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo,
onMenuShareQZone }; /**
/** * 分享接口集合
* 图像接口集合 */
*/ public final static JSSDKAPI[] SHARE_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ,
public final static JSSDKAPI[] IMAGE_APIS = { chooseImage, previewImage, onMenuShareWeibo, onMenuShareQZone };
uploadImage, downloadImage }; /**
/** * 图像接口集合
* 音频接口集合 */
*/ public final static JSSDKAPI[] IMAGE_APIS = { chooseImage, previewImage, uploadImage, downloadImage };
public final static JSSDKAPI[] RECORD_APIS = { startRecord, stopRecord, /**
onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, * 音频接口集合
uploadVoice, downloadVoice }; */
/** public final static JSSDKAPI[] RECORD_APIS = { startRecord, stopRecord, onVoiceRecordEnd, playVoice, pauseVoice,
* 智能接口集合 stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice };
*/ /**
public final static JSSDKAPI[] SEM_APIS = { translateVoice }; * 智能接口集合
/** */
* 设备信息接口集合 public final static JSSDKAPI[] SEM_APIS = { translateVoice };
*/ /**
public final static JSSDKAPI[] DEVICE_APIS = { getNetworkType }; * 设备信息接口集合
/** */
* 地理位置接口集合 public final static JSSDKAPI[] DEVICE_APIS = { getNetworkType };
*/ /**
public final static JSSDKAPI[] LOCATION_APIS = { openLocation, getLocation }; * 地理位置接口集合
/** */
* 摇一摇周边接口集合 public final static JSSDKAPI[] LOCATION_APIS = { openLocation, getLocation };
*/ /**
public final static JSSDKAPI[] BEACON_APIS = { startSearchBeacons, * 摇一摇周边接口集合
stopSearchBeacons, onSearchBeacons }; */
/** public final static JSSDKAPI[] BEACON_APIS = { startSearchBeacons, stopSearchBeacons, onSearchBeacons };
* 界面操作接口集合 /**
*/ * 界面操作接口集合
public final static JSSDKAPI[] UI_APIS = { hideOptionMenu, showOptionMenu, */
closeWindow, hideMenuItems, showMenuItems, hideAllNonBaseMenuItem, public final static JSSDKAPI[] UI_APIS = { hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems,
showAllNonBaseMenuItem }; showMenuItems, hideAllNonBaseMenuItem, showAllNonBaseMenuItem };
/** /**
* 微信扫一扫接口集合 * 微信扫一扫接口集合
*/ */
public final static JSSDKAPI[] SCAN_APIS = { scanQRCode }; public final static JSSDKAPI[] SCAN_APIS = { scanQRCode };
/** /**
* 微信小店接口集合 * 微信小店接口集合
*/ */
public final static JSSDKAPI[] SHOP_APIS = { openProductSpecificView }; public final static JSSDKAPI[] SHOP_APIS = { openProductSpecificView };
/** /**
* 微信卡券接口集合 * 微信卡券接口集合
*/ */
public final static JSSDKAPI[] CARD_APIS = { chooseCard, addCard, openCard, public final static JSSDKAPI[] CARD_APIS = { chooseCard, addCard, openCard, consumeAndShareCard };
consumeAndShareCard }; /**
/** * 微信支付接口集合
* 微信支付接口集合 */
*/ public final static JSSDKAPI[] PAY_APIS = { chooseWXPay };
public final static JSSDKAPI[] PAY_APIS = { chooseWXPay }; /**
/** * 企业号会话接口集合
* 企业号会话接口集合 */
*/ public final static JSSDKAPI[] CHAT_APIS = { openEnterpriseChat };
public final static JSSDKAPI[] CHAT_APIS = { openEnterpriseChat };
/**
/** * 公众平台全部接口集合
* 公众平台全部接口集合 */
*/ public final static JSSDKAPI[] MP_ALL_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ,
public final static JSSDKAPI[] MP_ALL_APIS = { onMenuShareTimeline, onMenuShareWeibo, onMenuShareQZone, chooseImage, previewImage, uploadImage, downloadImage, startRecord,
onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice,
onMenuShareQZone, chooseImage, previewImage, uploadImage, translateVoice, getNetworkType, openLocation, getLocation, startSearchBeacons, stopSearchBeacons,
downloadImage, startRecord, stopRecord, onVoiceRecordEnd, onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, showMenuItems,
playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, hideAllNonBaseMenuItem, showAllNonBaseMenuItem, scanQRCode, openProductSpecificView, chooseCard, addCard,
downloadVoice, translateVoice, getNetworkType, openLocation, openCard, consumeAndShareCard, chooseWXPay };
getLocation, startSearchBeacons, stopSearchBeacons, /**
onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, * 企业号全部接口集合
hideMenuItems, showMenuItems, hideAllNonBaseMenuItem, */
showAllNonBaseMenuItem, scanQRCode, openProductSpecificView, public final static JSSDKAPI[] QY_ALL_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ,
chooseCard, addCard, openCard, consumeAndShareCard, chooseWXPay }; onMenuShareWeibo, onMenuShareQZone, chooseImage, previewImage, uploadImage, downloadImage, startRecord,
/** stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice,
* 企业号全部接口集合 translateVoice, getNetworkType, openLocation, getLocation, startSearchBeacons, stopSearchBeacons,
*/ onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, showMenuItems,
public final static JSSDKAPI[] QY_ALL_APIS = { onMenuShareTimeline, hideAllNonBaseMenuItem, showAllNonBaseMenuItem, scanQRCode, openEnterpriseChat, openEnterpriseContact };
onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, }
onMenuShareQZone, chooseImage, previewImage, uploadImage,
downloadImage, startRecord, stopRecord, onVoiceRecordEnd,
playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice,
downloadVoice, translateVoice, getNetworkType, openLocation,
getLocation, startSearchBeacons, stopSearchBeacons,
onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow,
hideMenuItems, showMenuItems, hideAllNonBaseMenuItem,
showAllNonBaseMenuItem, scanQRCode, openEnterpriseChat,
openEnterpriseContact };
}

View File

@ -1,88 +1,88 @@
package com.foxinmy.weixin4j.model; package com.foxinmy.weixin4j.model;
import java.io.Serializable; import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
/** /**
* access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token,正常情况下access_token有效期为7200秒, * access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token,正常情况下access_token有效期为7200秒,
* 重复获取将导致上次获取的access_token失效 * 重复获取将导致上次获取的access_token失效
* *
* @className Token * @className Token
* @author jy.hu * @author jy.hu
* @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>
*/ */
public class Token implements Serializable { public class Token implements Serializable {
private static final long serialVersionUID = -7564855472419104084L; private static final long serialVersionUID = -7564855472419104084L;
/** /**
* 获取到的凭证 * 获取到的凭证
*/ */
@JSONField(name = "access_token") @JSONField(name = "access_token")
private String accessToken; private String accessToken;
/** /**
* 凭证有效时间单位 * 凭证有效时间单位
*/ */
@JSONField(name = "expires_in") @JSONField(name = "expires_in")
private int expiresIn; private int expiresIn;
/** /**
* token创建的时间 * token创建的时间
*/ */
private long createTime; private long createTime;
/** /**
* 请求返回的原始结果 * 请求返回的原始结果
*/ */
private String originalResult; private String originalResult;
public Token() { public Token() {
this.createTime = System.currentTimeMillis() / 1000l; this.createTime = System.currentTimeMillis() / 1000l;
} }
public Token(String accessToken) { public Token(String accessToken) {
this.accessToken = accessToken; this.accessToken = accessToken;
} }
public String getAccessToken() { public String getAccessToken() {
return accessToken; return accessToken;
} }
public void setAccessToken(String accessToken) { public void setAccessToken(String accessToken) {
this.accessToken = accessToken; this.accessToken = accessToken;
} }
public int getExpiresIn() { public int getExpiresIn() {
return expiresIn; return expiresIn;
} }
public void setExpiresIn(int expiresIn) { public void setExpiresIn(int expiresIn) {
this.expiresIn = expiresIn; this.expiresIn = expiresIn;
} }
public long getCreateTime() { public long getCreateTime() {
return createTime; return createTime;
} }
public void setCreateTime(long createTime) { public void setCreateTime(long createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public String getOriginalResult() { public String getOriginalResult() {
return originalResult; return originalResult;
} }
public void setOriginalResult(String originalResult) { public void setOriginalResult(String originalResult) {
this.originalResult = originalResult; this.originalResult = originalResult;
} }
@Override @Override
public String toString() { public String toString() {
return "Token [accessToken=" + accessToken + ", expiresIn=" + expiresIn return "Token [accessToken=" + accessToken + ", expiresIn=" + expiresIn
+ ", createTime=" + createTime + "]"; + ", createTime=" + createTime + "]";
} }
} }

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

@ -1,66 +1,66 @@
package com.foxinmy.weixin4j.type; package com.foxinmy.weixin4j.type;
/** /**
* 自定义菜单类型 </br> <font * 自定义菜单类型 </br> <font
* color="red">请注意scancode_push到location_select的所有事件仅支持微信iPhone5.4.1以上版本和Android5.4以上版本的微信用户 * color="red">请注意scancode_push到location_select的所有事件仅支持微信iPhone5.4.1以上版本和Android5.4以上版本的微信用户
* 旧版本微信用户点击后将没有回应 * 旧版本微信用户点击后将没有回应
* 开发者也不能正常接收到事件推送media_id和view_limited是专门给第三方平台旗下未微信认证具体而言是资质认证未通过的订阅号准备的事件类型 * 开发者也不能正常接收到事件推送media_id和view_limited是专门给第三方平台旗下未微信认证具体而言是资质认证未通过的订阅号准备的事件类型
* 它们是没有事件推送的能力相对受限其他类型的公众号不必使用</font> * 它们是没有事件推送的能力相对受限其他类型的公众号不必使用</font>
* *
* @className ButtonType * @className ButtonType
* @author jy * @author jy
* @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 {
/** /**
* 点击推事件 用户点击click类型按钮后微信服务器会通过消息接口推送消息类型为event * 点击推事件 用户点击click类型按钮后微信服务器会通过消息接口推送消息类型为event
* 的结构给开发者参考消息接口指南并且带上按钮中开发者填写的key值开发者可以通过自定义的key值与用户进行交互 * 的结构给开发者参考消息接口指南并且带上按钮中开发者填写的key值开发者可以通过自定义的key值与用户进行交互
*/ */
click, click,
/** /**
* 跳转URL 用户点击view类型按钮后微信客户端将会打开开发者在按钮中填写的网页URL可与网页授权获取用户基本信息接口结合获得用户基本信息 * 跳转URL 用户点击view类型按钮后微信客户端将会打开开发者在按钮中填写的网页URL可与网页授权获取用户基本信息接口结合获得用户基本信息
*/ */
view, view,
/** /**
* 扫码推事件 用户点击按钮后微信客户端将调起扫一扫工具完成扫码操作后显示扫描结果如果是URL将进入URL且会将扫码的结果传给开发者 * 扫码推事件 用户点击按钮后微信客户端将调起扫一扫工具完成扫码操作后显示扫描结果如果是URL将进入URL且会将扫码的结果传给开发者
* 开发者可以下发消息 * 开发者可以下发消息
*/ */
scancode_push, scancode_push,
/** /**
* 扫码推事件且弹出消息接收中提示框用户点击按钮后微信客户端将调起扫一扫工具完成扫码操作后将扫码的结果传给开发者同时收起扫一扫工具 * 扫码推事件且弹出消息接收中提示框用户点击按钮后微信客户端将调起扫一扫工具完成扫码操作后将扫码的结果传给开发者同时收起扫一扫工具
* 然后弹出消息接收中提示框随后可能会收到开发者下发的消息 * 然后弹出消息接收中提示框随后可能会收到开发者下发的消息
*/ */
scancode_waitmsg, scancode_waitmsg,
/** /**
* 弹出系统拍照发图用户点击按钮后微信客户端将调起系统相机完成拍照操作后会将拍摄的相片发送给开发者并推送事件给开发者同时收起系统相机 * 弹出系统拍照发图用户点击按钮后微信客户端将调起系统相机完成拍照操作后会将拍摄的相片发送给开发者并推送事件给开发者同时收起系统相机
* 随后可能会收到开发者下发的消息 * 随后可能会收到开发者下发的消息
*/ */
pic_sysphoto, pic_sysphoto,
/** /**
* 弹出拍照或者相册发图用户点击按钮后微信客户端将弹出选择器供用户选择拍照或者从手机相册选择用户选择后即走其他两种流程 * 弹出拍照或者相册发图用户点击按钮后微信客户端将弹出选择器供用户选择拍照或者从手机相册选择用户选择后即走其他两种流程
*/ */
pic_photo_or_album, pic_photo_or_album,
/** /**
* 弹出微信相册发图器用户点击按钮后微信客户端将调起微信相册完成选择操作后将选择的相片发送给开发者的服务器并推送事件给开发者同时收起相册 * 弹出微信相册发图器用户点击按钮后微信客户端将调起微信相册完成选择操作后将选择的相片发送给开发者的服务器并推送事件给开发者同时收起相册
* 随后可能会收到开发者下发的消息 * 随后可能会收到开发者下发的消息
*/ */
pic_weixin, pic_weixin,
/** /**
* 弹出地理位置选择器用户点击按钮后微信客户端将调起地理位置选择工具完成选择操作后将选择的地理位置发送给开发者的服务器同时收起位置选择工具 * 弹出地理位置选择器用户点击按钮后微信客户端将调起地理位置选择工具完成选择操作后将选择的地理位置发送给开发者的服务器同时收起位置选择工具
* 随后可能会收到开发者下发的消息 * 随后可能会收到开发者下发的消息
*/ */
location_select, location_select,
/** /**
* 下发消息除文本消息:用户点击media_id类型按钮后微信服务器会将开发者填写的永久素材id对应的素材下发给用户永久素材类型可以是图片 * 下发消息除文本消息:用户点击media_id类型按钮后微信服务器会将开发者填写的永久素材id对应的素材下发给用户永久素材类型可以是图片
* 音频视频图文消息 请注意永久素材id必须是在素材管理/新增永久素材接口上传后获得的合法id * 音频视频图文消息 请注意永久素材id必须是在素材管理/新增永久素材接口上传后获得的合法id
*/ */
media_id, media_id,
/** /**
* 跳转图文消息URL:用户点击view_limited类型按钮后微信客户端将打开开发者在按钮中填写的永久素材id对应的图文消息URL * 跳转图文消息URL:用户点击view_limited类型按钮后微信客户端将打开开发者在按钮中填写的永久素材id对应的图文消息URL
* 永久素材类型只支持图文消息 请注意永久素材id必须是在素材管理/新增永久素材接口上传后获得的合法id * 永久素材类型只支持图文消息 请注意永久素材id必须是在素材管理/新增永久素材接口上传后获得的合法id
*/ */
view_limited; view_limited;
} }

View File

@ -1,25 +1,25 @@
package com.foxinmy.weixin4j.type; 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 {
/** /**
* 不校验真实姓名 * 不校验真实姓名
*/ */
NO_CHECK, NO_CHECK,
/** /**
* 强校验真实姓名未实名认证的用户会校验失败无法转账 * 强校验真实姓名未实名认证的用户会校验失败无法转账
*/ */
FORCE_CHECK, FORCE_CHECK,
/** /**
* 针对已实名认证的用户才校验真实姓名未实名认证用户不校验可以转账成功 * 针对已实名认证的用户才校验真实姓名未实名认证用户不校验可以转账成功
*/ */
OPTION_CHECK; OPTION_CHECK;
} }

View File

@ -1,107 +1,107 @@
package com.foxinmy.weixin4j.util; 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;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory; import org.xml.sax.helpers.XMLReaderFactory;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse; import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
/** /**
* 接口调用错误获取 * 接口调用错误获取
* *
* @className WeixinErrorUtil * @className WeixinErrorUtil
* @author jy * @author jy
* @date 2015年5月12日 * @date 2015年5月12日
* @since JDK 1.6 * @since JDK 1.6
* @see * @see
*/ */
public final class WeixinErrorUtil { 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"));
} catch (IOException e) { } catch (IOException e) {
; ;
} }
} }
private static class ErrorTextHandler extends DefaultHandler { private static class ErrorTextHandler extends DefaultHandler {
private final String code; private final String code;
public ErrorTextHandler(String code) { public ErrorTextHandler(String code) {
this.code = code; this.code = code;
} }
private String text; private String text;
private boolean codeElement; private boolean codeElement;
private boolean textElement; private boolean textElement;
private boolean findElement; private boolean findElement;
@Override @Override
public void startElement(String uri, String localName, String qName, public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException { Attributes attributes) throws SAXException {
codeElement = qName.equalsIgnoreCase("code"); codeElement = qName.equalsIgnoreCase("code");
textElement = qName.equalsIgnoreCase("text"); textElement = qName.equalsIgnoreCase("text");
} }
@Override @Override
public void endElement(String uri, String localName, String qName) public void endElement(String uri, String localName, String qName)
throws SAXException { throws SAXException {
} }
@Override @Override
public void characters(char[] ch, int start, int length) public void characters(char[] ch, int start, int length)
throws SAXException { throws SAXException {
String _text = new String(ch, start, length); String _text = new String(ch, start, length);
if (codeElement && _text.equalsIgnoreCase(code)) { if (codeElement && _text.equalsIgnoreCase(code)) {
findElement = true; findElement = true;
} else if (textElement && findElement) { } else if (textElement && findElement) {
text = _text; text = _text;
throw new SAXException("ENOUGH"); throw new SAXException("ENOUGH");
} }
} }
public String getText() { public String getText() {
return StringUtil.isBlank(text) ? "未知错误" : text; return StringUtil.isBlank(text) ? "未知错误" : text;
} }
} }
public static String getText(String code) throws RuntimeException { public static String getText(String code) throws RuntimeException {
String text = errorCacheMap.get(code); String text = errorCacheMap.get(code);
if (StringUtil.isBlank(text)) { if (StringUtil.isBlank(text)) {
ErrorTextHandler textHandler = new ErrorTextHandler(code); ErrorTextHandler textHandler = new ErrorTextHandler(code);
try { try {
XMLReader xmlReader = XMLReaderFactory.createXMLReader(); XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(textHandler); xmlReader.setContentHandler(textHandler);
xmlReader.parse(new InputSource(new ByteArrayInputStream( xmlReader.parse(new InputSource(new ByteArrayInputStream(
errorXmlByteArray))); errorXmlByteArray)));
text = textHandler.getText(); text = textHandler.getText();
errorCacheMap.put(code, text); errorCacheMap.put(code, text);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (SAXException e) { } catch (SAXException e) {
text = textHandler.getText(); text = textHandler.getText();
errorCacheMap.put(code, text); errorCacheMap.put(code, text);
} }
} }
return text; return text;
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(getText("40001")); System.out.println(getText("40001"));
System.out.println(getText("40001")); System.out.println(getText("40001"));
System.out.println(getText("1234")); System.out.println(getText("1234"));
} }
} }

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);