diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java index 539d948a..8583da5f 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java @@ -39,6 +39,7 @@ import com.foxinmy.weixin4j.type.IdType; import com.foxinmy.weixin4j.type.SignType; import com.foxinmy.weixin4j.type.TradeType; import com.foxinmy.weixin4j.type.mch.BillType; +import com.foxinmy.weixin4j.type.mch.RefundAccountType; import com.foxinmy.weixin4j.util.Consts; import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DigestUtil; @@ -453,6 +454,8 @@ public class PayApi extends MchApi { * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY * @param opUserId * 操作员帐号, 默认为商户号 + * @param refundAccountType + * 退款资金来源,默认使用未结算资金退款:REFUND_SOURCE_UNSETTLED_FUNDS * @return 退款申请结果 * @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see map = createBaseRequestMap(idQuery); map.put("out_refund_no", outRefundNo); @@ -478,7 +482,11 @@ public class PayApi extends MchApi { if (refundFeeType == null) { refundFeeType = CurrencyType.CNY; } + if (refundAccountType == null) { + refundAccountType = RefundAccountType.REFUND_SOURCE_UNSETTLED_FUNDS; + } map.put("refund_fee_type", refundFeeType.name()); + map.put("refund_account", refundAccountType.name()); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); response = getWeixinSSLExecutor().post( @@ -501,7 +509,8 @@ public class PayApi extends MchApi { */ public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee) throws WeixinException { - return applyRefund(idQuery, outRefundNo, totalFee, totalFee, null, null); + return applyRefund(idQuery, outRefundNo, totalFee, totalFee, null, + null, null); } /** diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java index 93c512a0..10041ec8 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java @@ -40,6 +40,7 @@ import com.foxinmy.weixin4j.type.CurrencyType; import com.foxinmy.weixin4j.type.CustomsCity; import com.foxinmy.weixin4j.type.IdQuery; import com.foxinmy.weixin4j.type.mch.BillType; +import com.foxinmy.weixin4j.type.mch.RefundAccountType; import com.foxinmy.weixin4j.util.Weixin4jConfigUtil; /** @@ -443,7 +444,8 @@ public class WeixinPayProxy { * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY * @param opUserId * 操作员帐号, 默认为商户号 - * + * @param refundAccountType + * 退款资金来源,默认使用未结算资金退款:REFUND_SOURCE_UNSETTLED_FUNDS * @return 退款申请结果 * @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see com.foxinmy.weixin4j.api.PayApi @@ -455,9 +457,10 @@ public class WeixinPayProxy { */ public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee, double refundFee, CurrencyType refundFeeType, - String opUserId) throws WeixinException { + String opUserId, RefundAccountType refundAccountType) + throws WeixinException { return payApi.applyRefund(idQuery, outRefundNo, totalFee, refundFee, - refundFeeType, opUserId); + refundFeeType, opUserId, refundAccountType); } /** diff --git a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java index 126b1f51..0b5f3e16 100644 --- a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java +++ b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java @@ -99,7 +99,7 @@ public class PayTest { IdQuery idQuery = new IdQuery("TT_1427183696238", IdType.TRADENO); RefundResult result = PAY.applyRefund(idQuery, "TT_R" + System.currentTimeMillis(), 0.01d, 0.01d, null, - "10020674"); + "10020674", null); Assert.assertEquals(Consts.SUCCESS, result.getReturnCode()); Assert.assertEquals(Consts.SUCCESS, result.getResultCode()); System.err.println(result);