优化扫码支付(Native)
This commit is contained in:
@@ -171,10 +171,9 @@ public class Pay2Api extends MpApi {
|
||||
map.put("productid", productId);
|
||||
map.put("appkey", weixinAccount.getPaySignKey());
|
||||
String sign = DigestUtil.paysignSha(map, null);
|
||||
return String
|
||||
.format("weixin://wxpay/bizpayurl?sign=%s&appid=%s&productid=%s×tamp=%s&nocestr=%s",
|
||||
sign, weixinAccount.getId(), productId, timestamp,
|
||||
noncestr);
|
||||
String ordernative_v2_uri = getRequestUri("ordernative_v2_uri");
|
||||
return String.format(ordernative_v2_uri, sign, weixinAccount.getId(),
|
||||
productId, timestamp, noncestr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# \u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u6587\u6863\u8bf4\u660e
|
||||
# http://mp.weixin.qq.com/wiki/index.php
|
||||
# http://mp.weixin.qq.com/wiki/0/2e2239fa5f49388d5b5136ecc8e0e440.html
|
||||
@@ -130,6 +129,8 @@ getcallbackip_uri={api_cgi_url}/getcallbackip?access_token=%s
|
||||
|
||||
# v2\u8ba2\u5355\u67e5\u8be2
|
||||
orderquery_v2_uri={api_base_url}/pay/orderquery?access_token=%s
|
||||
# v2native\u652f\u4ed8
|
||||
ordernative_v2_uri=weixin://wxpay/bizpayurl?sign=%s&appid=%s&productid=%s×tamp=%s&nocestr=%s\udbff\udce0\udbff\udce0\udbff\udce0\udbff\udce0\udbff\udc57\udbff\udc57\udbff\udc57\udbff\udc57\udbff\udc71\udbff\udc71\udbff\udc71\udbff\udc71\udbff\udc54\udbff\udc54\udbff\udc54\udbff\udc54\udbff\udc53\udbff\udc53\udbff\udc53\udbff\udc53\udbff\udce0\udbff\udce0\udbff\udce0\udbff\udce0\udbff\udc76\udbff\udc76\udbff\udc76\udbff\udc76\udbff\udcdc\udbff\udcdc\udbff\udcdc\udbff\udcdc\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcde\udbff\udcde\udbff\udcde\udbff\udcde\udbff\udc69\udbff\udc69\udbff\udc69\udbff\udc69\udbff\udcdf\udbff\udcdf\udbff\udcdf\udbff\udcdf\udbff\udc69\udbff\udc69\udbff\udc69\udbff\udc69\udbff\udc77\udbff\udc77\udbff\udc77\udbff\udc77\udbff\udc57\udbff\udc57\udbff\udc57\udbff\udc57\udbff\udc71\udbff\udc71\udbff\udc71\udbff\udc71\udbff\udc54\udbff\udc54\udbff\udc54\udbff\udc54\udbff\udc68\udbff\udc68\udbff\udc68\udbff\udc68\udbff\udcdc\udbff\udcdc\udbff\udcdc\udbff\udcdc\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd\udbff\udcdd
|
||||
# \u53d1\u8d27\u901a\u77e5
|
||||
delivernotify_uri={api_base_url}/pay/delivernotify?access_token=%s
|
||||
# \u7ef4\u6743\u5904\u7406
|
||||
|
||||
@@ -37,7 +37,7 @@ public class JsPayRequestV2 extends PayRequest {
|
||||
|
||||
public JsPayRequestV2(WeixinPayAccount weixinAccount,
|
||||
PayPackageV2 payPackage) {
|
||||
this.setAppId(weixinAccount.getId());
|
||||
super(weixinAccount.getId(), "");
|
||||
this.setPackageInfo(package2string(payPackage,
|
||||
weixinAccount.getPartnerKey()));
|
||||
}
|
||||
|
||||
+27
-37
@@ -7,14 +7,10 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.DigestUtil;
|
||||
import com.foxinmy.weixin4j.util.RandomUtil;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
/**
|
||||
* V2 Native支付时的回调响应
|
||||
@@ -43,58 +39,52 @@ public class NativePayResponseV2 extends JsPayRequestV2 {
|
||||
@XmlElement(name = "RetErrMsg")
|
||||
private String retMsg;
|
||||
|
||||
@XmlTransient
|
||||
@JSONField(serialize = false)
|
||||
private WeixinPayAccount weixinAccount;
|
||||
|
||||
protected NativePayResponseV2() {
|
||||
// jaxb required
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应错误信息
|
||||
*
|
||||
* @param errorMsg
|
||||
* 错误信息
|
||||
*/
|
||||
public NativePayResponseV2(String errorMsg) {
|
||||
this.retCode = "-1";
|
||||
this.retMsg = errorMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 正确响应
|
||||
*
|
||||
* @param weixinAccount
|
||||
* @param payPackage
|
||||
* 订单信息
|
||||
*/
|
||||
public NativePayResponseV2(WeixinPayAccount weixinAccount,
|
||||
PayPackageV2 payPackage) {
|
||||
super(weixinAccount, payPackage);
|
||||
this.retCode = "0";
|
||||
this.retMsg = "OK";
|
||||
this.weixinAccount = weixinAccount;
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("appid", weixinAccount.getId());
|
||||
map.put("appkey", weixinAccount.getPaySignKey());
|
||||
map.put("timestamp", getTimeStamp());
|
||||
map.put("noncestr", getNonceStr());
|
||||
map.put("package", getPackageInfo());
|
||||
map.put("retcode", getRetCode());
|
||||
map.put("reterrmsg", getRetMsg());
|
||||
this.setPaySign(DigestUtil.paysignSha(map, null));
|
||||
}
|
||||
|
||||
public String getRetCode() {
|
||||
return retCode;
|
||||
}
|
||||
|
||||
public void setRetCode(String retCode) {
|
||||
this.retCode = retCode;
|
||||
}
|
||||
|
||||
public String getRetMsg() {
|
||||
return retMsg;
|
||||
}
|
||||
|
||||
public void setRetMsg(String retMsg) {
|
||||
this.retMsg = retMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 回调字符串
|
||||
*
|
||||
* @return native回调字符串
|
||||
*/
|
||||
@XmlTransient
|
||||
@JSONField(serialize = false)
|
||||
public String asReqeustXml() {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("appid", weixinAccount.getId());
|
||||
map.put("appkey", weixinAccount.getPaySignKey());
|
||||
map.put("timestamp", DateUtil.timestamp2string());
|
||||
map.put("noncestr", RandomUtil.generateString(16));
|
||||
map.put("package", getPackageInfo());
|
||||
map.put("retcode", getRetCode());
|
||||
map.put("reterrmsg", getRetMsg());
|
||||
this.setPaySign(DigestUtil.paysignSha(map, null));
|
||||
return XmlStream.toXML(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NativePayResponseV2 [retCode=" + retCode + ", retMsg=" + retMsg
|
||||
|
||||
Reference in New Issue
Block a user