字符处理

This commit is contained in:
egzosn
2020-01-06 11:29:59 +08:00
parent afd3797f03
commit 7f642fc0e2
5 changed files with 17 additions and 18 deletions

View File

@@ -53,7 +53,7 @@ public class PayTest {
/*-----------即时到帐 WAP 网页支付-------------------*/
// payOrder.setTransactionType(AliTransactionType.WAP); //WAP支付
payOrder.setTransactionType(AliTransactionType.DIRECT); // 即时到帐 PC网页支付
payOrder.setTransactionType(AliTransactionType.PAGE); // 即时到帐 PC网页支付
//获取支付所需的信息
Map directOrderInfo = service.orderInfo(payOrder);
//获取表单提交对应的字符串,将其序列化到页面即可,

View File

@@ -5,6 +5,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.egzosn.pay.common.util.str.StringUtils;
/**
* 支付订单信息
*
@@ -99,10 +101,10 @@ public class PayOrder implements Order {
}
public PayOrder(String subject, String body, BigDecimal price, String outTradeNo, TransactionType transactionType) {
this.subject = tryTrim(subject);
this.body = tryTrim(body);
this.subject = StringUtils.tryTrim(subject);
this.body = StringUtils.tryTrim(body);
this.price = price;
this.outTradeNo = tryTrim(outTradeNo);
this.outTradeNo = StringUtils.tryTrim(outTradeNo);
this.transactionType = transactionType;
}
@@ -273,15 +275,6 @@ public class PayOrder implements Order {
}
/**
* 对 subject body 进行 trim 运算,
* 以防止在签名是可能造成的签名错误问题
* @param str
* @return
*/
private static String tryTrim(String str) {
return str == null ? null : str.trim();
}
@Override
public String toString() {

View File

@@ -125,5 +125,14 @@ public class StringUtils {
throw new RuntimeException("转码过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
}
}
/**
* 对 subject body 进行 trim 运算,
* 以防止在签名是可能造成的签名错误问题
* @param str 字符
* @return 去除空格之后的字符
*/
public static String tryTrim(String str) {
return str == null ? null : str.trim();
}
}

View File

@@ -14,7 +14,7 @@ public enum PayType implements BasePayType {
aliPay{
/**
* @see com.egzosn.pay.ali.api.AliPayService 17年更新的版本,旧版本请自行切换{@link com.egzosn.pay.ali.before.api.AliPayService }
* @see com.egzosn.pay.ali.api.AliPayService
* @param apyAccount
* @return
*/
@@ -176,7 +176,6 @@ public class PayResponse {
router = new PayMessageRouter(this.service);
router
.rule()
.async(false)
.msgType(MsgType.text.name()) //消息类型
.payType(PayType.aliPay.name()) //支付账户事件类型
.transactionType(AliTransactionType.UNAWARE.name())//交易类型,有关回调的可在这处理
@@ -184,13 +183,11 @@ public class PayResponse {
.handler(autowire(new AliPayMessageHandler(payId))) //处理器
.end()
.rule()
.async(false)
.msgType(MsgType.xml.name())
.payType(PayType.wxPay.name())
.handler(autowire(new WxPayMessageHandler(payId)))
.end()
.rule()
.async(false)
.msgType(MsgType.json.name())
.payType(PayType.youdianPay.name())
.handler(autowire(new YouDianPayMessageHandler(payId)))

View File

@@ -43,7 +43,7 @@ public enum PayType implements BasePayType {
aliPay{
/**
* @see com.egzosn.pay.ali.api.AliPayService 17年更新的版本,旧版本请自行切换
* @see com.egzosn.pay.ali.api.AliPayService
* @param apyAccount
* @return
*/