代码整理与优化,刷脸支付案例

This commit is contained in:
egzosn
2019-04-15 20:26:19 +08:00
parent 100b9aecb7
commit d20ae41ab0
14 changed files with 49 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original huodull or egan.
* Copyright 2017 the original egan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original huodull or egan.
* Copyright 2002-2017 the original egan or egan.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -46,7 +46,7 @@ public class PayOrder {
*/
private String spbillCreateIp;
/**
* 付款条码串 与设备号类似???
* 付款条码串,人脸凭证,有关支付代码相关的,
*/
private String authCode;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original huodull or egan.
* Copyright 2002-2017 the original egan or egan.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -136,9 +136,9 @@ public class AliPayController {
public Map<String, Object> microPay(BigDecimal price, String authCode) throws IOException {
//获取对应的支付账户操作工具可根据账户id
//条码付
PayOrder order = new PayOrder("huodull order", "huodull order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.BAR_CODE);
PayOrder order = new PayOrder("egan order", "egan order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.BAR_CODE);
//声波付
// PayOrder order = new PayOrder("huodull order", "huodull order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.WAVE_CODE);
// PayOrder order = new PayOrder("egan order", "egan order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.WAVE_CODE);
//设置授权码,条码等
order.setAuthCode(authCode);
//支付结果

View File

@@ -181,7 +181,7 @@ public class PayController {
//获取对应的支付账户操作工具可根据账户id
PayResponse payResponse = service.getPayResponse(payId);
PayOrder order = new PayOrder("huodull order", "huodull order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), PayType.valueOf(payResponse.getStorage().getPayType()).getTransactionType(transactionType));
PayOrder order = new PayOrder("egan order", "egan order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), PayType.valueOf(payResponse.getStorage().getPayType()).getTransactionType(transactionType));
//设置授权码,条码等
order.setAuthCode(authCode);
//支付结果

View File

@@ -167,7 +167,7 @@ public class UnionPayController {
public Map<String, Object> microPay(BigDecimal price, String authCode) throws IOException {
//获取对应的支付账户操作工具可根据账户id
//条码付
PayOrder order = new PayOrder("huodull order", "huodull order", null == price ? new BigDecimal(0.01) : price, SignUtils.randomStr(), UnionTransactionType.CONSUME);
PayOrder order = new PayOrder("egan order", "egan order", null == price ? new BigDecimal(0.01) : price, SignUtils.randomStr(), UnionTransactionType.CONSUME);
//设置授权码,条码等
order.setAuthCode(authCode);
//支付结果

View File

@@ -182,7 +182,7 @@ public class WxPayController {
public Map<String, Object> microPay( BigDecimal price, String authCode) throws IOException {
//获取对应的支付账户操作工具可根据账户id
//条码付
PayOrder order = new PayOrder("huodull order", "huodull order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), WxTransactionType.MICROPAY);
PayOrder order = new PayOrder("egan order", "egan order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), WxTransactionType.MICROPAY);
//设置授权码,条码等
order.setAuthCode(authCode);
//支付结果
@@ -199,6 +199,36 @@ public class WxPayController {
return params;
}
/**
* 刷卡付,pos主动扫码付款(条码付)
* @param price 金额
* @param authCode 人脸凭证
* @param openid 用户在商户 appid下的唯一标识
* @return 支付结果
*/
@RequestMapping(value = "facePay")
public Map<String, Object> facePay(BigDecimal price, String authCode, String openid) throws IOException {
//获取对应的支付账户操作工具可根据账户id
//条码付
PayOrder order = new PayOrder("egan order", "egan order", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), WxTransactionType.MICROPAY);
//设置授权码,条码等
order.setAuthCode(authCode);
order.setOpenid(openid);
//支付结果
Map<String, Object> params = service.microPay(order);
//校验
if (service.verify(params)) {
//支付校验通过后的处理
//......业务逻辑处理块........
}
//这里开发者自行处理
return params;
}
/**
* 支付回调地址 方式一
*

View File

@@ -102,7 +102,7 @@ public class ApyAccountRepository {
ApyAccount apyAccount5 = new ApyAccount();
apyAccount5.setPayId(5);
apyAccount5.setPartner("100086190");//Program ID
apyAccount5.setSeller("Huodull6190");//Username
apyAccount5.setSeller("egan6190");//Username
apyAccount5.setStorePassword("12BkDT8152Zj");//API password
apyAccount5.setInputCharset("UTF-8");
apyAccount5.setPayType(PayType.payoneer);

View File

@@ -9,6 +9,7 @@ import com.egzosn.pay.common.bean.CertStoreType;
import com.egzosn.pay.common.bean.MsgType;
import com.egzosn.pay.common.bean.TransactionType;
import com.egzosn.pay.common.http.HttpConfigStorage;
import com.egzosn.pay.demo.service.handler.WxPayMessageHandler;
import com.egzosn.pay.fuiou.api.FuiouPayConfigStorage;
import com.egzosn.pay.fuiou.api.FuiouPayService;
import com.egzosn.pay.fuiou.bean.FuiouTransactionType;
@@ -107,7 +108,9 @@ public enum PayType implements BasePayType {
//设置ssl证书对应的存储方式这里默认为文件地址
httpConfigStorage.setCertStoreType(CertStoreType.PATH);
return new WxPayService(wxPayConfigStorage, httpConfigStorage);*/
return new WxPayService(wxPayConfigStorage);
WxPayService wxPayService = new WxPayService(wxPayConfigStorage);
wxPayService.setPayMessageHandler(new WxPayMessageHandler(1));
return wxPayService;
}
/**

View File

@@ -68,7 +68,7 @@ public class PayResponse {
// //代理密码
// httpConfigStorage.setHttpProxyPassword("password");
//设置ssl证书路径 https证书设置 方式二
httpConfigStorage.setKeystorePath(apyAccount.getKeystorePath());
httpConfigStorage.setKeystore(apyAccount.getKeystorePath());
//设置ssl证书对应的密码
httpConfigStorage.setStorePassword(apyAccount.getStorePassword());
return httpConfigStorage;

View File

@@ -36,7 +36,7 @@ public class PayTest {
if (1==1){
String auth = Base64.encode("Huodull6190:12BkDT8152Zj".getBytes());
String auth = Base64.encode("egan6190:12BkDT8152Zj".getBytes());
System.out.println(auth);
return;
}
@@ -49,7 +49,7 @@ public class PayTest {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(uri.getHost(), uri.getPort()),
new UsernamePasswordCredentials("Huodull6190", "12BkDT8152Zj"));
new UsernamePasswordCredentials("egan6190", "12BkDT8152Zj"));
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
@@ -73,7 +73,7 @@ public class PayTest {
// PayoneerRequestBean bean = new PayoneerRequestBean("666");
String referenceId = UUID.randomUUID().toString().replace("-", "");
PayoneerRequestBean bean = new PayoneerRequestBean("8a2950f959043699015904453b330057","1.01", referenceId, CurType.USD,"huodull order");
PayoneerRequestBean bean = new PayoneerRequestBean("8a2950f959043699015904453b330057","1.01", referenceId, CurType.USD,"egan order");
// PayoneerRequestBean bean = JSON.parseObject("{\"amount\":\"1.00\",\"client_reference_id\":\""+ System.nanoTime()+"\",\"currency\":\"USD\",\"description\":\"aaabb\",\"payee_id\":\"asdfg13\"}", PayoneerRequestBean.class);
System.out.println(JSON.toJSONString(bean));
StringEntity entity = new StringEntity(JSON.toJSONString(bean), ContentType.APPLICATION_JSON);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original huodull or egan.
* Copyright 2002-2017 the original egan or egan.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -51,7 +51,6 @@
<module>pay-java-union</module>
<module>pay-java-payoneer</module>
<module>pay-java-paypal</module>
<module>pay-java-pds</module>
<module>pay-java-demo</module>
</modules>