支付宝刷脸初始化、调用服务

This commit is contained in:
张雪 2025-04-29 09:56:43 +08:00
parent 909ad5cc8c
commit d46490fc6b
10 changed files with 91 additions and 284 deletions

View File

@ -48,7 +48,7 @@ public class AliScanFaceController {
} }
/** /**
* ABCP服务调用 刷脸去初始化服务 * ABCP服务调用 刷脸去初始化服务,获取ftoken
* 文档地址https://opendocs.alipay.com/iot/05e9ye * 文档地址https://opendocs.alipay.com/iot/05e9ye
* 初始化成功后商家App 可根据业务需求调用接口 abcp_start_service 执行 ABCP 所提供的服务 * 初始化成功后商家App 可根据业务需求调用接口 abcp_start_service 执行 ABCP 所提供的服务
* 上述服务调用过程可重复多次调用通过传入不同的 service_code 来调用不同的 ABCP 服务 * 上述服务调用过程可重复多次调用通过传入不同的 service_code 来调用不同的 ABCP 服务
@ -59,30 +59,17 @@ public class AliScanFaceController {
Result<Object> abcpStartServiceIni() { Result<Object> abcpStartServiceIni() {
aliScanFaceService.iniAbcpAbsolute(); aliScanFaceService.iniAbcpAbsolute();
//参数 //参数
JSONObject params = new JSONObject().fluentPut("serviceId", aliFaceConfig.getServiceId()); //服务场景 JSONObject zolozConfig = new JSONObject().fluentPut("installAngle",90);
JSONObject params = new JSONObject()
.fluentPut("serviceId", aliFaceConfig.getServiceId())
.fluentPut("zolozConfig",zolozConfig);
String json = params.toJSONString(); String json = params.toJSONString();
String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码:初始化 String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码:初始化
return aliScanFaceService.startServiceIni(json, service_code); return aliScanFaceService.startServiceIni(json, service_code);
} }
/**
* ABCP服务调用 刷脸支付服务
* 文档地址https://opendocs.alipay.com/iot/05e9ye
* @return
*/
@GetMapping("startServiceFaceSmilePay")
Result<Object> startServiceFaceSmilePay() {
//参数
JSONObject params = new JSONObject(); //
String json = params.toJSONString();
String service_code = AliFaceConstants.SMILEPAY; //调用的组件编码刷脸支付
return aliScanFaceService.startServiceFaceSmilePay(json, service_code);
}
/** /**
* ABCP服务停用 * ABCP服务停用
@ -91,10 +78,11 @@ public class AliScanFaceController {
*/ */
@PostMapping("stopService") @PostMapping("stopService")
Result<Object> stopService(@RequestParam String traceId) { Result<Object> stopService(@RequestParam String traceId) {
aliScanFaceService.iniAbcpAbsolute();
//参数 //参数
JSONObject params = new JSONObject() JSONObject params = new JSONObject()
.fluentPut("traceId",traceId) .fluentPut("traceId",traceId);
.fluentPut("service_code",AliFaceConstants.SMILEVERIFYNIN_V1); // //.fluentPut("service_code",AliFaceConstants.SMILEVERIFYNIN_V1); //
String json = params.toJSONString(); String json = params.toJSONString();
String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码 String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码

View File

@ -129,6 +129,7 @@ public class AbcpInvoke {
msLock.unlock(); msLock.unlock();
try { try {
log.info("[调用abcp_stop_service]:seedId={}, appId={}, serviceCode={}, json={}", seedId, appId, serviceCode, json);
msAbcpNativeDll.abcp_stop_service(seedId, appId, serviceCode, json, msABCPProcess, msABCPFinish); msAbcpNativeDll.abcp_stop_service(seedId, appId, serviceCode, json, msABCPProcess, msABCPFinish);
} catch (Throwable e) { } catch (Throwable e) {
callback.OnFinish(3, "E69001", e.getMessage(), ""); callback.OnFinish(3, "E69001", e.getMessage(), "");
@ -251,7 +252,7 @@ public class AbcpInvoke {
public static class ABCPFinish implements FuncFinish { public static class ABCPFinish implements FuncFinish {
public void onFinish(int seed_id, int _code, String subCode, String subMsg, String result) { public void onFinish(int seed_id, int _code, String subCode, String subMsg, String result) {
log.info("[ABCPFinish][onFinish][261][ABCPFinish数据][seed_id:{}],[_code:{}],[subMsg:{}],[result:{}]", seed_id, _code, subCode, subMsg, result); //log.info("[ABCPFinish][onFinish][261][ABCPFinish数据][seed_id:{}],[_code:{}],[subMsg:{}],[result:{}]", seed_id, _code, subCode, subMsg, result);
Integer seedId = Integer.valueOf(seed_id); Integer seedId = Integer.valueOf(seed_id);
CallbackRsp callback = null; CallbackRsp callback = null;

View File

@ -18,7 +18,7 @@ public interface IAliScanFaceService {
/** /**
* ABCP服务调用 刷脸去初始化服务 * ABCP服务调用 刷脸去初始化服务,获取ftoken
* 接受调用者传入的参数信息执行指定服务service_code然后通过回调返回服务结果 * 接受调用者传入的参数信息执行指定服务service_code然后通过回调返回服务结果
* https://opendocs.alipay.com/iot/05e9ye#ABCP%E6%9C%8D%E5%8A%A1%E8%B0%83%E7%94%A8 * https://opendocs.alipay.com/iot/05e9ye#ABCP%E6%9C%8D%E5%8A%A1%E8%B0%83%E7%94%A8
* @param json 组装参数 * @param json 组装参数
@ -27,14 +27,6 @@ public interface IAliScanFaceService {
*/ */
Result<Object> startServiceIni(String json,String service_code); Result<Object> startServiceIni(String json,String service_code);
/**
* ABCP服务调用 :刷脸支付服务
* @param json
* @param service_code
* @return
*/
Result<Object> startServiceFaceSmilePay(String json,String service_code);
/** /**
* ABCP服务停用 * ABCP服务停用

View File

@ -57,10 +57,20 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
AbcpInvoke.SetAPIPathFile(aliFaceConfig.getDllPath()); AbcpInvoke.SetAPIPathFile(aliFaceConfig.getDllPath());
//创建回调实例 //创建回调实例
MyCallbackRsp callback = new MyCallbackRsp(); AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() {
@Override
public void OnProcess(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][OnProcess][123][ABCP调用iniAbcpAbsolute][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
}
@Override
public void OnFinish(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][OnFinish][128][ABCP调用iniAbcpAbsolute][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
}
};
//初始化 //初始化
AbcpInvoke.AbcpInit(aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, callback); AbcpInvoke.AbcpInit(aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, callbackRsp);
return Result.ok("支付宝ABCP初始化成功"); return Result.ok("支付宝ABCP初始化成功");
} else { } else {
@ -74,42 +84,7 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
} }
/** /**
* 使用相对路径调用ABCP_SDK部署出来的AbcpInvoke类 * ABCP服务调用 刷脸初始化服务,获取ftoken
*
* @return
* @Override public Result<Object> iniAbcp() {
* try {
* log.info("[AliScanFaceServiceImpl][iniAbcpAli][26][ABCP初始化参数][appId:{}],[merchantId:{}],[deviceNum:{}],[partnerId:{}]",
* aliFaceConfig.getAppId(), aliFaceConfig.getMerchantId(), aliFaceConfig.getDeviceNum(), aliFaceConfig.getPartnerId());
* <p>
* AliScanFaceDll.Dll dll = AliScanFaceDll.instance();
* dll.bp_api_set_isv_lan(3);// 0:cpp | 1:cshap | 2:jni | 3:jna
* <p>
* JSONObject params = new JSONObject()
* .fluentPut("appId", aliFaceConfig.getAppId()) //应用ID
* .fluentPut("merchantId", aliFaceConfig.getMerchantId()) //签约商家的 PID 2088 开头
* .fluentPut("deviceNum", aliFaceConfig.getDeviceNum())//商家机具终端编号每台设备保持唯一
* .fluentPut("partnerId", aliFaceConfig.getPartnerId());//服务商的 PID
* String json = params.toJSONString();
* <p>
* <p>
* AbcpInvoke.ABCPProcess msABCPProcess = new AbcpInvoke.ABCPProcess();
* AbcpInvoke.ABCPFinish msABCPFinish = new AbcpInvoke.ABCPFinish();
* Integer seedId = AbcpInvoke.getMsSeedId();
* dll.abcp_init(seedId, aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, msABCPProcess, msABCPFinish);
* <p>
* log.info("[AliScanFaceServiceImpl][iniAbcp][49][ABCP初始化process] {}", msABCPProcess.toString());
* log.info("[AliScanFaceServiceImpl][iniAbcp][49][ABCP初始化结果] {}", msABCPFinish.toString());
* return Result.ok("成功");
* } catch (Exception e) {
* e.printStackTrace();
* return Result.error("失败");
* }
* }
*/
/**
* ABCP服务调用 刷脸初始化服务
* 接受调用者传入的参数信息执行指定服务service_code然后通过回调返回服务结果 * 接受调用者传入的参数信息执行指定服务service_code然后通过回调返回服务结果
* https://opendocs.alipay.com/iot/05e9ye#ABCP%E6%9C%8D%E5%8A%A1%E8%B0%83%E7%94%A8 * https://opendocs.alipay.com/iot/05e9ye#ABCP%E6%9C%8D%E5%8A%A1%E8%B0%83%E7%94%A8
* @param json 组装参数 * @param json 组装参数
@ -123,18 +98,26 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
// 使用 CountDownLatch 实现线程同步 // 使用 CountDownLatch 实现线程同步
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Result<Object>> resultRef = new AtomicReference<>(); CountDownLatch latchFinish = new CountDownLatch(1);
AtomicReference<Result<Object>> finishResultRef = new AtomicReference<>();
//获取返回数据 //获取返回数据
AtomicReference<Integer> returnCode = new AtomicReference<>(); AtomicReference<Integer> processCode = new AtomicReference<>();
AtomicReference<String> returnResult = new AtomicReference<>(); AtomicReference<String> processResult = new AtomicReference<>();
AtomicReference<Integer> finishCode = new AtomicReference<>();
AtomicReference<String> finishResult = new AtomicReference<>();
//接收结果
Map<String, String> res = new HashMap<>();
AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() { AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() {
@Override @Override
public void OnProcess(int code, String subCode, String subMsg, String result) { public void OnProcess(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][OnProcess][123][ABCP调用刷脸初始化服务][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result); log.info("[AliScanFaceServiceImpl][OnProcess][123][service_code:{}][code:{}][subCode:{}][subMsg:{}][result:{}]",service_code, code, subCode, subMsg, result);
try { try {
returnCode.set(code); processCode.set(code);
returnResult.set(result); processResult.set(result);
} finally { } finally {
latch.countDown(); // 确保无论如何都释放锁 latch.countDown(); // 确保无论如何都释放锁
} }
@ -142,7 +125,17 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
@Override @Override
public void OnFinish(int code, String subCode, String subMsg, String result) { public void OnFinish(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][OnFinish][128][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result); log.info("[AliScanFaceServiceImpl][OnFinish][128][service_code:{}][code:{}][subCode:{}][subMsg:{}][result:{}]",service_code, code, subCode, subMsg, result);
/**Demo示例记录
* [service_code:BPaaSSmileVerifyNonInitV1][code:1000][subCode:E00000][subMsg:SUCCESS][result:{"code":1000,"subCode":"OK_SUCCESS","subMessage":"SUCCESS","barCode":"281215320962898068","ftoken":"fp1efd3d4c0230a28f5261efe7c5050eh28","alipayUid":"2088812449506047","accountList":"[\"104***@qq.com\"]","authToken":"44686f7195c77ee2e09c09bcdc657dd5h28i","result":{"accountList":["104***@qq.com"],"alipayUid":"2088812449506047","allowRetry":false,"authToken":"44686f7195c77ee2e09c09bcdc657dd5h28i","barCode":"281215320962898068","certName":"您好,*雪","ftoken":"fp1efd3d4c0230a28f5261efe7c5050eh28","type":"selectUid"},"easterEgg":false,"zolozConfig":{"installAngle":90},"serviceId":"pay","traceId":"2444-44-1745802328","callStartTimeMs":1745802328114,"localTime":"2025-04-28-09-05-41-791"}]
*/
try {
finishCode.set(code);
finishResult.set(result);
} finally {
latchFinish.countDown(); // 确保无论如何都释放锁
}
} }
}; };
@ -150,97 +143,50 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
log.info("[AliScanFaceServiceImpl][startService][141][ABCP调用刷脸初始化服务-调用AbcpStartService参数][appId:{}][service_code:{}][json:{}] ", appId, service_code, json.toString()); log.info("[AliScanFaceServiceImpl][startService][141][ABCP调用刷脸初始化服务-调用AbcpStartService参数][appId:{}][service_code:{}][json:{}] ", appId, service_code, json.toString());
AbcpInvoke.AbcpStartService(appId, service_code, json, callbackRsp); AbcpInvoke.AbcpStartService(appId, service_code, json, callbackRsp);
// 等待回调完成设置超时避免死锁 // 等待process回调完成设置超时避免死锁
boolean awaitSuccess = latch.await(10, TimeUnit.SECONDS); boolean awaitSuccess = latch.await(10, TimeUnit.SECONDS);
if (!awaitSuccess) { if (!awaitSuccess) {
return Result.error("等待回调超时"); return Result.error("等待process回调超时");
} else { } else {
if (returnCode.get() == 0) { if (processCode.get() == 0) {
Map<String, String> res = new HashMap<>(); JSONObject jsonObject = JSONObject.parseObject(processResult.get());
JSONObject jsonObject = JSONObject.parseObject(returnResult.get());
if (jsonObject.containsKey("traceId")) { if (jsonObject.containsKey("traceId")) {
res.put("traceId", jsonObject.getString("traceId")); res.put("traceId", jsonObject.getString("traceId"));
resultRef.set(Result.ok("ABCP调用刷脸初始化服务成功", res));
} else { } else {
return Result.ok("ABCP调用刷脸初始化服务失败返回结果无traceId"); return Result.error("ABCP调用刷脸初始化服务process失败返回结果无traceId");
} }
} else { } else {
return Result.error("ABCP调用刷脸初始化服务失败"); return Result.error("ABCP调用刷脸初始化服务process失败");
}
}
// 等待finish回调完成设置超时避免死锁
boolean awaitFinishSuccess = latchFinish.await(120, TimeUnit.SECONDS);
if (!awaitFinishSuccess) {
return Result.error("等待finish回调超时");
} else {
if (finishCode.get() == 1000) {
JSONObject jsonObject = JSONObject.parseObject(finishResult.get());
if (jsonObject.containsKey("ftoken")) {
res.put("ftoken", jsonObject.getString("ftoken"));
res.put("barCode", jsonObject.getString("barCode"));
finishResultRef.set(Result.ok("ABCP调用刷脸初始化finish服务成功", res));
} else {
return Result.ok("ABCP调用刷脸初始化服务finish失败返回结果无ftoken");
}
} else {
return Result.error("ABCP调用刷脸初始化服务finish失败");
} }
} }
//结果返回 //结果返回
return resultRef.get(); return finishResultRef.get();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return Result.error("ABCP调用刷脸初始化服务失败" + e.getMessage()); return Result.error("ABCP调用刷脸初始化服务失败" + e.getMessage());
} }
} }
/**
* ABCP服务调用 :刷脸支付服务
*
* @param json
* @param service_code
* @return
*/
public Result<Object> startServiceFaceSmilePay(String json, String service_code) {
try {
String appId = aliFaceConfig.getAppId();
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Result<Object>> finalResultRef = new AtomicReference<>();
AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() {
@Override
public void OnProcess(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][startServiceFaceSmilePay][OnProcess][188][ABCP调用刷脸支付服务-OnProcess][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
if (code != 0) {
finalResultRef.set(Result.error("流程中断: " + subMsg));
latch.countDown(); // 失败时立即释放锁
}
}
@Override
public void OnFinish(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][startServiceFaceSmilePay][OnFinish][128][ABCP调用刷脸支付服务-OnFinish][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
try {
if (code == 0 && StringUtil.isNotBlank(result)) {
JSONObject resultJson = JSONObject.parseObject(result);
if (resultJson.containsKey("ftoken")) {
String ftoken = resultJson.getString("ftoken");
finalResultRef.set(Result.ok("ABCP刷脸支付服务成功", ftoken));
} else {
finalResultRef.set(Result.error("ABCP刷脸支付服务结果中ftoken不存在"));
}
} else {
finalResultRef.set(Result.error("ABCP刷脸支付服务失败: " + subMsg));
}
} catch (Exception e) {
finalResultRef.set(Result.error("ABCP刷脸支付服务结果解析异常: " + e.getMessage()));
} finally {
latch.countDown();
}
}
};
//调用
log.info("[AliScanFaceServiceImpl][startServiceFaceSmilePay][141][ABCP调用刷脸初始化服务-调用AbcpStartService参数][appId:{}][service_code:{}][json:{}] ", appId, service_code, json.toString());
AbcpInvoke.AbcpStartService(appId, service_code, json, callbackRsp);
// 等待回调完成60秒超时
boolean awaitSuccess = latch.await(60, TimeUnit.SECONDS);
if (!awaitSuccess) {
return Result.error("等待结果超时");
}
return finalResultRef.get();
} catch (Exception e) {
e.printStackTrace();
return Result.error("ABCP调用刷脸支付服务失败" + e.getMessage());
}
}
/** /**

View File

@ -22,7 +22,6 @@ public class MyCallbackRsp implements AbcpInvoke.CallbackRsp {
public void OnFinish(int code, String subCode, String subMsg, String result) { public void OnFinish(int code, String subCode, String subMsg, String result) {
// 处理初始化完成结果 // 处理初始化完成结果
if (code == 0) { if (code == 0) {
log.info("[MyCallbackRsp][OnFinish][24] {}", "初始化成功!");
log.info("[MyCallbackRsp][OnFinish][27][返回结果:] {}", result); log.info("[MyCallbackRsp][OnFinish][27][返回结果:] {}", result);
} else { } else {
log.info("[MyCallbackRsp][OnFinish][29] :初始化失败!错误码: %s, 错误信息: %s%n", subCode, subMsg); log.info("[MyCallbackRsp][OnFinish][29] :初始化失败!错误码: %s, 错误信息: %s%n", subCode, subMsg);

View File

@ -19,8 +19,6 @@ import javax.annotation.Resource;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.Provider; import java.security.Provider;
import java.security.Security; import java.security.Security;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Map; import java.util.Map;
import java.util.TreeSet; import java.util.TreeSet;

View File

@ -4,12 +4,6 @@ import com.sun.jna.Library;
import com.sun.jna.Native; import com.sun.jna.Native;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
/** /**
* @description: * @description:
* @author: Zhangxue * @author: Zhangxue
@ -17,57 +11,19 @@ import java.nio.file.StandardCopyOption;
*/ */
@Slf4j @Slf4j
public class WxpayFaceSDKDll { public class WxpayFaceSDKDll {
private static final String DLL_NAME = "WxpayFaceSDK.dll"; // 确保文件名与实际资源一致
//win32-x86-64/WxpayFaceSDK.dll
private static final String RESOURCE_PATH = "win32-x86-64/" + DLL_NAME; // 例如: resources/native/WxpayFaceSDK.dll
private static volatile boolean dllLoaded = false;
static {
loadDllFromResources();
}
private static void loadDllFromResources() {
if (dllLoaded) return;
/**
* 获取 Dll 实例同时注册 Dll 控件
*
* @return WxpayFaceSDKDll 实例
* @throws WxpayFaceSDKDll.DllRegistrationException 如果注册控件失败抛出此异常
*/
public static WxpayFaceSDKDll.Dll instance() throws DllRegistrationException {
try { try {
// resources 中读取 DLL 文件流 return Native.load("WxpayFaceSDK", WxpayFaceSDKDll.Dll.class);
InputStream inputStream = WxpayFaceSDKDll.class.getClassLoader().getResourceAsStream(RESOURCE_PATH);
if (inputStream == null) {
throw new RuntimeException("DLL 未找到: " + RESOURCE_PATH);
}
// 创建临时目录并提取 DLL
Path tempDir = Files.createTempDirectory("native-libs");
Path tempDll = tempDir.resolve(DLL_NAME);
Files.copy(inputStream, tempDll, StandardCopyOption.REPLACE_EXISTING);
inputStream.close();
// 显式加载 DLL
System.load(tempDll.toAbsolutePath().toString());
dllLoaded = true;
// 可选JVM 退出时清理临时文件
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Files.deleteIfExists(tempDll);
Files.deleteIfExists(tempDir);
} catch (Exception e) {
e.printStackTrace();
}
}));
} catch (Exception e) {
throw new RuntimeException("加载 DLL 失败", e);
}
}
public static Dll instance() throws DllRegistrationException {
try {
// 加载已提取的 DLL
return Native.load(DLL_NAME, Dll.class);
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
log.error("[WxpayFaceSDK][instance] 加载失败", e); log.info("[WxpayFaceSDK][instance][微信扫脸动态库] SDK注册失败{}", e.getMessage());
throw new DllRegistrationException("Failed to load WxpayFaceSDK library: ", e); throw new WxpayFaceSDKDll.DllRegistrationException("Failed to load WxpayFaceSDK library: ", e);
} }
} }

View File

@ -1,71 +0,0 @@
package com.dpkj.modules.scanface.wx.dll;
import com.sun.jna.Library;
import com.sun.jna.Native;
import lombok.extern.slf4j.Slf4j;
/**
* @description:
* @author: Zhangxue
* @time: 2025/4/17 17:02
*/
@Slf4j
public class WxpayFaceSDKDll_old {
/**
* 获取 Dll 实例同时注册 Dll 控件
*
* @return WxpayFaceSDKDll 实例
* @throws WxpayFaceSDKDll_old.DllRegistrationException 如果注册控件失败抛出此异常
*/
public static WxpayFaceSDKDll_old.Dll instance() throws DllRegistrationException {
try {
return Native.load("WxpayFaceSDK", WxpayFaceSDKDll_old.Dll.class);
} catch (UnsatisfiedLinkError e) {
log.info("[WxpayFaceSDK][instance][微信扫脸动态库] SDK注册失败{}", e.getMessage());
throw new WxpayFaceSDKDll_old.DllRegistrationException("Failed to load WxpayFaceSDK library: ", e);
}
}
/**
* 定义自定义异常类用于表示注册控件时发生的错误
*/
public static class DllRegistrationException extends Exception {
public DllRegistrationException(String message) {
super(message);
}
public DllRegistrationException(String message, Throwable cause) {
super(message, cause);
}
}
/**
* 定义接口映射本地库中的函数
*/
public interface Dll extends Library {
/**
* 调用人脸服务
* 注意这里的方法签名需要与DLL中的C函数签名一致
* req和resp都是JSON字符串需要转换为Pointer类型
* char * -->String; char ** -->String[]
* int -->int; int* --> IntByReference
* @param reqBuf 请求参数(JSON字符串)
* @param reqSize 请求参数长度
* @param pRespBuf 用来接收响应结果(JSON字符串)的char**指针
* @param pRespSize 用来接收响应结果长度的unsigned int*指针
* @return 如果成功返回0失败则返回非0
*/
//int wxpayCallFaceService(String reqBuf, int reqSize, String[] pRespBuf, IntByReference pRespSize);
int wxpayCallFaceService(String reqBuf, int reqSize, long[] pRespBuf, int[] pRespSize);
/**
* char ** -->String[]
* 释放人脸服务的响应字符串调用wxpayCallFaceService成功后务必调用此函数释放内存
* @param pRespBuf 指向响应结果(JSON字符串)的指针
*/
void wxpayReleaseResponse(String[] pRespBuf);
}
}

View File

@ -29,17 +29,15 @@ dpkj:
#dll文件路径 #dll文件路径
dll-path: C:/opt/ant-abcp/bpaas_api.dll dll-path: C:/opt/ant-abcp/bpaas_api.dll
#IOT 应用管理-appid #IOT 应用管理-appid
app-id: 2021005138692337 app-id: 2021005138656502
#IOT应用版本 #IOT应用版本
app-version: 1.0.0 app-version: 1.0.0.0
#签约商家的 PID以 2088 开头,企业主体 #签约商家的 PID以 2088 开头,企业主体
merchant-id: 2088641941653700 merchant-id: 2088641941653700
#商家机具终端编号,每台设备保持唯一【设备铭牌上的整机编码】 #商家机具终端编号,每台设备保持唯一
device-num: P060003750 device-num: P060003750
#服务商的 PID #服务商的 PID
partner-id: 2088641941653700 partner-id: 2088641941653700
# 刷脸支付服务-服务编码serviceCode
service-code: BPaaSSmileVerifyNonInitV1
# 核心入参 serviceId # 核心入参 serviceId
service-id: pay service-id: pay

View File

@ -1,5 +1,5 @@
server: server:
port: 5948 port: 5946
dpkj: dpkj:
# 医保配置 # 医保配置
@ -31,7 +31,7 @@ dpkj:
#IOT 应用管理-appid #IOT 应用管理-appid
app-id: 2021005138656502 app-id: 2021005138656502
#IOT应用版本 #IOT应用版本
app-version: 1.0.0 app-version: 1.0.0.0
#签约商家的 PID以 2088 开头,企业主体 #签约商家的 PID以 2088 开头,企业主体
merchant-id: 2088641941653700 merchant-id: 2088641941653700
#商家机具终端编号,每台设备保持唯一 #商家机具终端编号,每台设备保持唯一