微信刷脸:无授权码

This commit is contained in:
张雪 2025-05-07 15:36:05 +08:00
parent 237cf8dbe3
commit d9d73434f6
10 changed files with 127 additions and 92 deletions

View File

@ -11,46 +11,13 @@ import java.util.List;
*/
@Data
@Component
@ConfigurationProperties(prefix = "wx.mp")
@ConfigurationProperties(prefix = "dpkj.wx")
public class WxMpProperties {
/**
* 是否使用redis存储access token
*/
private Boolean useRedis = false;
/**
* redis 配置
*/
private RedisConfig redisConfig;
@Data
public static class RedisConfig {
/**
* redis服务器 主机地址
*/
private String host;
/**
* redis服务器 端口号
*/
private Integer port;
/**
* redis服务器 密码
*/
private String password;
/**
* redis 服务连接超时时间
*/
private Integer timeout;
}
/**
* 多个公众号配置信息
*/
private List<MpConfig> configs;
@Data
public static class MpConfig {
/**
@ -126,48 +93,6 @@ public class WxMpProperties {
}
/**
* 访问地址
*/
private MpUrl url;
@Data
public static class MpUrl {
/**
* H5地址
*/
private String h5;
/**
* 接口地址
*/
private String server;
}
/**
* 模板消息id
*/
private MpTemplate template;
@Data
public static class MpTemplate {
/**
* 缴费通知
*/
private String payMsg;
/**
* 流程待办
*/
private String test;
/**
* 流程待办
*/
private String test2;
}
/**
* 微信商户支付配置
*/
@ -250,4 +175,22 @@ public class WxMpProperties {
}
/**
* 访问地址
*/
private MpUrl url;
@Data
public static class MpUrl {
/**
* H5地址
*/
private String h5;
/**
* 接口地址
*/
private String server;
}
}

View File

@ -19,6 +19,7 @@ import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.security.Provider;
import java.security.Security;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;
@ -66,8 +67,6 @@ public class WxpayFaceTestController {
WxFacePayResp wxFacePayResp = weChatPayFaceService.doWxPayIniMethod(wxFacePayReq);
System.out.println("**************2、获取数据"+wxFacePayResp.toString());
String rawdata = wxFacePayResp.getRawdata();
return Result.ok(wxFacePayResp);
}
@ -80,15 +79,17 @@ public class WxpayFaceTestController {
*/
@RequestMapping(value = "/getWxpayfaceAuthinfo", method = RequestMethod.POST)
public Result<Map<String, Object>> getWxpayfaceAuthinfo() throws Exception {
Map<String, Object> wxFacePayResp = new HashMap<>();
// 构建请求参数的JSON字符串
WxFacePayReq wxFacePayReq = new WxFacePayReq("getWxpayfaceRawdata","1",System.currentTimeMillis()/1000);
WxFacePayResp wxFacePayResp1 = weChatPayFaceService.doWxPayIniMethod(wxFacePayReq);
System.out.println("**************2、获取数据返回值"+wxFacePayResp1.toString());
String rawdata = wxFacePayResp1.getRawdata();
// 构建请求参数的JSON字符串
Map<String, Object> wxFacePayResp = weChatPayFaceService.getWxFaceAuthInfoReqMap(rawdata);
System.out.println("**************333"+wxFacePayResp.toString());
System.out.println("**************2、获取数据getWxpayfaceRawdata"+wxFacePayResp1.toString());
if("SUCCESS".equals(wxFacePayResp1.getReturn_code())){
String rawdata = wxFacePayResp1.getRawdata();
// 构建请求参数的JSON字符串
wxFacePayResp= weChatPayFaceService.getWxFaceAuthInfoReqMap(rawdata);
System.out.println("**************2、获取调用凭证get_wxpayface_authinfo"+wxFacePayResp.toString());
}
return Result.ok(wxFacePayResp);
}

View File

@ -5,7 +5,7 @@ import com.sun.jna.Native;
import lombok.extern.slf4j.Slf4j;
/**
* @description:
* @description: 32位的WxpayFaceSDK /resources/win32-x86/WxpayFaceSDK.dll
* @author: Zhangxue
* @time: 2025/4/17 17:02
*/

View File

@ -1,5 +1,6 @@
package com.dpkj.modules.scanface.wx.service;
import com.dpkj.modules.scanface.wx.dll.WxpayFaceSDKDll;
import java.io.UnsupportedEncodingException;

View File

@ -56,15 +56,17 @@ public class CallWxpayFaceServiceImpl implements CallWxpayFaceService {
// 调用本地方法
WxpayFaceSDKDll.Dll dll = WxpayFaceSDKDll.instance();
int result =dll.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
int result = dll.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
//使用C:\Windows\System32目录下 int result = WxpayFaceSDK.INSTANCE.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
if (result == 0) {
Pointer pointer = new Pointer(pRespBuf[0]);
byte[] byteArray = pointer.getByteArray(0, respSize[0]);
resStr = new String(byteArray, StandardCharsets.UTF_8);
System.out.println("-----------调用服务成功结果: " + resStr);
//释放
dll.wxpayReleaseResponse(new String[2]);
//释放 C:\Windows\System32目录下 WxpayFaceSDK.INSTANCE.wxpayReleaseResponse(new String[2]);
} else {
Pointer pointer = new Pointer(pRespBuf[0]);
byte[] byteArray = pointer.getByteArray(0, respSize[0]);

View File

@ -51,11 +51,8 @@ public class WeChatPayFaceServiceImpl implements WeChatPayFaceService {
//赋值
private static WxMpProperties wxMpProperties;
public static void setWxMpConfiguration(WxMpProperties wxMpProperties) {
WeChatPayFaceServiceImpl.wxMpProperties = wxMpProperties;
}
@Autowired
private WxMpProperties wxMpProperties;
/**
@ -93,6 +90,8 @@ public class WeChatPayFaceServiceImpl implements WeChatPayFaceService {
// 调用本地方法
WxpayFaceSDKDll.Dll dll = WxpayFaceSDKDll.instance();
int result = dll.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
//使用C:\Windows\System32目录下 int result = WxpayFaceSDK.INSTANCE.wxpayCallFaceService(reqPointer.getString(0), reqSize, pRespBuf, respSize);
log.info("[WeChatPayFaceServiceImpl][doWxPayIniMethod][95] DLL 返回码: {}", result);
if (result == 0) {
Pointer pointer = new Pointer(pRespBuf[0]);
@ -102,6 +101,8 @@ public class WeChatPayFaceServiceImpl implements WeChatPayFaceService {
System.out.println("-----------调用服务成功结果: " + resStr);
//释放
dll.wxpayReleaseResponse(new String[2]);
//释放 C:\Windows\System32目录下 WxpayFaceSDK.INSTANCE.wxpayReleaseResponse(new String[2]);
} else {
Pointer pointer = new Pointer(pRespBuf[0]);
byte[] byteArray = pointer.getByteArray(0, respSize[0]);

View File

@ -42,6 +42,50 @@ dpkj:
partner-id: 2088641941653700
# 核心入参 serviceId
service-id: pay
#微信模块
wx:
configs: #清研家
- app-id: wxe8334dd2140bb0e1
# 公众号的appsecret
secret: f83420d79cc6ecd1d7fe9684ac9cdfe4
# 接口配置里的Token值
token: dpkjylwjvote
# 接口配置里的EncodingAESKey值
aes-key: go2uM3ASe2rEyeoNsZHoPCiKGgpku0Bi49P5IypdQWT
mch-config: #商户信息 清研家关联的商户:驿路万家-扬州清研软件科技
app-id: wxe8334dd2140bb0e1
secret: f83420d79cc6ecd1d7fe9684ac9cdfe4
#调用接口所需service_id
service-id: service_id
#商户号
mch-id: 1557642321
#商户秘钥
mch-key: yndpkj15288216506YndpkjKsjytZx12
#报文解密 APIv3密钥
v3-key: yndpkj15288216506YndpkjKsjytZx12
#微信: 商户APIv2密钥
key-api: yndpkj15288216506YndpkjKsjytZx12
#p12证书的位置可以指定绝对路径也可以指定类路径以classpath;开头)
key-path: classpath:test\apiclient_cert.p12
private-key-path: classpath:test\apiclient_key.pem
private-cert-path: classpath:test\apiclient_cert.pem
#微信商家api序列号
mch-serial-no:
#JSAPI--公众号支付 NATIVE--原生扫码支付 APP--app支付
trade-type: JSAPI
trade-type-native: NATIVE
#支付回调方法地址
pay-notify-url: ${dpkj.url.server-url}/openapi/wxPayOrderApi/notify
#退款回调方法地址
refund-notify-url: ${dpkj.url.server-url}/openapi/wxPayOrderApi/refundNotify
# 路径
url:
# 后端接口地址
# server: https://102760424tfyw.vicp.fun/api
server: ${dpkj.url.server-url}
# h5地址
h5: ${dpkj.url.h5-url}
# 自定义app参数
app:

View File

@ -43,6 +43,49 @@ dpkj:
partner-id: 2088641941653700
# 核心入参 serviceId
service-id: pay
#微信模块
wx:
configs: # 清研家
- app-id: wxc12fa4977f66974d #wxc12fa4977f66974d #wx024903d1d2e1a55a
# 公众号的appsecret
secret: a51dbcac25a73d7e4812a43cf550c5fc #f83420d79cc6ecd1d7fe9684ac9cdfe4
# 接口配置里的Token值 DPKJ-YINYITONG #DPKJ-YINYITONG#dpkjylwjvote
token: DPKJ-YINYITONG
# 接口配置里的EncodingAESKey值
aes-key: yIBgBrHwRGjO2L3CLIE9hmnlf1FrXQQ7qJZVIg4r6Dx
mch-config: #商户信息 驿路万家-扬州清研软件科技
app-id: wxc12fa4977f66974d
secret: f83420d79cc6ecd1d7fe9684ac9cdfe4
#调用接口所需service_id
service-id: service_id
#商户号
mch-id: 1557642321
#商户秘钥
mch-key: yndpkj15288216506YndpkjKsjytZx12
#报文解密 APIv3密钥
v3-key: yndpkj15288216506YndpkjKsjytZx12
#微信: 商户APIv2密钥
key-api: yndpkj15288216506YndpkjKsjytZx12
#p12证书的位置可以指定绝对路径也可以指定类路径以classpath;开头)
key-path: classpath:test\apiclient_cert.p12
private-key-path: classpath:test\apiclient_key.pem
private-cert-path: classpath:test\apiclient_cert.pem
#微信商家api序列号
mch-serial-no:
#JSAPI--公众号支付 NATIVE--原生扫码支付 APP--app支付
trade-type: JSAPI
trade-type-native: NATIVE
#支付回调方法地址
pay-notify-url: ${dpkj.url.server-url}/openapi/wxPayOrderApi/notify
#退款回调方法地址
refund-notify-url: ${dpkj.url.server-url}/openapi/wxPayOrderApi/refundNotify
# 路径
url:
# 后端接口地址
# server: https://102760424tfyw.vicp.fun/api
server: ${dpkj.url.server-url}
# h5地址
h5: ${dpkj.url.h5-url}
# 自定义app参数
app:

Binary file not shown.