PrePay codeUrl file change to payUrl
This commit is contained in:
parent
291c263a54
commit
38e2f62154
3
pom.xml
3
pom.xml
@ -45,12 +45,13 @@
|
|||||||
<module>weixin4j-qy</module>
|
<module>weixin4j-qy</module>
|
||||||
<module>weixin4j-server</module>
|
<module>weixin4j-server</module>
|
||||||
<module>weixin4j-example</module>
|
<module>weixin4j-example</module>
|
||||||
|
<module>weixin4j-serverX</module>
|
||||||
</modules>
|
</modules>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.6</maven.compiler.source>
|
<maven.compiler.source>1.6</maven.compiler.source>
|
||||||
<maven.compiler.target>1.6</maven.compiler.target>
|
<maven.compiler.target>1.6</maven.compiler.target>
|
||||||
<fastjson.version>1.2.3</fastjson.version>
|
<fastjson.version>1.2.31</fastjson.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@ -134,9 +134,10 @@ public class PayApi extends MchApi {
|
|||||||
return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount);
|
return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else if (TradeType.NATIVE.name().equals(tradeType)) {
|
} else if (TradeType.NATIVE.name().equals(tradeType)) {
|
||||||
return new NATIVEPayRequest(prePay.getPrepayId(),
|
return new NATIVEPayRequest(prePay.getPrepayId(),
|
||||||
prePay.getCodeUrl(), weixinAccount);
|
prePay.getPayUrl(), weixinAccount);
|
||||||
} else if (TradeType.WAP.name().equals(tradeType)) {
|
} else if (TradeType.MWEB.name().equals(tradeType)) {
|
||||||
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
|
return new WAPPayRequest(prePay.getPrepayId(), prePay.getPayUrl(),
|
||||||
|
weixinAccount);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("unknown tradeType:" + tradeType);
|
throw new WeixinException("unknown tradeType:" + tradeType);
|
||||||
}
|
}
|
||||||
@ -341,7 +342,8 @@ public class PayApi extends MchApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建WAP支付请求对象
|
* 创建WAP支付请求对象:正常流程用户支付完成后会返回至发起支付的页面,如需返回至指定页面,
|
||||||
|
* 则可以在MWEB_URL后拼接上redirect_url参数,来指定回调页面
|
||||||
*
|
*
|
||||||
* @param body
|
* @param body
|
||||||
* 商品描述
|
* 商品描述
|
||||||
@ -366,8 +368,8 @@ public class PayApi extends MchApi {
|
|||||||
double totalFee, String notifyUrl, String createIp, String attach)
|
double totalFee, String notifyUrl, String createIp, String attach)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||||
totalFee, notifyUrl, createIp, TradeType.WAP, null, null, null,
|
totalFee, notifyUrl, createIp, TradeType.MWEB, null, null,
|
||||||
attach);
|
null, attach);
|
||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,7 +472,6 @@ public class PayApi extends MchApi {
|
|||||||
double totalFee, double refundFee, CurrencyType refundFeeType,
|
double totalFee, double refundFee, CurrencyType refundFeeType,
|
||||||
String opUserId, RefundAccountType refundAccountType)
|
String opUserId, RefundAccountType refundAccountType)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
WeixinResponse response = null;
|
|
||||||
Map<String, String> map = createBaseRequestMap(idQuery);
|
Map<String, String> map = createBaseRequestMap(idQuery);
|
||||||
map.put("out_refund_no", outRefundNo);
|
map.put("out_refund_no", outRefundNo);
|
||||||
map.put("total_fee",
|
map.put("total_fee",
|
||||||
@ -491,7 +492,7 @@ public class PayApi extends MchApi {
|
|||||||
map.put("refund_account", refundAccountType.name());
|
map.put("refund_account", refundAccountType.name());
|
||||||
map.put("sign", weixinSignature.sign(map));
|
map.put("sign", weixinSignature.sign(map));
|
||||||
String param = XmlStream.map2xml(map);
|
String param = XmlStream.map2xml(map);
|
||||||
response = getWeixinSSLExecutor().post(
|
WeixinResponse response = getWeixinSSLExecutor().post(
|
||||||
getRequestUri("refund_apply_uri"), param);
|
getRequestUri("refund_apply_uri"), param);
|
||||||
return response.getAsObject(new TypeReference<RefundResult>() {
|
return response.getAsObject(new TypeReference<RefundResult>() {
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.foxinmy.weixin4j.payment.mch;
|
|||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElements;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.type.TradeType;
|
import com.foxinmy.weixin4j.type.TradeType;
|
||||||
@ -35,10 +36,12 @@ public class PrePay extends MerchantResult {
|
|||||||
@XmlElement(name = "prepay_id")
|
@XmlElement(name = "prepay_id")
|
||||||
private String prepayId;
|
private String prepayId;
|
||||||
/**
|
/**
|
||||||
* trade_type 为 NATIVE 是有 返回,此参数可直接生成二 维码展示出来进行扫码支付 可能为空
|
* 对于trade_type 为 NATIVE 或者 MWEB 是有 返回</br> NATVIE支付:可直接生成二维码展示出来进行扫码支付可能为空</br>
|
||||||
|
* MWEB支付:可直接作为跳转支付的URL
|
||||||
*/
|
*/
|
||||||
@XmlElement(name = "code_url")
|
@XmlElements({ @XmlElement(name = "code_url"),
|
||||||
private String codeUrl;
|
@XmlElement(name = "mweb_url") })
|
||||||
|
private String payUrl;
|
||||||
|
|
||||||
protected PrePay() {
|
protected PrePay() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
@ -64,17 +67,17 @@ public class PrePay extends MerchantResult {
|
|||||||
this.prepayId = prepayId;
|
this.prepayId = prepayId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodeUrl() {
|
public String getPayUrl() {
|
||||||
return codeUrl;
|
return payUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodeUrl(String codeUrl) {
|
public void setPayUrl(String payUrl) {
|
||||||
this.codeUrl = codeUrl;
|
this.payUrl = payUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PrePay [tradeType=" + tradeType + ", prepayId=" + prepayId
|
return "PrePay [tradeType=" + tradeType + ", prepayId=" + prepayId
|
||||||
+ ", codeUrl=" + codeUrl + ", " + super.toString() + "]";
|
+ ", payUrl=" + payUrl + ", " + super.toString() + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,10 +3,6 @@ package com.foxinmy.weixin4j.payment.mch;
|
|||||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||||
import com.foxinmy.weixin4j.payment.PayRequest;
|
import com.foxinmy.weixin4j.payment.PayRequest;
|
||||||
import com.foxinmy.weixin4j.type.TradeType;
|
import com.foxinmy.weixin4j.type.TradeType;
|
||||||
import com.foxinmy.weixin4j.util.Consts;
|
|
||||||
import com.foxinmy.weixin4j.util.DigestUtil;
|
|
||||||
import com.foxinmy.weixin4j.util.MapUtil;
|
|
||||||
import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WAP支付
|
* WAP支付
|
||||||
@ -21,14 +17,21 @@ import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
|||||||
* 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>
|
||||||
*/
|
*/
|
||||||
public class WAPPayRequest extends AbstractPayRequest {
|
public class WAPPayRequest extends AbstractPayRequest {
|
||||||
|
/**
|
||||||
|
* 微信支付URL
|
||||||
|
*/
|
||||||
|
private final String payUrl;
|
||||||
|
|
||||||
public WAPPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
public WAPPayRequest(String prePayId, String payUrl,
|
||||||
|
WeixinPayAccount payAccount) {
|
||||||
super(prePayId, payAccount);
|
super(prePayId, payAccount);
|
||||||
|
this.payUrl = payUrl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TradeType getPaymentType() {
|
public TradeType getPaymentType() {
|
||||||
return TradeType.WAP;
|
return TradeType.MWEB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,14 +47,15 @@ public class WAPPayRequest extends AbstractPayRequest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toRequestString() {
|
public String toRequestString() {
|
||||||
PayRequest payRequest = toRequestObject();
|
// PayRequest payRequest = toRequestObject();
|
||||||
String original = MapUtil.toJoinString(payRequest, true, true);
|
// String original = MapUtil.toJoinString(payRequest, true, true);
|
||||||
String sign = DigestUtil.MD5(
|
// String sign = DigestUtil.MD5(
|
||||||
String.format("%s&key=%s", original, getPaymentAccount()
|
// String.format("%s&key=%s", original, getPaymentAccount()
|
||||||
.getPaySignKey())).toUpperCase();
|
// .getPaySignKey())).toUpperCase();
|
||||||
return String.format("weixin://wap/pay?%s",
|
// return String.format("weixin://wap/pay?%s",
|
||||||
URLEncodingUtil.encoding(
|
// URLEncodingUtil.encoding(
|
||||||
String.format("%s&sign=%s", original, sign),
|
// String.format("%s&sign=%s", original, sign),
|
||||||
Consts.UTF_8, true));
|
// Consts.UTF_8, true));
|
||||||
|
return this.payUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,5 +29,5 @@ public enum TradeType {
|
|||||||
/**
|
/**
|
||||||
* WAP支付
|
* WAP支付
|
||||||
*/
|
*/
|
||||||
WAP;
|
MWEB;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public class PayTest {
|
|||||||
c.set(Calendar.DAY_OF_MONTH, 4);
|
c.set(Calendar.DAY_OF_MONTH, 4);
|
||||||
System.err.println(c.getTime());
|
System.err.println(c.getTime());
|
||||||
OutputStream os = new FileOutputStream("/tmp/bill20160813.txt");
|
OutputStream os = new FileOutputStream("/tmp/bill20160813.txt");
|
||||||
PAY.downloadBill(c.getTime(), BillType.ALL, os,null);
|
PAY.downloadBill(c.getTime(), BillType.ALL, os, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@ -13,11 +13,17 @@
|
|||||||
<url>https://github.com/foxinmy/weixin4j/tree/master/weixin4j-server</url>
|
<url>https://github.com/foxinmy/weixin4j/tree/master/weixin4j-server</url>
|
||||||
<description>微信消息netty服务器</description>
|
<description>微信消息netty服务器</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>4.1.8.Final</version>
|
<version>4.1.8.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user