|
|
|
@@ -82,8 +82,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 微信支付接口实现(使用weixin4j.properties配置的account商户信息)
|
|
|
|
|
*/
|
|
|
|
|
public WeixinPayProxy() {
|
|
|
|
|
this(JSON.parseObject(Weixin4jConfigUtil.getValue("account"),
|
|
|
|
|
WeixinPayAccount.class));
|
|
|
|
|
this(JSON.parseObject(Weixin4jConfigUtil.getValue("account"), WeixinPayAccount.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -94,8 +93,7 @@ public class WeixinPayProxy {
|
|
|
|
|
*/
|
|
|
|
|
public WeixinPayProxy(WeixinPayAccount weixinPayAccount) {
|
|
|
|
|
if (weixinPayAccount == null) {
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"weixinPayAccount must not be empty");
|
|
|
|
|
throw new IllegalArgumentException("weixinPayAccount must not be empty");
|
|
|
|
|
}
|
|
|
|
|
this.weixinPayAccount = weixinPayAccount;
|
|
|
|
|
this.payApi = new PayApi(weixinPayAccount);
|
|
|
|
@@ -156,8 +154,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* @see com.foxinmy.weixin4j.payment.mch.MchPayRequest#toRequestString()
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public MchPayRequest createPayRequest(MchPayPackage payPackage)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public MchPayRequest createPayRequest(MchPayPackage payPackage) throws WeixinException {
|
|
|
|
|
return payApi.createPayRequest(payPackage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -184,11 +181,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* @return JSAPI支付对象
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public MchPayRequest createJSPayRequest(String openId, String body,
|
|
|
|
|
String outTradeNo, double totalFee, String notifyUrl,
|
|
|
|
|
String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee,
|
|
|
|
|
notifyUrl, createIp, attach);
|
|
|
|
|
public MchPayRequest createJSPayRequest(String openId, String body, String outTradeNo, double totalFee,
|
|
|
|
|
String notifyUrl, String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -196,11 +191,16 @@ public class WeixinPayProxy {
|
|
|
|
|
* 生成编辑地址请求
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* err_msg edit_address:ok获取编辑收货地址成功</br> edit_address:fail获取编辑收货地址失败</br>
|
|
|
|
|
* userName 收货人姓名</br> telNumber 收货人电话</br> addressPostalCode 邮编</br>
|
|
|
|
|
* proviceFirstStageName 国标收货地址第一级地址</br> addressCitySecondStageName
|
|
|
|
|
* 国标收货地址第二级地址</br> addressCountiesThirdStageName 国标收货地址第三级地址</br>
|
|
|
|
|
* addressDetailInfo 详细收货地址信息</br> nationalCode 收货地址国家码</br>
|
|
|
|
|
* err_msg edit_address:ok获取编辑收货地址成功</br>
|
|
|
|
|
* edit_address:fail获取编辑收货地址失败</br>
|
|
|
|
|
* userName 收货人姓名</br>
|
|
|
|
|
* telNumber 收货人电话</br>
|
|
|
|
|
* addressPostalCode 邮编</br>
|
|
|
|
|
* proviceFirstStageName 国标收货地址第一级地址</br>
|
|
|
|
|
* addressCitySecondStageName 国标收货地址第二级地址</br>
|
|
|
|
|
* addressCountiesThirdStageName 国标收货地址第三级地址</br>
|
|
|
|
|
* addressDetailInfo 详细收货地址信息</br>
|
|
|
|
|
* nationalCode 收货地址国家码</br>
|
|
|
|
|
*
|
|
|
|
|
* @param url
|
|
|
|
|
* 当前访问页的URL
|
|
|
|
@@ -262,11 +262,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* </a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public NativePayResponse createNativePayResponse(String productId,
|
|
|
|
|
String body, String outTradeNo, double totalFee, String notifyUrl,
|
|
|
|
|
String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createNativePayResponse(productId, body, outTradeNo,
|
|
|
|
|
totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
public NativePayResponse createNativePayResponse(String productId, String body, String outTradeNo, double totalFee,
|
|
|
|
|
String notifyUrl, String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createNativePayResponse(productId, body, outTradeNo, totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -298,11 +296,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* </a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public MchPayRequest createNativePayRequest(String productId, String body,
|
|
|
|
|
String outTradeNo, double totalFee, String notifyUrl,
|
|
|
|
|
String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createNativePayRequest(productId, body, outTradeNo,
|
|
|
|
|
totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
public MchPayRequest createNativePayRequest(String productId, String body, String outTradeNo, double totalFee,
|
|
|
|
|
String notifyUrl, String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createNativePayRequest(productId, body, outTradeNo, totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -329,11 +325,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* APP支付</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public MchPayRequest createAppPayRequest(String body, String outTradeNo,
|
|
|
|
|
double totalFee, String notifyUrl, String createIp, String attach)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return payApi.createAppPayRequest(body, outTradeNo, totalFee,
|
|
|
|
|
notifyUrl, createIp, attach);
|
|
|
|
|
public MchPayRequest createAppPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl,
|
|
|
|
|
String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createAppPayRequest(body, outTradeNo, totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -360,11 +354,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* </a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public MchPayRequest createWapPayRequest(String body, String outTradeNo,
|
|
|
|
|
double totalFee, String notifyUrl, String createIp, String attach)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return payApi.createWapPayRequest(body, outTradeNo, totalFee,
|
|
|
|
|
notifyUrl, createIp, attach);
|
|
|
|
|
public MchPayRequest createWapPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl,
|
|
|
|
|
String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createWapPayRequest(body, outTradeNo, totalFee, notifyUrl, createIp, attach);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -392,18 +384,18 @@ public class WeixinPayProxy {
|
|
|
|
|
* 提交被扫支付API</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
|
|
|
|
String outTradeNo, double totalFee, String createIp, String attach)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return payApi.createMicroPayRequest(authCode, body, outTradeNo,
|
|
|
|
|
totalFee, createIp, attach);
|
|
|
|
|
public MchPayRequest createMicroPayRequest(String authCode, String body, String outTradeNo, double totalFee,
|
|
|
|
|
String createIp, String attach) throws WeixinException {
|
|
|
|
|
return payApi.createMicroPayRequest(authCode, body, outTradeNo, totalFee, createIp, attach);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 订单查询
|
|
|
|
|
* <p>
|
|
|
|
|
* 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;</br> 调用支付接口后,返回系统错误或未知交易状态情况;</br>
|
|
|
|
|
* 调用被扫支付API,返回USERPAYING的状态;</br> 调用关单或撤销接口API之前,需确认支付状态;
|
|
|
|
|
* 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;</br>
|
|
|
|
|
* 调用支付接口后,返回系统错误或未知交易状态情况;</br>
|
|
|
|
|
* 调用被扫支付API,返回USERPAYING的状态;</br>
|
|
|
|
|
* 调用关单或撤销接口API之前,需确认支付状态;
|
|
|
|
|
* </P>
|
|
|
|
|
*
|
|
|
|
|
* @param idQuery
|
|
|
|
@@ -458,12 +450,10 @@ public class WeixinPayProxy {
|
|
|
|
|
* @since V3
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
|
|
|
|
double totalFee, double refundFee, CurrencyType refundFeeType,
|
|
|
|
|
String opUserId, RefundAccountType refundAccountType)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return payApi.applyRefund(idQuery, outRefundNo, totalFee, refundFee,
|
|
|
|
|
refundFeeType, opUserId, refundAccountType);
|
|
|
|
|
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee, double refundFee,
|
|
|
|
|
CurrencyType refundFeeType, String opUserId, RefundAccountType refundAccountType) throws WeixinException {
|
|
|
|
|
return payApi.applyRefund(idQuery, outRefundNo, totalFee, refundFee, refundFeeType, opUserId,
|
|
|
|
|
refundAccountType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -473,8 +463,7 @@ public class WeixinPayProxy {
|
|
|
|
|
*
|
|
|
|
|
* @see {@link #applyRefund(IdQuery, String, double, double, String,CurrencyType)}
|
|
|
|
|
*/
|
|
|
|
|
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
|
|
|
|
double totalFee) throws WeixinException {
|
|
|
|
|
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee) throws WeixinException {
|
|
|
|
|
return payApi.applyRefund(idQuery, outRefundNo, totalFee);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -523,16 +512,18 @@ public class WeixinPayProxy {
|
|
|
|
|
* 下载对账单API</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public void downloadBill(Date billDate, BillType billType,
|
|
|
|
|
OutputStream outputStream, TarType tarType) throws WeixinException {
|
|
|
|
|
public void downloadBill(Date billDate, BillType billType, OutputStream outputStream, TarType tarType)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
payApi.downloadBill(billDate, billType, outputStream, tarType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 冲正订单(需要证书)</br> 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br> 接口逻辑:支
|
|
|
|
|
* 付失败的关单,支付成功的撤销支付</br> <font color="red">7天以内的单可撤销,其他正常支付的单
|
|
|
|
|
* 如需实现相同功能请调用退款接口</font></br> <font
|
|
|
|
|
* color="red">调用扣款接口后请勿立即调用撤销,需要等待5秒以上。先调用查单接口,如果没有确切的返回,再调用撤销</font> </br>
|
|
|
|
|
* 冲正订单(需要证书)</br>
|
|
|
|
|
* 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br>
|
|
|
|
|
* 接口逻辑:支 付失败的关单,支付成功的撤销支付</br>
|
|
|
|
|
* <font color="red">7天以内的单可撤销,其他正常支付的单 如需实现相同功能请调用退款接口</font></br>
|
|
|
|
|
* <font color="red">调用扣款接口后请勿立即调用撤销,需要等待5秒以上。先调用查单接口,如果没有确切的返回,再调用撤销</font>
|
|
|
|
|
* </br>
|
|
|
|
|
*
|
|
|
|
|
* @param idQuery
|
|
|
|
|
* 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
|
|
|
|
@@ -608,11 +599,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* 接口测试上报API</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public XmlResult reportInterface(String interfaceUrl, int executeTime,
|
|
|
|
|
String outTradeNo, String ip, Date time, XmlResult returnXml)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return payApi.reportInterface(interfaceUrl, executeTime, outTradeNo,
|
|
|
|
|
ip, time, returnXml);
|
|
|
|
|
public XmlResult reportInterface(String interfaceUrl, int executeTime, String outTradeNo, String ip, Date time,
|
|
|
|
|
XmlResult returnXml) throws WeixinException {
|
|
|
|
|
return payApi.reportInterface(interfaceUrl, executeTime, outTradeNo, ip, time, returnXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -634,10 +623,9 @@ public class WeixinPayProxy {
|
|
|
|
|
* 发放代金券接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CouponResult sendCoupon(String couponStockId, String partnerTradeNo,
|
|
|
|
|
String openId, String opUserId) throws WeixinException {
|
|
|
|
|
return couponApi.sendCoupon(couponStockId, partnerTradeNo, openId,
|
|
|
|
|
opUserId);
|
|
|
|
|
public CouponResult sendCoupon(String couponStockId, String partnerTradeNo, String openId, String opUserId)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return couponApi.sendCoupon(couponStockId, partnerTradeNo, openId, opUserId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -653,14 +641,15 @@ public class WeixinPayProxy {
|
|
|
|
|
* 查询代金券批次信息接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CouponStock queryCouponStock(String couponStockId)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public CouponStock queryCouponStock(String couponStockId) throws WeixinException {
|
|
|
|
|
return couponApi.queryCouponStock(couponStockId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询代金券详细
|
|
|
|
|
*
|
|
|
|
|
* @param openId
|
|
|
|
|
* 用户ID
|
|
|
|
|
* @param couponId
|
|
|
|
|
* 代金券ID
|
|
|
|
|
* @return 代金券详细信息
|
|
|
|
@@ -671,9 +660,8 @@ public class WeixinPayProxy {
|
|
|
|
|
* 查询代金券详细信息接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CouponDetail queryCouponDetail(String couponId)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return couponApi.queryCouponDetail(couponId);
|
|
|
|
|
public CouponDetail queryCouponDetail(String openId, String couponId) throws WeixinException {
|
|
|
|
|
return couponApi.queryCouponDetail(openId, couponId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -693,8 +681,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 发放裂变红包接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public RedpacketSendResult sendRedpack(Redpacket redpacket)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public RedpacketSendResult sendRedpack(Redpacket redpacket) throws WeixinException {
|
|
|
|
|
return cashApi.sendRedpack(redpacket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -708,8 +695,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* @see #sendRedpacks(Redpacket...)
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public List<Future<RedpacketSendResult>> sendRedpacks(
|
|
|
|
|
Redpacket... redpackets) {
|
|
|
|
|
public List<Future<RedpacketSendResult>> sendRedpacks(Redpacket... redpackets) {
|
|
|
|
|
return cashApi.sendRedpacks(redpackets);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -729,8 +715,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 查询裂变红包接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public RedpacketRecord queryRedpack(String outTradeNo)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public RedpacketRecord queryRedpack(String outTradeNo) throws WeixinException {
|
|
|
|
|
return cashApi.queryRedpack(outTradeNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -757,8 +742,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 企业付款接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CorpPaymentResult sendCorpPayment(CorpPayment payment)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public CorpPaymentResult sendCorpPayment(CorpPayment payment) throws WeixinException {
|
|
|
|
|
return cashApi.sendCorpPayment(payment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -775,8 +759,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 企业付款查询接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CorpPaymentRecord queryCorpPayment(String outTradeNo)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public CorpPaymentRecord queryCorpPayment(String outTradeNo) throws WeixinException {
|
|
|
|
|
return cashApi.queryCorpPayment(outTradeNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -816,8 +799,8 @@ public class WeixinPayProxy {
|
|
|
|
|
* "https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_14&index=7">
|
|
|
|
|
* 查询结算资金接口</a>
|
|
|
|
|
*/
|
|
|
|
|
public SettlementRecord querySettlement(boolean status, Pageable pageable,
|
|
|
|
|
Date start, Date end) throws WeixinException {
|
|
|
|
|
public SettlementRecord querySettlement(boolean status, Pageable pageable, Date start, Date end)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
return cashApi.querySettlement(status, pageable, start, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -835,8 +818,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* "https://pay.weixin.qq.com/wiki/doc/api/external/micropay.php?chapter=9_15&index=8">
|
|
|
|
|
* 查询汇率接口</a>
|
|
|
|
|
*/
|
|
|
|
|
public double queryExchageRate(CurrencyType currencyType, Date date)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public double queryExchageRate(CurrencyType currencyType, Date date) throws WeixinException {
|
|
|
|
|
return cashApi.queryExchageRate(currencyType, date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -854,8 +836,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 附加订单信息提交接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder)
|
|
|
|
|
throws WeixinException {
|
|
|
|
|
public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) throws WeixinException {
|
|
|
|
|
return customsApi.declareCustomsOrder(customsOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -874,8 +855,7 @@ public class WeixinPayProxy {
|
|
|
|
|
* 附加订单信息查询接口</a>
|
|
|
|
|
* @throws WeixinException
|
|
|
|
|
*/
|
|
|
|
|
public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery,
|
|
|
|
|
CustomsCity customsCity) throws WeixinException {
|
|
|
|
|
public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, CustomsCity customsCity) throws WeixinException {
|
|
|
|
|
return customsApi.queryCustomsOrder(idQuery, customsCity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|