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