新增海关接口

This commit is contained in:
jinyu 2016-03-27 17:40:35 +08:00
parent 223ba9d693
commit 1a2530d4c6
20 changed files with 746 additions and 149 deletions

View File

@ -663,4 +663,6 @@
+ weixin4j-base:删除Mciro支付接口,新增MCIROPayRequest对象 + weixin4j-base:删除Mciro支付接口,新增MCIROPayRequest对象
+ weixin4j-base:支付对象优化 + weixin4j-base:支付对象优化
+ weixin4j-base:新增海关接口

View File

@ -54,11 +54,12 @@ public class CashApi extends MchApi {
* @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="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5">发放红包接口说明</a> * href="https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_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);
JSONObject obj = (JSONObject) JSON.toJSON(redpacket); JSONObject obj = (JSONObject) JSON.toJSON(redpacket);
obj.put("wxappid", obj.remove("appid")); obj.put("wxappid", obj.remove("appid"));
obj.put("sign", weixinSignature.sign(obj)); obj.put("sign", weixinSignature.sign(obj));
@ -136,6 +137,7 @@ public class CashApi extends MchApi {
*/ */
public CorpPaymentResult sendCorpPayment(InputStream certificate, public CorpPaymentResult sendCorpPayment(InputStream certificate,
CorpPayment payment) throws WeixinException { CorpPayment payment) throws WeixinException {
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"));
obj.put("mch_appid", obj.remove("appid")); obj.put("mch_appid", obj.remove("appid"));

View File

@ -0,0 +1,84 @@
package com.foxinmy.weixin4j.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.mch.CustomsOrder;
import com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord;
import com.foxinmy.weixin4j.payment.mch.CustomsOrderResult;
import com.foxinmy.weixin4j.type.CustomsCity;
import com.foxinmy.weixin4j.type.IdQuery;
import com.foxinmy.weixin4j.xml.ListsuffixResultDeserializer;
import com.foxinmy.weixin4j.xml.XmlStream;
/**
* 报关接口
*
* @className CustomsApi
* @author jy
* @date 2016年3月67日
* @since JDK 1.7
* @see
*/
public class CustomsApi extends MchApi {
public CustomsApi(WeixinPayAccount weixinAccount) {
super(weixinAccount);
}
/**
* 订单附加信息提交
*
* @param customsOrder
* 附加订单信息
* @return 报关结果
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrder
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult
* @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a>
* @throws WeixinException
*/
public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder)
throws WeixinException {
JSONObject para = (JSONObject) JSON.toJSON(customsOrder);
para.put("appid", weixinAccount.getId());
para.put("mch_id", weixinAccount.getMchId());
para.put("sign", weixinSignature.sign(para));
String param = XmlStream.map2xml(para);
WeixinResponse response = weixinExecutor.post(
getRequestUri("customsorder_declare_uri"), param);
return response.getAsObject(new TypeReference<CustomsOrderResult>() {
});
}
/**
* 订单附加信息查询
*
* @param idQuery
* out_trade_no,transaction_id,sub_order_no,sub_order_id四选一
* @param customsCity
* 海关
* @return 报关记录
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord
* @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a>
* @throws WeixinException
*/
public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery,
CustomsCity customsCity) throws WeixinException {
JSONObject para = new JSONObject();
para.put("appid", weixinAccount.getId());
para.put("mch_id", weixinAccount.getMchId());
para.put(idQuery.getType().getName(), idQuery.getId());
para.put("customs", customsCity.name());
para.put("sign", weixinSignature.sign(para));
String param = XmlStream.map2xml(para);
WeixinResponse response = weixinExecutor.post(
getRequestUri("customsorder_query_uri"), param);
return ListsuffixResultDeserializer.deserialize(response.getAsString(),
CustomsOrderRecord.class);
}
}

View File

@ -18,7 +18,6 @@ import java.util.Map;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.foxinmy.weixin4j.exception.WeixinException; import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.exception.WeixinPayException;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse; import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.http.weixin.XmlResult; import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.model.Consts; import com.foxinmy.weixin4j.model.Consts;
@ -79,27 +78,14 @@ public class PayApi extends MchApi {
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口</a> * href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口</a>
* @return 预支付对象 * @return 预支付对象
*/ */
public PrePay createPrePay(MchPayPackage payPackage) public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException {
throws WeixinPayException { payPackage.declareWeixinPayAccount(weixinAccount);
payPackage.setSign(weixinSignature.sign(payPackage)); payPackage.setSign(weixinSignature.sign(payPackage));
String payJsRequestXml = XmlStream.toXML(payPackage); String payJsRequestXml = XmlStream.toXML(payPackage);
try { WeixinResponse response = weixinExecutor.post(
WeixinResponse response = weixinExecutor.post( getRequestUri("order_create_uri"), payJsRequestXml);
getRequestUri("order_create_uri"), payJsRequestXml); return response.getAsObject(new TypeReference<PrePay>() {
PrePay prePay = response.getAsObject(new TypeReference<PrePay>() { });
});
if (!prePay.getReturnCode().equalsIgnoreCase(Consts.SUCCESS)) {
throw new WeixinPayException(prePay.getReturnMsg(),
prePay.getReturnCode());
}
if (!prePay.getResultCode().equalsIgnoreCase(Consts.SUCCESS)) {
throw new WeixinPayException(prePay.getResultCode(),
prePay.getErrCodeDes());
}
return prePay;
} catch (WeixinException e) {
throw new WeixinPayException(e.getErrorCode(), e.getErrorMsg());
}
} }
/** /**
@ -113,10 +99,10 @@ public class PayApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付 * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付 * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(MchPayPackage payPackage) public MchPayRequest createPayRequest(MchPayPackage payPackage)
throws WeixinPayException { 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)) {
@ -130,19 +116,15 @@ public class PayApi extends MchApi {
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);
try { WeixinResponse response = weixinExecutor.post(
WeixinResponse response = weixinExecutor.post( getRequestUri("micropay_uri"), para);
getRequestUri("micropay_uri"), para); MICROPayRequest microPayRequest = response
MICROPayRequest microPayRequest = response .getAsObject(new TypeReference<MICROPayRequest>() {
.getAsObject(new TypeReference<MICROPayRequest>() { });
}); microPayRequest.setPaymentAccount(weixinAccount);
microPayRequest.setPaymentAccount(weixinAccount); return microPayRequest;
return microPayRequest;
} catch (WeixinException e) {
throw new WeixinPayException(e);
}
} else { } else {
throw new WeixinPayException("unknown tradeType:" + tradeType); throw new WeixinException("unknown tradeType:" + tradeType);
} }
} }
@ -185,17 +167,17 @@ public class PayApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付 * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付 * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(String body, String detail, public MchPayRequest createPayRequest(String body, String detail,
String outTradeNo, double totalFee, String notifyUrl, String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String openId, String createIp, TradeType tradeType, String openId,
String productId, String attach, Date timeStart, Date timeExpire, String productId, String attach, Date timeStart, Date timeExpire,
String goodsTag, String limitPay, String subOpenId) String goodsTag, String limitPay, String subOpenId)
throws WeixinPayException { throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
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);
@ -224,14 +206,14 @@ public class PayApi extends MchApi {
* 附加数据 非必填 * 附加数据 非必填
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest * @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest
* @return JSAPI支付对象 * @return JSAPI支付对象
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createJSPayRequest(String openId, String body, public MchPayRequest createJSPayRequest(String openId, String body,
String outTradeNo, double totalFee, String notifyUrl, String outTradeNo, double totalFee, String notifyUrl,
String createIp, String attach) throws WeixinPayException { String createIp, String attach) throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.JSAPI, totalFee, notifyUrl, createIp, TradeType.JSAPI, openId, null,
openId, null, null, attach); null, attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -317,14 +299,14 @@ public class PayApi extends MchApi {
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a>
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a> * href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public NativePayResponse createNativePayResponse(String productId, public NativePayResponse createNativePayResponse(String productId,
String body, String outTradeNo, double totalFee, String notifyUrl, String body, String outTradeNo, double totalFee, String notifyUrl,
String createIp, String attach) throws WeixinPayException { String createIp, String attach) throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE, totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
null, null, productId, attach); productId, attach);
PrePay prePay = createPrePay(payPackage); PrePay prePay = createPrePay(payPackage);
return new NativePayResponse(weixinAccount, prePay.getPrepayId()); return new NativePayResponse(weixinAccount, prePay.getPrepayId());
} }
@ -351,14 +333,14 @@ public class PayApi extends MchApi {
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a>
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二</a> * href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createNativePayRequest(String productId, String body, public MchPayRequest createNativePayRequest(String productId, String body,
String outTradeNo, double totalFee, String notifyUrl, String outTradeNo, double totalFee, String notifyUrl,
String createIp, String attach) throws WeixinPayException { String createIp, String attach) throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.NATIVE, totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
null, null, productId, attach); productId, attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -381,14 +363,14 @@ public class PayApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
* @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.php?chapter=8_1">APP支付</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createAppPayRequest(String body, String outTradeNo, public MchPayRequest createAppPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp, String attach) double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException { throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.APP, null, totalFee, notifyUrl, createIp, TradeType.APP, null, null, null,
null, null, attach); attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -411,14 +393,14 @@ public class PayApi extends MchApi {
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a> * href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createWAPPayRequest(String body, String outTradeNo, public MchPayRequest createWAPPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp, String attach) double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException { throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
outTradeNo, totalFee, notifyUrl, createIp, TradeType.WAP, null, totalFee, notifyUrl, createIp, TradeType.WAP, null, null, null,
null, null, attach); attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }
@ -447,9 +429,9 @@ public class PayApi extends MchApi {
public MchPayRequest createMICROPayRequest(String authCode, String body, public MchPayRequest createMICROPayRequest(String authCode, String body,
String outTradeNo, double totalFee, String createIp, String attach) String outTradeNo, double totalFee, String createIp, String attach)
throws WeixinException { throws WeixinException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, body, MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
outTradeNo, totalFee, null, createIp, TradeType.MICROPAY, null, totalFee, null, createIp, TradeType.MICROPAY, null, null, null,
null, null, attach); attach);
return createPayRequest(payPackage); return createPayRequest(payPackage);
} }

View File

@ -8,7 +8,6 @@ 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.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.mch.MerchantResult; import com.foxinmy.weixin4j.payment.mch.MerchantResult;
import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DateUtil;
@ -91,8 +90,6 @@ public class PayPackage extends MerchantResult {
/** /**
* 订单对象 * 订单对象
* *
* @param weixinPayAccount
* 商户信息 必填
* @param body * @param body
* 订单描述 必填 * 订单描述 必填
* @param detail * @param detail
@ -114,11 +111,9 @@ public class PayPackage extends MerchantResult {
* @param goodsTag * @param goodsTag
* 订单标记 非必填 * 订单标记 非必填
*/ */
public PayPackage(WeixinPayAccount weixinPayAccount, String body, public PayPackage(String body, String detail, String outTradeNo,
String detail, String outTradeNo, double totalFee, double totalFee, String notifyUrl, String createIp, String attach,
String notifyUrl, String createIp, String attach, Date timeStart, Date timeStart, Date timeExpire, String goodsTag) {
Date timeExpire, String goodsTag) {
super(weixinPayAccount);
this.body = body; this.body = body;
this.detail = detail; this.detail = detail;
this.outTradeNo = outTradeNo; this.outTradeNo = outTradeNo;

View File

@ -8,9 +8,9 @@ import java.util.Date;
import com.foxinmy.weixin4j.api.CashApi; import com.foxinmy.weixin4j.api.CashApi;
import com.foxinmy.weixin4j.api.CouponApi; import com.foxinmy.weixin4j.api.CouponApi;
import com.foxinmy.weixin4j.api.CustomsApi;
import com.foxinmy.weixin4j.api.PayApi; import com.foxinmy.weixin4j.api.PayApi;
import com.foxinmy.weixin4j.exception.WeixinException; import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.exception.WeixinPayException;
import com.foxinmy.weixin4j.http.weixin.XmlResult; import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.model.Pageable; import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.WeixinPayAccount; import com.foxinmy.weixin4j.model.WeixinPayAccount;
@ -20,6 +20,9 @@ import com.foxinmy.weixin4j.payment.coupon.CouponStock;
import com.foxinmy.weixin4j.payment.mch.CorpPayment; import com.foxinmy.weixin4j.payment.mch.CorpPayment;
import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord; import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult; import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
import com.foxinmy.weixin4j.payment.mch.CustomsOrder;
import com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord;
import com.foxinmy.weixin4j.payment.mch.CustomsOrderResult;
import com.foxinmy.weixin4j.payment.mch.MchPayPackage; import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
import com.foxinmy.weixin4j.payment.mch.MchPayRequest; import com.foxinmy.weixin4j.payment.mch.MchPayRequest;
import com.foxinmy.weixin4j.payment.mch.MerchantResult; import com.foxinmy.weixin4j.payment.mch.MerchantResult;
@ -35,6 +38,7 @@ import com.foxinmy.weixin4j.payment.mch.RefundResult;
import com.foxinmy.weixin4j.payment.mch.SettlementRecord; import com.foxinmy.weixin4j.payment.mch.SettlementRecord;
import com.foxinmy.weixin4j.type.BillType; import com.foxinmy.weixin4j.type.BillType;
import com.foxinmy.weixin4j.type.CurrencyType; import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.type.CustomsCity;
import com.foxinmy.weixin4j.type.IdQuery; import com.foxinmy.weixin4j.type.IdQuery;
import com.foxinmy.weixin4j.type.TradeType; import com.foxinmy.weixin4j.type.TradeType;
import com.foxinmy.weixin4j.util.Weixin4jSettings; import com.foxinmy.weixin4j.util.Weixin4jSettings;
@ -62,6 +66,10 @@ public class WeixinPayProxy {
* 现金API * 现金API
*/ */
private final CashApi cashApi; private final CashApi cashApi;
/**
* 海关API
*/
private final CustomsApi customsApi;
/** /**
* 配置相关 * 配置相关
*/ */
@ -85,6 +93,7 @@ public class WeixinPayProxy {
this.payApi = new PayApi(settings.getWeixinPayAccount()); this.payApi = new PayApi(settings.getWeixinPayAccount());
this.couponApi = new CouponApi(settings.getWeixinPayAccount()); this.couponApi = new CouponApi(settings.getWeixinPayAccount());
this.cashApi = new CashApi(settings.getWeixinPayAccount()); this.cashApi = new CashApi(settings.getWeixinPayAccount());
this.customsApi = new CustomsApi(settings.getWeixinPayAccount());
} }
/** /**
@ -110,8 +119,7 @@ public class WeixinPayProxy {
* href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口</a> * href="http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单接口</a>
* @return 预支付对象 * @return 预支付对象
*/ */
public PrePay createPrePay(MchPayPackage payPackage) public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException {
throws WeixinPayException {
return payApi.createPrePay(payPackage); return payApi.createPrePay(payPackage);
} }
@ -127,10 +135,10 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付 * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付 * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(MchPayPackage payPackage) public MchPayRequest createPayRequest(MchPayPackage payPackage)
throws WeixinPayException { throws WeixinException {
return payApi.createPayRequest(payPackage); return payApi.createPayRequest(payPackage);
} }
@ -174,14 +182,14 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付 * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest 刷卡支付
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付 * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest APP支付
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createPayRequest(String body, String detail, public MchPayRequest createPayRequest(String body, String detail,
String outTradeNo, double totalFee, String notifyUrl, String outTradeNo, double totalFee, String notifyUrl,
String createIp, TradeType tradeType, String openId, String createIp, TradeType tradeType, String openId,
String productId, String attach, Date timeStart, Date timeExpire, String productId, String attach, Date timeStart, Date timeExpire,
String goodsTag, String limitPay, String subOpenId) String goodsTag, String limitPay, String subOpenId)
throws WeixinPayException { throws WeixinException {
return payApi.createPayRequest(body, detail, outTradeNo, totalFee, return payApi.createPayRequest(body, detail, outTradeNo, totalFee,
notifyUrl, createIp, tradeType, openId, productId, attach, notifyUrl, createIp, tradeType, openId, productId, attach,
timeStart, timeExpire, goodsTag, limitPay, subOpenId); timeStart, timeExpire, goodsTag, limitPay, subOpenId);
@ -207,11 +215,11 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.api.PayApi
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest * @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest
* @return JSAPI支付对象 * @return JSAPI支付对象
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createJSPayRequest(String openId, String body, public MchPayRequest createJSPayRequest(String openId, String body,
String outTradeNo, double totalFee, String notifyUrl, String outTradeNo, double totalFee, String notifyUrl,
String createIp, String attach) throws WeixinPayException { String createIp, String attach) throws WeixinException {
return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee, return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee,
notifyUrl, createIp, attach); notifyUrl, createIp, attach);
} }
@ -278,11 +286,11 @@ public class WeixinPayProxy {
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a>
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a> * href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public NativePayResponse createNativePayResponse(String productId, public NativePayResponse createNativePayResponse(String productId,
String body, String outTradeNo, double totalFee, String notifyUrl, String body, String outTradeNo, double totalFee, String notifyUrl,
String createIp, String attach) throws WeixinPayException { String createIp, String attach) throws WeixinException {
return payApi.createNativePayResponse(productId, body, outTradeNo, return payApi.createNativePayResponse(productId, body, outTradeNo,
totalFee, notifyUrl, createIp, attach); totalFee, notifyUrl, createIp, attach);
} }
@ -310,11 +318,11 @@ public class WeixinPayProxy {
* @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a> * @see <a href="http://pay.weixin.qq.com/wiki/doc/api/native.php">扫码支付</a>
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二</a> * href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createNativePayRequest(String productId, String body, public MchPayRequest createNativePayRequest(String productId, String body,
String outTradeNo, double totalFee, String notifyUrl, String outTradeNo, double totalFee, String notifyUrl,
String createIp, String attach) throws WeixinPayException { String createIp, String attach) throws WeixinException {
return payApi.createNativePayRequest(productId, body, outTradeNo, return payApi.createNativePayRequest(productId, body, outTradeNo,
totalFee, notifyUrl, createIp, attach); totalFee, notifyUrl, createIp, attach);
} }
@ -339,11 +347,11 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
* @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.php?chapter=8_1">APP支付</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createAppPayRequest(String body, String outTradeNo, public MchPayRequest createAppPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp, String attach) double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException { throws WeixinException {
return payApi.createAppPayRequest(body, outTradeNo, totalFee, return payApi.createAppPayRequest(body, outTradeNo, totalFee,
notifyUrl, createIp, attach); notifyUrl, createIp, attach);
} }
@ -368,11 +376,11 @@ public class WeixinPayProxy {
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
* @see <a * @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a> * href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a>
* @throws WeixinPayException * @throws WeixinException
*/ */
public MchPayRequest createWAPPayRequest(String body, String outTradeNo, public MchPayRequest createWAPPayRequest(String body, String outTradeNo,
double totalFee, String notifyUrl, String createIp, String attach) double totalFee, String notifyUrl, String createIp, String attach)
throws WeixinPayException { throws WeixinException {
return payApi.createWAPPayRequest(body, outTradeNo, totalFee, return payApi.createWAPPayRequest(body, outTradeNo, totalFee,
notifyUrl, createIp, attach); notifyUrl, createIp, attach);
} }
@ -891,5 +899,42 @@ public class WeixinPayProxy {
return cashApi.queryExchageRate(currencyType, date); return cashApi.queryExchageRate(currencyType, date);
} }
/**
* 订单附加信息提交
*
* @param customsOrder
* 附加订单信息
* @return 报关结果
* @see com.foxinmy.weixin4j.api.CustomsApi
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrder
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult
* @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a>
* @throws WeixinException
*/
public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder)
throws WeixinException {
return customsApi.declareCustomsOrder(customsOrder);
}
/**
* 订单附加信息查询
*
* @param idQuery
* out_trade_no,transaction_id,sub_order_no,sub_order_id四选一
* @param customsCity
* 海关
* @return 报关记录
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord
* @see com.foxinmy.weixin4j.api.CustomsApi
* @see <a
* href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息</a>
* @throws WeixinException
*/
public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery,
CustomsCity customsCity) throws WeixinException {
return customsApi.queryCustomsOrder(idQuery, customsCity);
}
public final static String VERSION = "1.6.7"; public final static String VERSION = "1.6.7";
} }

View File

@ -6,7 +6,6 @@ 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.model.WeixinPayAccount;
import com.foxinmy.weixin4j.type.MPPaymentCheckNameType; import com.foxinmy.weixin4j.type.MPPaymentCheckNameType;
import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DateUtil;
@ -72,8 +71,6 @@ public class CorpPayment extends MerchantResult {
/** /**
* 企业付款 * 企业付款
* *
* @param weixinPayAccount
* 商户信息
* @param outTradeNo * @param outTradeNo
* 商户的订单号 * 商户的订单号
* @param openId * @param openId
@ -87,10 +84,9 @@ public class CorpPayment extends MerchantResult {
* @param clientIp * @param clientIp
* 调用接口IP * 调用接口IP
*/ */
public CorpPayment(WeixinPayAccount weixinPayAccount, String outTradeNo, public CorpPayment(String outTradeNo, String openId,
String openId, MPPaymentCheckNameType checkNameType, String desc, MPPaymentCheckNameType checkNameType, String desc, double amount,
double amount, String clientIp) { String clientIp) {
super(weixinPayAccount);
this.outTradeNo = outTradeNo; this.outTradeNo = outTradeNo;
this.openId = openId; this.openId = openId;
this.checkNameType = checkNameType; this.checkNameType = checkNameType;

View File

@ -0,0 +1,217 @@
package com.foxinmy.weixin4j.payment.mch;
import javax.xml.bind.annotation.XmlElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.CredentialType;
import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.type.CustomsCity;
/**
* 报关对象
*
* @className CustomsOrder
* @author jy
* @date 2016年3月27日
* @since JDK 1.6
* @see
*/
public class CustomsOrder extends MerchantResult {
private static final long serialVersionUID = 799510373861612386L;
/**
* 微信支付订单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
/**
* 商户订单号
*/
@XmlElement(name = "out_trade_no")
@JSONField(name = "out_trade_no")
private String outTradeNo;
/**
* 商户子订单号如有拆单则必传
*/
@XmlElement(name = "sub_order_no")
@JSONField(name = "sub_order_no")
private String subOrderNo;
/**
* 货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private CurrencyType feeType;
/**
* 子订单金额以分为单位不能超过原订单金额order_fee=transport_fee+product_fee应付金额=物流费+商品价格
* 如有拆单则必传
*/
@XmlElement(name = "order_fee")
@JSONField(name = "order_fee")
private String orderFee;
/**
* 物流费用以分为单位如有拆单则必传
*/
@XmlElement(name = "transport_fee")
@JSONField(name = "transport_fee")
private String transportFee;
/**
* 商品费用以分为单位如有拆单则必传
*/
@XmlElement(name = "product_fee")
@JSONField(name = "product_fee")
private String productFee;
/**
* 关税以分为单位
*/
@XmlElement(name = "duty")
@JSONField(name = "duty")
private String dutyFee;
/**
* 海关
*/
@XmlElement(name = "customs")
@JSONField(name = "customs")
private CustomsCity customsCity;
/**
* 商户在海关登记的备案号customsCity非NO此参数必填
*/
@XmlElement(name = "mch_customs_no")
@JSONField(name = "mch_customs_no")
private String customsNo;
/**
* 证件类型暂只支持身份证该参数是指用户信息商户若有用户信息可上送系统将以商户上传的数据为准进行海关通关报备
*/
@XmlElement(name = "cert_type")
@JSONField(name = "cert_type")
private CredentialType credentialType;
/**
* 证件号码身份证号该参数是指用户信息商户若有用户信息可上送系统将以商户上传的数据为准进行海关通关报备
*/
@XmlElement(name = "cert_id")
@JSONField(name = "cert_id")
private String credentialId;
/**
* 用户姓名该参数是指用户信息商户若有用户信息可上送系统将以商户上传的数据为准进行海关通关报备
*/
@XmlElement(name = "name")
@JSONField(name = "name")
private String uname;
public CustomsOrder(String transactionId, String outTradeNo) {
this.transactionId = transactionId;
this.outTradeNo = outTradeNo;
this.customsCity = CustomsCity.NO;
}
public String getSubOrderNo() {
return subOrderNo;
}
public void setSubOrderNo(String subOrderNo) {
this.subOrderNo = subOrderNo;
}
public CurrencyType getFeeType() {
return feeType;
}
public void setFeeType(CurrencyType feeType) {
this.feeType = feeType;
}
public String getOrderFee() {
return orderFee;
}
public void setOrderFee(String orderFee) {
this.orderFee = orderFee;
}
public String getTransportFee() {
return transportFee;
}
public void setTransportFee(String transportFee) {
this.transportFee = transportFee;
}
public String getProductFee() {
return productFee;
}
public void setProductFee(String productFee) {
this.productFee = productFee;
}
public String getDutyFee() {
return dutyFee;
}
public void setDutyFee(String dutyFee) {
this.dutyFee = dutyFee;
}
public CustomsCity getCustomsCity() {
return customsCity;
}
public void setCustomsCity(CustomsCity customsCity) {
this.customsCity = customsCity;
}
public String getCustomsNo() {
return customsNo;
}
public void setCustomsNo(String customsNo) {
this.customsNo = customsNo;
}
public CredentialType getCredentialType() {
return credentialType;
}
public void setCredentialType(CredentialType credentialType) {
this.credentialType = credentialType;
}
public String getCredentialId() {
return credentialId;
}
public void setCredentialId(String credentialId) {
this.credentialId = credentialId;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getTransactionId() {
return transactionId;
}
public String getOutTradeNo() {
return outTradeNo;
}
@Override
public String toString() {
return "CustomsOrder [transactionId=" + transactionId + ", outTradeNo="
+ outTradeNo + ", subOrderNo=" + subOrderNo + ", feeType="
+ feeType + ", orderFee=" + orderFee + ", transportFee="
+ transportFee + ", productFee=" + productFee + ", dutyFee="
+ dutyFee + ", customsCity=" + customsCity + ", customsNo="
+ customsNo + ", credentialType=" + credentialType
+ ", credentialId=" + credentialId + ", uname=" + uname + ", "
+ super.toString() + "]";
}
}

View File

@ -0,0 +1,73 @@
package com.foxinmy.weixin4j.payment.mch;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
/**
* 报关记录
*
* @className CustomsOrderRecord
* @author jy
* @date 2016年3月27日
* @since JDK 1.6
* @see
*/
public class CustomsOrderRecord extends MerchantResult {
private static final long serialVersionUID = -1675090110657154049L;
/**
* 微信支付订单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
/**
* 笔数
*/
@XmlElement(name = "count")
@JSONField(name = "count")
private int orderCount;
/**
* 报关详情
*
* @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult
*/
@ListsuffixResult
private List<CustomsOrderResult> customsOrderList;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public int getOrderCount() {
return orderCount;
}
public void setOrderCount(int orderCount) {
this.orderCount = orderCount;
}
public List<CustomsOrderResult> getCustomsOrderList() {
return customsOrderList;
}
public void setCustomsOrderList(List<CustomsOrderResult> customsOrderList) {
this.customsOrderList = customsOrderList;
}
@Override
public String toString() {
return "CustomsOrderRecord [transactionId=" + transactionId
+ ", orderCount=" + orderCount + ", customsOrderList="
+ customsOrderList + "]";
}
}

View File

@ -0,0 +1,124 @@
package com.foxinmy.weixin4j.payment.mch;
import java.util.Date;
import javax.xml.bind.annotation.XmlElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.CustomsSatus;
import com.foxinmy.weixin4j.util.DateUtil;
/**
* 报关结果
*
* @className CustomsOrderResult
* @author jy
* @date 2016年3月27日
* @since JDK 1.6
* @see
*/
public class CustomsOrderResult extends MerchantResult {
private static final long serialVersionUID = 799510373861612386L;
/**
* 状态码
*/
private String state;
/**
* 微信支付订单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
/**
* 商户订单号
*/
@XmlElement(name = "out_trade_no")
@JSONField(name = "out_trade_no")
private String outTradeNo;
/**
* 商户子订单号
*/
@XmlElement(name = "sub_order_no")
@JSONField(name = "sub_order_no")
private String subOrderNo;
/**
* 微信子订单号
*
*/
@XmlElement(name = "sub_order_id")
@JSONField(name = "sub_order_id")
private String subOrderId;
/**
* 最后更新时间
*/
@XmlElement(name = "modify_time")
@JSONField(name = "modify_time")
private String modifyTime;
public String getState() {
return state;
}
@JSONField(serialize = false)
public CustomsSatus getFormatState() {
return CustomsSatus.valueOf(state.toUpperCase());
}
public void setState(String state) {
this.state = state;
}
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getOutTradeNo() {
return outTradeNo;
}
public void setOutTradeNo(String outTradeNo) {
this.outTradeNo = outTradeNo;
}
public String getSubOrderNo() {
return subOrderNo;
}
public void setSubOrderNo(String subOrderNo) {
this.subOrderNo = subOrderNo;
}
public String getSubOrderId() {
return subOrderId;
}
public void setSubOrderId(String subOrderId) {
this.subOrderId = subOrderId;
}
public String getModifyTime() {
return modifyTime;
}
@JSONField(serialize = false)
public Date getFormatModifyTime() {
return DateUtil.parse2yyyyMMddHHmmss(modifyTime);
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
@Override
public String toString() {
return "CustomsOrderResult [state=" + state + ", transactionId="
+ transactionId + ", outTradeNo=" + outTradeNo
+ ", subOrderNo=" + subOrderNo + ", subOrderId=" + subOrderId
+ ", modifyTime=" + modifyTime + "]";
}
}

View File

@ -8,7 +8,6 @@ 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.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.PayPackage; import com.foxinmy.weixin4j.payment.PayPackage;
import com.foxinmy.weixin4j.type.TradeType; import com.foxinmy.weixin4j.type.TradeType;
@ -73,8 +72,6 @@ public class MchPayPackage extends PayPackage {
/** /**
* 微信支付 * 微信支付
* *
* @param weixinAccount
* 商户信息 必填
* @param body * @param body
* 支付详情 必填 * 支付详情 必填
* @param outTradeNo * @param outTradeNo
@ -96,20 +93,17 @@ public class MchPayPackage extends PayPackage {
* @param attach * @param attach
* 支付时附加信息 非必填 * 支付时附加信息 非必填
*/ */
public MchPayPackage(WeixinPayAccount weixinAccount, String body, public MchPayPackage(String body, String outTradeNo, double totalFee,
String outTradeNo, double totalFee, String notifyUrl, String notifyUrl, String createIp, TradeType tradeType,
String createIp, TradeType tradeType, String openId, String openId, String authCode, String productId, String attach) {
String authCode, String productId, String attach) { this(body, null, outTradeNo, totalFee, notifyUrl, createIp, tradeType,
this(weixinAccount, body, null, outTradeNo, totalFee, notifyUrl, openId, authCode, productId, attach, null, null, null, null,
createIp, tradeType, openId, authCode, productId, attach, null, null);
null, null, null, null);
} }
/** /**
* 完整参数 * 完整参数
* *
* @param weixinAccount
* 商户信息 必填
* @param body * @param body
* 支付详情 必填 * 支付详情 必填
* @param detail * @param detail
@ -146,14 +140,13 @@ public class MchPayPackage extends PayPackage {
* 用户在子商户appid下的唯一标识 非必填 * 用户在子商户appid下的唯一标识 非必填
* openid和sub_openid可以选传其中之一如果选择传sub_openid ,则必须传sub_appid * openid和sub_openid可以选传其中之一如果选择传sub_openid ,则必须传sub_appid
*/ */
public MchPayPackage(WeixinPayAccount weixinPayAccount, String body, public MchPayPackage(String body, String detial, String outTradeNo,
String detial, String outTradeNo, double totalFee, double totalFee, String notifyUrl, String createIp,
String notifyUrl, String createIp, TradeType tradeType, TradeType tradeType, String openId, String authCode,
String openId, String authCode, String productId, String attach, String productId, String attach, Date timeStart, Date timeExpire,
Date timeStart, Date timeExpire, String goodsTag, String limitPay, String goodsTag, String limitPay, String subOpenId) {
String subOpenId) { super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
super(weixinPayAccount, body, detial, outTradeNo, totalFee, notifyUrl, timeStart, timeExpire, goodsTag);
createIp, attach, timeStart, timeExpire, goodsTag);
this.tradeType = tradeType.name(); this.tradeType = tradeType.name();
this.openId = openId; this.openId = openId;
this.authCode = authCode; this.authCode = authCode;

View File

@ -85,15 +85,6 @@ public class MerchantResult extends XmlResult {
super(returnCode, returnMsg); super(returnCode, returnMsg);
} }
public MerchantResult(WeixinPayAccount weixinPayAccount) {
this.appId = weixinPayAccount.getId();
this.mchId = weixinPayAccount.getMchId();
this.deviceInfo = weixinPayAccount.getDeviceInfo();
this.subId = weixinPayAccount.getSubId();
this.subMchId = weixinPayAccount.getSubMchId();
this.nonceStr = RandomUtil.generateString(16);
}
public String getAppId() { public String getAppId() {
return appId; return appId;
} }
@ -177,6 +168,22 @@ public class MerchantResult extends XmlResult {
return recall != null && recall.equalsIgnoreCase("y"); return recall != null && recall.equalsIgnoreCase("y");
} }
/**
* 赋值给对应字段
*
* @param weixinPayAccount
* 商户信息
*/
@JSONField(deserialize = false)
public void declareWeixinPayAccount(WeixinPayAccount weixinPayAccount) {
this.appId = weixinPayAccount.getId();
this.mchId = weixinPayAccount.getMchId();
this.deviceInfo = weixinPayAccount.getDeviceInfo();
this.subId = weixinPayAccount.getSubId();
this.subMchId = weixinPayAccount.getSubMchId();
this.nonceStr = RandomUtil.generateString(16);
}
@Override @Override
public String toString() { public String toString() {
return "appId=" + appId + ", mchId=" + mchId + ", subId=" + subId return "appId=" + appId + ", mchId=" + mchId + ", subId=" + subId

View File

@ -103,8 +103,6 @@ public class Redpacket extends MerchantResult {
/** /**
* 红包 * 红包
* *
* @param weixinPayAccount
* 商户信息
* @param outTradeNo * @param outTradeNo
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用 必填 * 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用 必填
* @param sendName * @param sendName
@ -127,17 +125,13 @@ public class Redpacket extends MerchantResult {
public Redpacket(WeixinPayAccount weixinPayAccount, String outTradeNo, public Redpacket(WeixinPayAccount weixinPayAccount, String outTradeNo,
String sendName, String openid, double totalAmount, int totalNum, String sendName, String openid, double totalAmount, int totalNum,
String wishing, String clientIp, String actName, String remark) { String wishing, String clientIp, String actName, String remark) {
this(weixinPayAccount, null, null, outTradeNo, sendName, openid, this(null, null, outTradeNo, sendName, openid, totalAmount, totalNum,
totalAmount, totalNum, wishing, clientIp, actName, remark); wishing, clientIp, actName, remark);
} }
/** /**
* 红包 完整参数 * 红包 完整参数
* *
* @param appId
* 公众号唯一标识 必填
* @param mchId
* 微信支付商户号 必填
* @param subMchId * @param subMchId
* 子商户商户号 非必填 * 子商户商户号 非必填
* @param subMsgId * @param subMsgId
@ -163,11 +157,9 @@ public class Redpacket extends MerchantResult {
* @param remark * @param remark
* 备注 必填 * 备注 必填
*/ */
public Redpacket(WeixinPayAccount weixinPayAccount, String subMsgId, public Redpacket(String subMsgId, String consumeMchId, String outTradeNo,
String consumeMchId, String outTradeNo, String sendName, String sendName, String openid, double totalAmount, int totalNum,
String openid, double totalAmount, int totalNum, String wishing, String wishing, String clientIp, String actName, String remark) {
String clientIp, String actName, String remark) {
super(weixinPayAccount);
this.subMsgId = subMsgId; this.subMsgId = subMsgId;
this.consumeMchId = consumeMchId; this.consumeMchId = consumeMchId;
this.outTradeNo = outTradeNo; this.outTradeNo = outTradeNo;

View File

@ -52,4 +52,8 @@ native_pay_uri=weixin://wxpay/bizpayurl?sign=%s&appid=%s&mch_id=%s&product_id=%s
# \u67e5\u8be2\u7ed3\u7b97\u8d44\u91d1 # \u67e5\u8be2\u7ed3\u7b97\u8d44\u91d1
settlement_query_uri={mch_base_url}/pay/settlementquery settlement_query_uri={mch_base_url}/pay/settlementquery
# \u67e5\u8be2\u6c47\u7387 # \u67e5\u8be2\u6c47\u7387
exchagerate_query_uri={mch_base_url}/pay/queryexchagerate exchagerate_query_uri={mch_base_url}/pay/queryexchagerate
# \u8ba2\u5355\u9644\u52a0\u4fe1\u606f\u63d0\u4ea4
customsorder_declare_uri={mch_base_url}/mch/customs/customdeclareorder
# \u8ba2\u5355\u9644\u52a0\u4fe1\u606f\u67e5\u8be2
customsorder_query_uri={mch_base_url}/mch/customs/customdeclarequery

View File

@ -0,0 +1,23 @@
package com.foxinmy.weixin4j.type;
/**
* 证件类型
*
* @className CredentialType
* @author jy
* @date 2016年3月27日
* @since JDK 1.6
* @see
*/
public enum CredentialType {
IDCARD("身份证");
CredentialType(String name) {
this.name = name;
}
private String name;
public String getName() {
return this.name;
}
}

View File

@ -0,0 +1,26 @@
package com.foxinmy.weixin4j.type;
/**
* 海关
*
* @className CustomsCity
* @author jy
* @date 2016年3月27日
* @since JDK 1.6
* @see
*/
public enum CustomsCity {
NO("无需上报海关"), GUANGZHOU("广州"), HANGZHOU("杭州"), NINGBO("宁波"), ZHENGZHOU_BS(
"郑州(保税物流中心)"), CHONGQING("重庆"), XIAN("西安"), SHANGHAI("上海"), ZHENGZHOU_ZH(
"郑州(综保区)");
private String name;
CustomsCity(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}

View File

@ -0,0 +1,24 @@
package com.foxinmy.weixin4j.type;
/**
* 报关状态
*
* @className CustomsSatus
* @author jy
* @date 2016年3月27日
* @since JDK 1.6
* @see
*/
public enum CustomsSatus {
UNDECLARED("未申报"), SUBMITTED("申报已提交"), PROCESSING("申报中"), SUCCESS("申报成功"), FAIL(
"申报失败"), EXCEPT("海关接口异常");
private String sate;
CustomsSatus(String sate) {
this.sate = sate;
}
public String getSate() {
return this.sate;
}
}

View File

@ -25,7 +25,15 @@ public enum IdType {
/** /**
* 商户退款号 * 商户退款号
*/ */
REFUNDNO("out_refund_no"); REFUNDNO("out_refund_no"),
/**
* 商户子订单号
*/
SUBORDERNO("sub_order_no"),
/**
* 微信子订单号
*/
SUBORDERID("sub_order_id");
private String name; private String name;
IdType(String name) { IdType(String name) {

View File

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

View File

@ -107,9 +107,9 @@ public class PayTest {
@Test @Test
public void nativePay() throws WeixinException { public void nativePay() throws WeixinException {
MchPayPackage payPackageV3 = new MchPayPackage(ACCOUNT, "native测试", MchPayPackage payPackageV3 = new MchPayPackage("native测试", "T0001",
"T0001", 0.1d, "notify_url", "127.0.0.1", TradeType.NATIVE, 0.1d, "notify_url", "127.0.0.1", TradeType.NATIVE, null, null,
null, null, "productId", null); "productId", null);
PrePay prePay = null; PrePay prePay = null;
try { try {
prePay = PAY.createPrePay(payPackageV3); prePay = PAY.createPrePay(payPackageV3);