刷脸支付凭证获得
This commit is contained in:
parent
60e8efef65
commit
fdc7f38d8c
@ -39,6 +39,7 @@ import com.foxinmy.weixin4j.logging.InternalLogLevel;
|
||||
import com.foxinmy.weixin4j.logging.InternalLogger;
|
||||
import com.foxinmy.weixin4j.logging.InternalLoggerFactory;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import static java.util.regex.Pattern.CASE_INSENSITIVE;
|
||||
|
||||
@ -218,10 +219,13 @@ public class WeixinRequestExecutor {
|
||||
try {
|
||||
XmlResult xmlResult = XmlMessageConverter.GLOBAL.convert(
|
||||
XmlResult.class, response);
|
||||
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult
|
||||
.getResultCode().toLowerCase()))) {
|
||||
throw new WeixinException(xmlResult.getErrCode(),
|
||||
xmlResult.getErrCodeDes());
|
||||
// 微信最新的刷脸支付API中已没有返回resultCode,需做非空判断,否则抛异常
|
||||
if(StringUtil.isNotBlank(xmlResult.getResultCode())) {
|
||||
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult
|
||||
.getResultCode().toLowerCase()))) {
|
||||
throw new WeixinException(xmlResult.getErrCode(),
|
||||
xmlResult.getErrCodeDes());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
;
|
||||
|
||||
@ -7,6 +7,8 @@ import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.model.paging.Pageable;
|
||||
import com.foxinmy.weixin4j.pay.payment.coupon.*;
|
||||
import com.foxinmy.weixin4j.pay.payment.face.PayfaceAuthinfo;
|
||||
import com.foxinmy.weixin4j.pay.payment.face.PayfaceAuthinfoRequest;
|
||||
import com.foxinmy.weixin4j.pay.payment.mch.*;
|
||||
import com.foxinmy.weixin4j.pay.sign.WeixinSignature;
|
||||
import com.foxinmy.weixin4j.pay.type.*;
|
||||
@ -815,5 +817,33 @@ public class WeixinPayProxy {
|
||||
return customsApi.queryCustomsOrder(idQuery, customsCity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信刷脸支付,获取调用凭证
|
||||
*
|
||||
* @param storeId
|
||||
* 门店编号, 由商户定义, 各门店唯一。
|
||||
* @param storeName
|
||||
* 门店名称,由商户定义。(可用于展示)
|
||||
* @param deviceId
|
||||
* 终端设备编号,由商户定义。
|
||||
* @param rawdata
|
||||
* 初始化数据。由微信人脸SDK的接口返回。
|
||||
* @return SDK调用凭证
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/wxfacepay/develop/sdk-android.html#获取数据-getwxpayfacerawdata">
|
||||
* 获取数据-getwxpayfacerawdata</a>
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/wxfacepay/develop/sdk-android.html#获取调用凭证-get-wxpayface-authinfo">
|
||||
* 获取调用凭证-get-wxpayface-authinfo</a>
|
||||
* @see PayfaceAuthinfo
|
||||
*/
|
||||
public PayfaceAuthinfo getWxPayfaceAuthinfo(String storeId, String storeName, String deviceId,
|
||||
String rawdata) throws WeixinException {
|
||||
PayfaceAuthinfoRequest request = new PayfaceAuthinfoRequest(this.weixinPayAccount, storeId, storeName, deviceId,
|
||||
rawdata);
|
||||
return payApi.getWxPayfaceAuthinfo(request);
|
||||
}
|
||||
|
||||
public final static String VERSION = Consts.VERSION;
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.pay.payment.face.PayfaceAuthinfo;
|
||||
import com.foxinmy.weixin4j.pay.payment.face.PayfaceAuthinfoRequest;
|
||||
import com.foxinmy.weixin4j.pay.payment.mch.*;
|
||||
import com.foxinmy.weixin4j.pay.type.mch.BillType;
|
||||
import com.foxinmy.weixin4j.pay.type.mch.RefundAccountType;
|
||||
|
||||
@ -33,4 +33,12 @@ public class PayfaceAuthinfo extends MerchantResult {
|
||||
* 人脸支付凭证(getWxpayfaceCode)</a>
|
||||
*/
|
||||
private String authinfo;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PayfaceAuthinfo{" +
|
||||
"expiresIn=" + expiresIn +
|
||||
", authinfo='" + authinfo + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.foxinmy.weixin4j.pay.payment.mch;
|
||||
package com.foxinmy.weixin4j.pay.payment.face;
|
||||
|
||||
import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.pay.sign.WeixinPaymentSignature;
|
||||
import com.foxinmy.weixin4j.pay.type.SignType;
|
||||
import com.foxinmy.weixin4j.util.*;
|
||||
|
||||
@ -47,6 +48,8 @@ public class PayfaceAuthinfoRequest {
|
||||
*/
|
||||
private String rawdata;
|
||||
|
||||
private WeixinPaymentSignature paymentSignature;
|
||||
|
||||
public PayfaceAuthinfoRequest(WeixinPayAccount account, String storeId, String storeName, String deviceId,
|
||||
String rawdata){
|
||||
this.payAccount = account;
|
||||
@ -54,6 +57,7 @@ public class PayfaceAuthinfoRequest {
|
||||
this.rawdata = rawdata;
|
||||
this.storeId = storeId;
|
||||
this.storeName = storeName;
|
||||
this.paymentSignature = new WeixinPaymentSignature(account.getPaySignKey());
|
||||
}
|
||||
|
||||
public void setAttach(String attach) {
|
||||
@ -108,8 +112,6 @@ public class PayfaceAuthinfoRequest {
|
||||
if(StringUtil.isNotBlank(attach)) {
|
||||
map.put("attach", attach);
|
||||
}
|
||||
return DigestUtil.MD5(
|
||||
String.format("%s&key=%s", MapUtil.toJoinString(map, false, true),
|
||||
payAccount.getPaySignKey())).toUpperCase();
|
||||
return paymentSignature.sign(map);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user