重要:com.foxinmy.weixin4j.payment.mch.MchPayPackage构造函数新增notifyUrl支付回调URL参数

This commit is contained in:
jinyu 2015-11-21 21:47:53 +08:00
parent e6a46b1ece
commit a4d660e7b0
3 changed files with 12 additions and 12 deletions

View File

@ -17,12 +17,12 @@ import com.foxinmy.weixin4j.payment.mch.Order;
import com.foxinmy.weixin4j.payment.mch.PrePay; import com.foxinmy.weixin4j.payment.mch.PrePay;
import com.foxinmy.weixin4j.type.SignType; import com.foxinmy.weixin4j.type.SignType;
import com.foxinmy.weixin4j.type.TradeType; import com.foxinmy.weixin4j.type.TradeType;
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DateUtil;
import com.foxinmy.weixin4j.util.DigestUtil; import com.foxinmy.weixin4j.util.DigestUtil;
import com.foxinmy.weixin4j.util.MapUtil; import com.foxinmy.weixin4j.util.MapUtil;
import com.foxinmy.weixin4j.util.RandomUtil; import com.foxinmy.weixin4j.util.RandomUtil;
import com.foxinmy.weixin4j.util.StringUtil; import com.foxinmy.weixin4j.util.StringUtil;
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
import com.foxinmy.weixin4j.xml.XmlStream; import com.foxinmy.weixin4j.xml.XmlStream;
/** /**
@ -81,8 +81,7 @@ public class PayUtil {
String orderNo, double orderFee, String notifyUrl, String ip, String orderNo, double orderFee, String notifyUrl, String ip,
WeixinPayAccount weixinAccount) throws PayException { WeixinPayAccount weixinAccount) throws PayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, openId, MchPayPackage payPackage = new MchPayPackage(weixinAccount, openId,
body, orderNo, orderFee, ip, TradeType.JSAPI); body, orderNo, orderFee, notifyUrl, ip, TradeType.JSAPI);
payPackage.setNotifyUrl(notifyUrl);
return createPayJsRequestJson(payPackage, weixinAccount); return createPayJsRequestJson(payPackage, weixinAccount);
} }
@ -228,6 +227,8 @@ public class PayUtil {
* 商户内部唯一订单号 * 商户内部唯一订单号
* @param totalFee * @param totalFee
* 商品总额 单位元 * 商品总额 单位元
* @param notifyUrl
* 支付回调URL
* @param createIp * @param createIp
* 订单生成的机器 IP * 订单生成的机器 IP
* @return 支付链接 * @return 支付链接
@ -238,10 +239,10 @@ public class PayUtil {
*/ */
public static String createNativePayRequestURL( public static String createNativePayRequestURL(
WeixinPayAccount weixinAccount, String productId, String body, WeixinPayAccount weixinAccount, String productId, String body,
String outTradeNo, double totalFee, String createIp) String outTradeNo, double totalFee, String notifyUrl,
throws PayException { String createIp) throws PayException {
MchPayPackage payPackage = new MchPayPackage(weixinAccount, null, body, MchPayPackage payPackage = new MchPayPackage(weixinAccount, null, body,
outTradeNo, totalFee, createIp, TradeType.NATIVE); outTradeNo, totalFee, createIp, notifyUrl, TradeType.NATIVE);
payPackage.setProductId(productId); payPackage.setProductId(productId);
String paySignKey = weixinAccount.getPaySignKey(); String paySignKey = weixinAccount.getPaySignKey();
payPackage.setSign(paysignMd5(payPackage, paySignKey)); payPackage.setSign(paysignMd5(payPackage, paySignKey));

View File

@ -69,7 +69,7 @@ public class MchPayPackage extends PayPackage {
@JSONField(name = "openid") @JSONField(name = "openid")
private String openId; private String openId;
/** /**
* 只在 trade_type NATIVE 时需要填写 非必须 * 只在 trade_type NATIVE 模式一 时需要填写 非必须
*/ */
@XmlElement(name = "product_id") @XmlElement(name = "product_id")
@JSONField(name = "product_id") @JSONField(name = "product_id")
@ -80,10 +80,10 @@ public class MchPayPackage extends PayPackage {
} }
public MchPayPackage(WeixinPayAccount weixinAccount, String openId, public MchPayPackage(WeixinPayAccount weixinAccount, String openId,
String body, String outTradeNo, double totalFee, String body, String outTradeNo, double totalFee, String notifyUrl,
String spbillCreateIp, TradeType tradeType) { String spbillCreateIp, TradeType tradeType) {
this(weixinAccount, openId, body, null, outTradeNo, totalFee, null, this(weixinAccount, openId, body, null, outTradeNo, totalFee,
spbillCreateIp, tradeType); notifyUrl, spbillCreateIp, tradeType);
} }
public MchPayPackage(WeixinPayAccount weixinAccount, String openId, public MchPayPackage(WeixinPayAccount weixinAccount, String openId,

View File

@ -137,9 +137,8 @@ public class PayTest {
public void nativeV3() throws WeixinException { public void nativeV3() throws WeixinException {
MchPayPackage payPackageV3 = new MchPayPackage(ACCOUNT3, MchPayPackage payPackageV3 = new MchPayPackage(ACCOUNT3,
"oyFLst1bqtuTcxK-ojF8hOGtLQao", "native测试", "T0001", 0.1d, "oyFLst1bqtuTcxK-ojF8hOGtLQao", "native测试", "T0001", 0.1d,
"127.0.0.1", TradeType.NATIVE); "notify_url", "127.0.0.1", TradeType.NATIVE);
payPackageV3.setProductId("0001"); payPackageV3.setProductId("0001");
payPackageV3.setNotifyUrl("xxxx");
PrePay prePay = null; PrePay prePay = null;
try { try {
prePay = PayUtil.createPrePay(payPackageV3, prePay = PayUtil.createPrePay(payPackageV3,