mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-24 03:59:10 +08:00
代码整理优化
This commit is contained in:
@@ -1,20 +1,34 @@
|
||||
package com.egzosn.pay.common.api;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.egzosn.pay.common.bean.*;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.Order;
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
import com.egzosn.pay.common.bean.PayOrder;
|
||||
import com.egzosn.pay.common.bean.PayOutMessage;
|
||||
import com.egzosn.pay.common.bean.RefundOrder;
|
||||
import com.egzosn.pay.common.bean.TransactionType;
|
||||
import com.egzosn.pay.common.bean.TransferOrder;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import com.egzosn.pay.common.http.HttpConfigStorage;
|
||||
import com.egzosn.pay.common.http.HttpRequestTemplate;
|
||||
import com.egzosn.pay.common.util.MatrixToImageWriter;
|
||||
import com.egzosn.pay.common.util.sign.SignUtils;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 支付基础服务
|
||||
@@ -455,6 +469,7 @@ public abstract class BasePayService<PC extends PayConfigStorage> implements Pay
|
||||
protected Map<String, Object> setParameters(Map<String, Object> parameters, String key, Order order) {
|
||||
Object attr = order.getAttr(key);
|
||||
if (null != attr && !"".equals(attr)) {
|
||||
order.getAttrs().remove(key);
|
||||
parameters.put(key, attr);
|
||||
}
|
||||
return parameters;
|
||||
|
||||
@@ -5,9 +5,10 @@ import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 证书存储方式
|
||||
*
|
||||
* @author egan
|
||||
* email egzosn@gmail.com
|
||||
* date 2019/10/13.23:09
|
||||
* email egzosn@gmail.com
|
||||
* date 2019/10/13.23:09
|
||||
*/
|
||||
public interface CertStore {
|
||||
|
||||
|
||||
@@ -2,113 +2,126 @@ package com.egzosn.pay.common.api;
|
||||
|
||||
import com.egzosn.pay.common.bean.Attrs;
|
||||
import com.egzosn.pay.common.bean.MsgType;
|
||||
import com.egzosn.pay.common.util.sign.CertDescriptor;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
* 支付客户端配置存储
|
||||
* @author egan
|
||||
*
|
||||
* @author egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
* date 2016-5-18 14:09:01
|
||||
* </pre>
|
||||
*/
|
||||
public interface PayConfigStorage extends Attrs {
|
||||
public interface PayConfigStorage extends Attrs {
|
||||
|
||||
/**
|
||||
* 附加支付配置
|
||||
*
|
||||
* @return 附加信息
|
||||
*/
|
||||
Object getAttach();
|
||||
Object getAttach();
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
* @return 应用id
|
||||
* 应用id
|
||||
*
|
||||
* @return 应用id
|
||||
*/
|
||||
String getAppid();
|
||||
String getAppid();
|
||||
|
||||
/**
|
||||
* 合作商唯一标识
|
||||
* @return 合作商唯一标识
|
||||
*
|
||||
* @return 合作商唯一标识
|
||||
*/
|
||||
String getPid();
|
||||
String getPid();
|
||||
|
||||
/**
|
||||
* 获取收款账号
|
||||
* @return 收款账号
|
||||
*
|
||||
* @return 收款账号
|
||||
*/
|
||||
String getSeller();
|
||||
String getSeller();
|
||||
|
||||
/**
|
||||
* 授权令牌
|
||||
* @return 授权令牌
|
||||
*
|
||||
* @return 授权令牌
|
||||
*/
|
||||
String getToken();
|
||||
String getToken();
|
||||
|
||||
|
||||
/**
|
||||
* 服务端异步回调Url
|
||||
* @return 异步回调Url
|
||||
*
|
||||
* @return 异步回调Url
|
||||
*/
|
||||
String getNotifyUrl();
|
||||
/**
|
||||
* 服务端同步回调Url
|
||||
* @return 同步回调Url
|
||||
*/
|
||||
String getReturnUrl();
|
||||
/**
|
||||
* 签名方式
|
||||
* @return 签名方式
|
||||
*/
|
||||
String getSignType();
|
||||
String getNotifyUrl();
|
||||
|
||||
/**
|
||||
* 字符编码格式
|
||||
* 服务端同步回调Url
|
||||
*
|
||||
* @return 同步回调Url
|
||||
*/
|
||||
String getReturnUrl();
|
||||
|
||||
/**
|
||||
* 签名方式
|
||||
*
|
||||
* @return 签名方式
|
||||
*/
|
||||
String getSignType();
|
||||
|
||||
/**
|
||||
* 字符编码格式
|
||||
*
|
||||
* @return 字符编码
|
||||
*/
|
||||
String getInputCharset();
|
||||
String getInputCharset();
|
||||
|
||||
/**
|
||||
* 支付平台公钥(签名校验使用)
|
||||
*
|
||||
* @return 公钥
|
||||
*/
|
||||
String getKeyPublic();
|
||||
String getKeyPublic();
|
||||
|
||||
/**
|
||||
* 应用私钥(生成签名时使用)
|
||||
* 应用私钥(生成签名时使用)
|
||||
*
|
||||
* @return 私钥
|
||||
*/
|
||||
String getKeyPrivate();
|
||||
String getKeyPrivate();
|
||||
|
||||
/**
|
||||
* 支付类型 自定义
|
||||
* 这里暂定 aliPay 支付宝, wxPay微信支付
|
||||
*
|
||||
* @return 支付类型
|
||||
*/
|
||||
String getPayType();
|
||||
String getPayType();
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
* @see #getMsgType
|
||||
* @see MsgType
|
||||
*
|
||||
* @return "text" 或者 "xml",json
|
||||
* @see #getMsgType
|
||||
* @see MsgType
|
||||
*/
|
||||
@Deprecated
|
||||
MsgType getMsgType();
|
||||
|
||||
|
||||
MsgType getMsgType();
|
||||
|
||||
|
||||
/**
|
||||
* 应该是线程安全的
|
||||
* @param accessToken 新的accessToken值
|
||||
*
|
||||
* @param accessToken 新的accessToken值
|
||||
* @param expiresInSeconds 过期时间,以秒为单位 多少秒
|
||||
*/
|
||||
void updateAccessToken(String accessToken, int expiresInSeconds);
|
||||
|
||||
/**
|
||||
* 应该是线程安全的
|
||||
*
|
||||
* @param accessToken 新的accessToken值
|
||||
* @param expiresTime 过期时间,时间戳
|
||||
*/
|
||||
@@ -116,10 +129,10 @@ import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
* 是否为测试环境, true测试环境
|
||||
*
|
||||
* @return true测试环境
|
||||
*/
|
||||
boolean isTest();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.egzosn.pay.common.bean;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.egzosn.pay.common.api.CertStore;
|
||||
import com.egzosn.pay.common.bean.result.PayException;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import com.egzosn.pay.common.http.HttpRequestTemplate;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 证书存储类型
|
||||
*
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.egzosn.pay.common.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付订单信息
|
||||
*
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.egzosn.pay.common.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
package com.egzosn.pay.common.http;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.http.Consts;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import static com.egzosn.pay.common.http.UriVariables.getMapToParameters;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -8,23 +35,6 @@ import com.egzosn.pay.common.bean.result.PayException;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import com.egzosn.pay.common.util.XML;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.egzosn.pay.common.http.UriVariables.getMapToParameters;
|
||||
|
||||
/**
|
||||
* 一个HTTP请求的客户端
|
||||
|
||||
Reference in New Issue
Block a user