mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-08 03:56:48 +08:00
新增请求体原始字符串
This commit is contained in:
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
|
||||
import com.egzosn.pay.common.bean.AssistOrder;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.NoticeParams;
|
||||
import com.egzosn.pay.common.bean.NoticeRequest;
|
||||
@@ -223,14 +222,12 @@ public interface PayService<PC extends PayConfigStorage> {
|
||||
/**
|
||||
* 交易查询接口
|
||||
*
|
||||
* @param assistOrder 查询条件
|
||||
* @param assistOrder 查询条件
|
||||
* @return 返回查询回来的结果集,支付方原值返回
|
||||
*/
|
||||
Map<String, Object> query(AssistOrder assistOrder);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 交易关闭接口
|
||||
*
|
||||
@@ -241,10 +238,11 @@ public interface PayService<PC extends PayConfigStorage> {
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String, Object> close(String tradeNo, String outTradeNo);
|
||||
|
||||
/**
|
||||
* 交易关闭接口
|
||||
*
|
||||
* @param assistOrder 关闭订单
|
||||
* @param assistOrder 关闭订单
|
||||
* @return 返回支付方交易关闭后的结果
|
||||
*/
|
||||
Map<String, Object> close(AssistOrder assistOrder);
|
||||
@@ -343,7 +341,6 @@ public interface PayService<PC extends PayConfigStorage> {
|
||||
Map<String, Object> downloadBill(Date billDate, BillType billType);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*
|
||||
@@ -370,7 +367,9 @@ public interface PayService<PC extends PayConfigStorage> {
|
||||
* @param outNo 商户转账订单号
|
||||
* @param tradeNo 支付平台转账订单号
|
||||
* @return 对应的转账订单
|
||||
* @deprecated 替代{@link TransferService#transferQuery(com.egzosn.pay.common.bean.AssistOrder)}
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String, Object> transferQuery(String outNo, String tradeNo);
|
||||
|
||||
/**
|
||||
@@ -395,15 +394,16 @@ public interface PayService<PC extends PayConfigStorage> {
|
||||
*/
|
||||
@Deprecated
|
||||
PayOutMessage payBack(Map<String, String[]> parameterMap, InputStream is);
|
||||
|
||||
/**
|
||||
* 回调处理
|
||||
* 回调处理
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 获得回调响应信息
|
||||
*/
|
||||
PayOutMessage payBack(NoticeRequest request);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置支付消息处理器,这里用于处理具体的支付业务
|
||||
*
|
||||
|
||||
@@ -29,8 +29,12 @@ import java.util.Map;
|
||||
* email egzosn@gmail.com
|
||||
* date 2021/8/8
|
||||
*/
|
||||
public class NoticeParams {
|
||||
public class NoticeParams implements Attrs {
|
||||
|
||||
/**
|
||||
* body原始字符串
|
||||
*/
|
||||
private String bodyStr;
|
||||
|
||||
/**
|
||||
* 为了获取request里面传过来的动态参数
|
||||
@@ -59,6 +63,14 @@ public class NoticeParams {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public String getBodyStr() {
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
public void setBodyStr(String bodyStr) {
|
||||
this.bodyStr = bodyStr;
|
||||
}
|
||||
|
||||
private <T> T getValueMatchingKey(Map<String, T> values, String key) {
|
||||
T value = values.get(key);
|
||||
if (null != value) {
|
||||
@@ -115,4 +127,15 @@ public class NoticeParams {
|
||||
public void setAttr(Map<String, Object> attr) {
|
||||
this.attr = attr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取属性 这里可用做覆盖已设置的信息属性,订单信息在签名前进行覆盖。
|
||||
*
|
||||
* @return 属性
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getAttrs() {
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class HttpRequestTemplate {
|
||||
|
||||
//指定TLS版本
|
||||
sslsf = new SSLConnectionSocketFactory(
|
||||
sslcontext, new String[]{"TLSv1","TLSv1.2"}, null,
|
||||
sslcontext, new String[]{"TLSv1", "TLSv1.2"}, null,
|
||||
new DefaultHostnameVerifier());
|
||||
|
||||
return sslsf;
|
||||
@@ -268,7 +268,7 @@ public class HttpRequestTemplate {
|
||||
* @param uriVariables 用于匹配表达式
|
||||
* @param <T> 响应类型
|
||||
* @return 类型对象
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, "1", "APP")
|
||||
* </code>
|
||||
@@ -288,11 +288,11 @@ public class HttpRequestTemplate {
|
||||
* @return 类型对象
|
||||
* <code>
|
||||
* Map<String, String> uriVariables = new HashMap<String, String>();<br>
|
||||
*
|
||||
* <p>
|
||||
* uriVariables.put("id", "1");<br>
|
||||
*
|
||||
* <p>
|
||||
* uriVariables.put("type", "APP");<br>
|
||||
*
|
||||
* <p>
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, uriVariables)<br>
|
||||
* </code>
|
||||
*/
|
||||
@@ -334,7 +334,7 @@ public class HttpRequestTemplate {
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, "1", "APP")
|
||||
* </code>
|
||||
*/
|
||||
public <T> ResponseEntity<T> getForObjectEntity(String uri, HttpHeader header, Class<T> responseType, Object... uriVariables) {
|
||||
public <T> ResponseEntity<T> getForObjectEntity(String uri, HttpHeader header, Class<T> responseType, Object... uriVariables) {
|
||||
|
||||
return doExecuteEntity(URI.create(UriVariables.getUri(uri, uriVariables)), header, responseType, MethodType.GET);
|
||||
}
|
||||
@@ -343,24 +343,20 @@ public class HttpRequestTemplate {
|
||||
* get 请求
|
||||
*
|
||||
* @param uri 请求地址
|
||||
* @param header 请求头
|
||||
* @param responseType 响应类型
|
||||
* @param uriVariables 用于匹配表达式
|
||||
* @param <T> 响应类型
|
||||
* @return 类型对象
|
||||
*
|
||||
* <code>
|
||||
* Map<String, String> uriVariables = new HashMap<String, String>();<br>
|
||||
*
|
||||
* uriVariables.put("id", "1");<br>
|
||||
*
|
||||
* uriVariables.put("type", "APP");<br>
|
||||
*
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, uriVariables)<br>
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, "1", "APP")
|
||||
* </code>
|
||||
*/
|
||||
public <T> T getForObject(String uri, HttpHeader header, Class<T> responseType, Map<String, ?> uriVariables) {
|
||||
return getForObjectEntity(uri, header, responseType, uriVariables).getBody();
|
||||
public <T> ResponseEntity<T> getForObjectEntity(String uri, Class<T> responseType, Object... uriVariables) {
|
||||
|
||||
return doExecuteEntity(URI.create(UriVariables.getUri(uri, uriVariables)), null, responseType, MethodType.GET);
|
||||
}
|
||||
|
||||
/**
|
||||
* get 请求
|
||||
*
|
||||
@@ -372,15 +368,38 @@ public class HttpRequestTemplate {
|
||||
* @return 类型对象
|
||||
* <code>
|
||||
* Map<String, String> uriVariables = new HashMap<String, String>();<br>
|
||||
*
|
||||
* <p>
|
||||
* uriVariables.put("id", "1");<br>
|
||||
*
|
||||
* <p>
|
||||
* uriVariables.put("type", "APP");<br>
|
||||
*
|
||||
* <p>
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, uriVariables)<br>
|
||||
* </code>
|
||||
*/
|
||||
public <T> ResponseEntity<T> getForObjectEntity(String uri, HttpHeader header, Class<T> responseType, Map<String, ?> uriVariables) {
|
||||
public <T> T getForObject(String uri, HttpHeader header, Class<T> responseType, Map<String, ?> uriVariables) {
|
||||
return getForObjectEntity(uri, header, responseType, uriVariables).getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* get 请求
|
||||
*
|
||||
* @param uri 请求地址
|
||||
* @param header 请求头
|
||||
* @param responseType 响应类型
|
||||
* @param uriVariables 用于匹配表达式
|
||||
* @param <T> 响应类型
|
||||
* @return 类型对象
|
||||
* <code>
|
||||
* Map<String, String> uriVariables = new HashMap<String, String>();<br>
|
||||
* <p>
|
||||
* uriVariables.put("id", "1");<br>
|
||||
* <p>
|
||||
* uriVariables.put("type", "APP");<br>
|
||||
* <p>
|
||||
* getForObject("http://egan.in/pay/{id}/f/{type}", String.class, uriVariables)<br>
|
||||
* </code>
|
||||
*/
|
||||
public <T> ResponseEntity<T> getForObjectEntity(String uri, HttpHeader header, Class<T> responseType, Map<String, ?> uriVariables) {
|
||||
return doExecuteEntity(URI.create(UriVariables.getUri(uri, uriVariables)), header, responseType, MethodType.GET);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +156,7 @@ public enum SignUtils implements SignType {
|
||||
* @param characterEncoding 编码格式
|
||||
* @return 签名值
|
||||
*/
|
||||
@Override
|
||||
public String sign(Map parameters, String key, String characterEncoding) {
|
||||
|
||||
return createSign(parameterText(parameters, "&"), key, characterEncoding);
|
||||
@@ -170,6 +171,7 @@ public enum SignUtils implements SignType {
|
||||
* @param characterEncoding 编码格式
|
||||
* @return 签名值
|
||||
*/
|
||||
@Override
|
||||
public String sign(Map parameters, String key, String separator, String characterEncoding) {
|
||||
|
||||
return createSign(parameterText(parameters, separator), key, characterEncoding);
|
||||
@@ -186,6 +188,7 @@ public enum SignUtils implements SignType {
|
||||
* @param characterEncoding 编码格式
|
||||
* @return 签名结果
|
||||
*/
|
||||
@Override
|
||||
public boolean verify(Map params, String sign, String key, String characterEncoding) {
|
||||
//判断是否一样
|
||||
return this.verify(parameterText(params), sign, key, characterEncoding);
|
||||
|
||||
Reference in New Issue
Block a user