Skip to content

Commit 518f0e6

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents a6f0332 + 5971552 commit 518f0e6

20 files changed

Lines changed: 85 additions & 43 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ E-Mail:egzosn@gmail.com
6767

6868
QQ群:542193977
6969

70-
微信群: ![微信群](https://images.gitee.com/uploads/images/2019/1107/121546_6dbab7f7_1221178.jpeg "wx.jpg")
70+
微信群: ![微信群](https://images.gitee.com/uploads/images/2019/1117/151422_5085eaae_1221178.jpeg "wx.jpg")

pay-java-ali/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
<artifactId>pay-java-common</artifactId>
2020
</dependency>
2121
<!-- /pay-java -->
22+
<!--
23+
<dependency>
24+
<groupId>org.bouncycastle</groupId>
25+
<artifactId>bcprov-jdk15on</artifactId>
26+
<version>1.54</version>
27+
</dependency>-->
2228

2329
</dependencies>
2430

pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
import com.egzosn.pay.common.http.HttpConfigStorage;
1313
import com.egzosn.pay.common.http.UriVariables;
1414
import com.egzosn.pay.common.util.DateUtils;
15-
import com.egzosn.pay.common.util.MatrixToImageWriter;
1615
import com.egzosn.pay.common.util.Util;
1716
import com.egzosn.pay.common.util.sign.SignUtils;
1817
import com.egzosn.pay.common.util.str.StringUtils;
19-
import java.awt.image.BufferedImage;
2018
import java.math.BigDecimal;
2119
import java.util.*;
2220

@@ -28,7 +26,7 @@
2826
* email egzosn@gmail.com
2927
* date 2017-2-22 20:09
3028
*/
31-
public class AliPayService extends BasePayService<AliPayConfigStorage> {
29+
public class AliPayService extends BasePayService<AliPayConfigStorage, PayOrder> {
3230

3331
/**
3432
* 正式测试环境
@@ -218,6 +216,7 @@ private Map<String, Object> getOrder(PayOrder order) {
218216
break;
219217
case BAR_CODE:
220218
case WAVE_CODE:
219+
case SECURITY_CODE:
221220
bizContent.put("scene", order.getTransactionType().toString().toLowerCase());
222221
bizContent.put(PRODUCT_CODE, "FACE_TO_FACE_PAYMENT");
223222
bizContent.put("auth_code", order.getAuthCode());

pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliTransactionType.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ public enum AliTransactionType implements TransactionType {
4949
* 声波付
5050
*/
5151
WAVE_CODE("alipay.trade.pay"),
52+
/**
53+
* 刷脸付
54+
*/
55+
SECURITY_CODE("alipay.trade.pay"),
56+
/**
57+
* 人脸初始化刷脸付
58+
* 暂时未接入
59+
*
60+
*/
61+
SMILEPAY("zoloz.authentication.customer.smilepay.initialize"),
5262
//交易辅助接口
5363

5464
/**
@@ -86,7 +96,12 @@ public enum AliTransactionType implements TransactionType {
8696
/**
8797
* 转账查询
8898
*/
89-
TRANS_QUERY("alipay.fund.trans.order.query")
99+
TRANS_QUERY("alipay.fund.trans.order.query"),
100+
/**
101+
* 查询刷脸结果信息
102+
* 暂时未接入
103+
*/
104+
FTOKEN_QUERY("zoloz.authentication.customer.ftoken.query")
90105
;
91106

92107

pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/OrderSettle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import com.egzosn.pay.common.util.str.StringUtils;
55

66
import java.math.BigDecimal;
7-
import java.util.HashMap;
87
import java.util.Map;
98
import java.util.TreeMap;
109

1110
/**
11+
* 交易结算信息
1212
* @author egan
1313
* email egzosn@gmail.com
1414
* date 2019/4/28.20:29

pay-java-ali/src/main/java/com/egzosn/pay/ali/before/api/AliPayService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @see com.egzosn.pay.ali.api.AliPayService
3636
*/
3737
@Deprecated
38-
public class AliPayService extends BasePayService<AliPayConfigStorage> {
38+
public class AliPayService extends BasePayService<AliPayConfigStorage, PayOrder> {
3939

4040

4141

pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* date 2017/3/5 20:36
2727
* </pre>
2828
*/
29-
public abstract class BasePayService<PC extends PayConfigStorage> implements PayService<PC> {
29+
public abstract class BasePayService<PC extends PayConfigStorage, O extends PayOrder> implements PayService<PC, O> {
3030
protected final Log LOG = LogFactory.getLog(getClass());
3131
protected PC payConfigStorage;
3232

@@ -138,7 +138,7 @@ public String createSign(Map<String, Object> content, String characterEncoding)
138138
* @return 对应页面重定向信息
139139
*/
140140
@Override
141-
public String toPay(PayOrder order) {
141+
public String toPay(O order) {
142142
Map orderInfo = orderInfo(order);
143143
return buildRequest(orderInfo, MethodType.POST);
144144
}
@@ -150,7 +150,7 @@ public String toPay(PayOrder order) {
150150
* @return 返回图片信息,支付时需要的
151151
*/
152152
@Override
153-
public BufferedImage genQrPay(PayOrder order) {
153+
public BufferedImage genQrPay(O order) {
154154
return MatrixToImageWriter.writeInfoToJpgBuff(getQrPay(order));
155155
}
156156

@@ -463,7 +463,7 @@ public PayMessage createMessage(Map<String, Object> message) {
463463
* @param orderInfo 订单信息
464464
* @return 处理后订单信息
465465
*/
466-
public Map<String, Object> preOrderHandler(Map<String, Object> orderInfo, PayOrder payOrder){
466+
public Map<String, Object> preOrderHandler(Map<String, Object> orderInfo, O payOrder){
467467
return orderInfo;
468468
}
469469

pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* date 2016-5-18 14:09:01
2121
* </pre>
2222
*/
23-
public interface PayService<PC extends PayConfigStorage> {
23+
public interface PayService<PC extends PayConfigStorage, O extends PayOrder> {
2424

2525

2626
/**
@@ -88,15 +88,15 @@ public interface PayService<PC extends PayConfigStorage> {
8888
* @return 订单信息
8989
* @see PayOrder 支付订单信息
9090
*/
91-
Map<String, Object> orderInfo(PayOrder order);
91+
Map<String, Object> orderInfo(O order);
9292

9393
/**
9494
* 页面转跳支付, 返回对应页面重定向信息
9595
*
9696
* @param order 订单信息
9797
* @return 对应页面重定向信息
9898
*/
99-
String toPay(PayOrder order);
99+
String toPay(O order);
100100

101101
/**
102102
* 创建签名
@@ -160,22 +160,22 @@ public interface PayService<PC extends PayConfigStorage> {
160160
* @param order 发起支付的订单信息
161161
* @return 返回图片信息,支付时需要的
162162
*/
163-
BufferedImage genQrPay(PayOrder order);
163+
BufferedImage genQrPay(O order);
164164
/**
165165
* 获取输出二维码信息,
166166
*
167167
* @param order 发起支付的订单信息
168168
* @return 返回二维码信息,,支付时需要的
169169
*/
170-
String getQrPay(PayOrder order);
170+
String getQrPay(O order);
171171

172172
/**
173173
* 刷卡付,pos主动扫码付款(条码付)
174-
*
174+
* 刷脸付
175175
* @param order 发起支付的订单信息
176176
* @return 返回支付结果
177177
*/
178-
Map<String, Object> microPay(PayOrder order);
178+
Map<String, Object> microPay(O order);
179179

180180
/**
181181
* 交易查询接口
@@ -453,4 +453,15 @@ public interface PayService<PC extends PayConfigStorage> {
453453
* @return 支付消息对象
454454
*/
455455
PayMessage createMessage(Map<String, Object> message);
456+
457+
/**
458+
* 预订单回调处理器,用于订单信息的扩展
459+
* 签名之前使用
460+
* 如果需要进行扩展请重写该方法即可
461+
* @param orderInfo 商户平台预订单信息
462+
* @param payOrder 订单信息
463+
* @return 处理后订单信息
464+
*/
465+
Map<String, Object> preOrderHandler(Map<String, Object> orderInfo, O payOrder);
466+
456467
}

pay-java-common/src/main/java/com/egzosn/pay/common/http/ClientHttpRequest.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
import org.apache.http.entity.StringEntity;
2020
import org.apache.http.util.EntityUtils;
2121

22-
import java.io.IOException;
23-
import java.io.InputStream;
24-
import java.io.OutputStream;
22+
import java.io.*;
2523
import java.net.URI;
2624
import java.nio.charset.Charset;
2725
import java.util.Map;
@@ -352,14 +350,27 @@ private T toBean(HttpEntity entity, String[] contentType) throws IOException {
352350

353351
//是否为 输入流
354352
if (InputStream.class.isAssignableFrom(responseType)) {
355-
return (T) entity.getContent();
353+
ByteArrayOutputStream os = new ByteArrayOutputStream();
354+
entity.writeTo(os);
355+
return (T) new ByteArrayInputStream(os.toByteArray());
356+
}
357+
//是否为 字节数数组
358+
if (byte[].class.isAssignableFrom(responseType)) {
359+
ByteArrayOutputStream os = new ByteArrayOutputStream();
360+
entity.writeTo(os);
361+
return (T) os.toByteArray();
356362
}
357363
//输出流
358364
if (OutputStream.class.isAssignableFrom(responseType)) {
359365
try {
360-
T t = responseType.newInstance();
361-
entity.writeTo((OutputStream) t);
362-
return t;
366+
OutputStream t;
367+
if (responseType == OutputStream.class){
368+
t= new ByteArrayOutputStream();
369+
}else {
370+
t = (OutputStream) responseType.newInstance();
371+
}
372+
entity.writeTo( t);
373+
return (T) t;
363374
} catch (InstantiationException e) {
364375
throw new PayErrorException(new PayException("InstantiationException", e.getMessage()));
365376
} catch (IllegalAccessException e) {

pay-java-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<dependency>
8787
<groupId>com.fasterxml.jackson.core</groupId>
8888
<artifactId>jackson-databind</artifactId>
89-
<version>[2.9.9,)</version>
89+
<version>2.9.10</version>
9090
</dependency>
9191

9292
</dependencies>

0 commit comments

Comments
 (0)