代码整理,注释增加

This commit is contained in:
egan
2017-10-31 23:40:17 +08:00
parent cdf0225d9e
commit de7218d5ff
13 changed files with 134 additions and 103 deletions

View File

@@ -12,32 +12,18 @@ import com.egzosn.pay.common.api.BasePayConfigStorage;
public class AliPayConfigStorage extends BasePayConfigStorage {
/**
* 商户PID
* 商户应用id
*/
public volatile String appId ;
private volatile String appId ;
/**
* 商户签约拿到的pid,partner_id的简称合作伙伴身份等同于 partner
*/
public volatile String pid ;
private volatile String pid ;
/**
* 商户收款账号
*/
public volatile String seller;
/**
* 公钥
*/
private volatile String aliPublicKey;
public String getAliPublicKey() {
return aliPublicKey;
}
public void setAliPublicKey(String aliPublicKey) {
setKeyPublic(aliPublicKey);
this.aliPublicKey = aliPublicKey;
}
private volatile String seller;

View File

@@ -163,11 +163,6 @@ public class AliPayService extends BasePayService {
*/
private Map<String, Object> getOrder(PayOrder order) {
//兼容上一版本 即时收款
/* if (AliTransactionType.DIRECT == order.getTransactionType() || AliTransactionType.MOBILE == order.getTransactionType() || AliTransactionType.WAPPAY == order.getTransactionType()){
return getOrderBefore(order);
}
*/
Map<String, Object> orderInfo = getPublicParameters(order.getTransactionType());
@@ -185,7 +180,6 @@ public class AliPayService extends BasePayService {
case DIRECT:
bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
orderInfo.put("return_url", payConfigStorage.getReturnUrl());
// bizContent.remove("seller_id");
break;
case WAP:
bizContent.put("product_code", "QUICK_WAP_PAY");
@@ -245,7 +239,6 @@ public class AliPayService extends BasePayService {
valueStr += (i == len - 1) ? values[i] : values[i] + ",";
}
//乱码解决这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
if (!valueStr.matches("\\w+")){
try {
if(valueStr.equals(new String(valueStr.getBytes("iso8859-1"), "iso8859-1"))){
@@ -313,8 +306,7 @@ public class AliPayService extends BasePayService {
Map<String, Object> orderInfo = orderInfo(order);
// Map<String, Object> content = new HashMap<>(1);
// content.put("biz_content", orderInfo.remove("biz_content"));
//预订单
JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(orderInfo), null, JSONObject.class);
JSONObject response = result.getJSONObject("alipay_trade_precreate_response");

View File

@@ -19,16 +19,54 @@ import com.egzosn.pay.common.bean.TransactionType;
* date 2016/10/19 22:58
*/
public enum AliTransactionType implements TransactionType {
//即时到帐 //手机网站支付
DIRECT("alipay.trade.page.pay"),APP("alipay.trade.app.pay"),WAP("alipay.trade.wap.pay")
// TODO 2017/2/23 20:26 author: egan 以下三个为主动交易类型 暂未测试,
//扫码付 //条码付 // 声波付
,SWEEPPAY("alipay.trade.precreate"),BAR_CODE("alipay.trade.pay"),WAVE_CODE("alipay.trade.pay")
//交易辅助接口
,QUERY("alipay.trade.query"),CLOSE("alipay.trade.close"),REFUND("alipay.trade.refund"),REFUNDQUERY("alipay.trade.fastpay.refund.query"),DOWNLOADBILL("alipay.data.dataservice.bill.downloadurl.query")
/**
* 即时到帐
*/
DIRECT("alipay.trade.page.pay"),
/**
* APP支付
*/
APP("alipay.trade.app.pay"),
/**
* 手机网站支付
*/
WAP("alipay.trade.wap.pay")
/**
* 扫码付
*/
,SWEEPPAY("alipay.trade.precreate"),
/**
* 条码付
*/
BAR_CODE("alipay.trade.pay"),
/**
* 声波付
*/
WAVE_CODE("alipay.trade.pay")
//交易辅助接口
/**
* 交易订单查询
*/
,QUERY("alipay.trade.query"),
/**
* 交易订单关闭
*/
CLOSE("alipay.trade.close"),
/**
* 退款
*/
REFUND("alipay.trade.refund"),
/**
* 退款查询
*/
REFUNDQUERY("alipay.trade.fastpay.refund.query"),
/**
* 下载对账单
*/
DOWNLOADBILL("alipay.data.dataservice.bill.downloadurl.query")
//回调通知,回调后不清楚交易类型,以此定义
,UNAWARE("UNAWARE")
;
@@ -44,7 +82,7 @@ public enum AliTransactionType implements TransactionType {
return this.name();
}
/**
/* *
* 获取接口名称
* @return 接口名称
*/

View File

@@ -36,8 +36,8 @@ public class AliPayService extends BasePayService {
protected final Log LOG = LogFactory.getLog(AliPayService.class);
private String HTTPS_REQ_URL = "https://mapi.alipay.com/gateway.do";
private String QUERY_REQ_URL = "https://openapi.alipay.com/gateway.do";
private static final String HTTPS_REQ_URL = "https://mapi.alipay.com/gateway.do";
private static final String QUERY_REQ_URL = "https://openapi.alipay.com/gateway.do";
public AliPayService(PayConfigStorage payConfigStorage) {
super(payConfigStorage);
@@ -164,7 +164,7 @@ public class AliPayService extends BasePayService {
}
private String getOrderInfo(PayOrder order) {
String orderInfo = "partner=\"" + this.payConfigStorage.getPartner() + "\"";
String orderInfo = "partner=\"" + this.payConfigStorage.getPid() + "\"";
orderInfo = orderInfo + "&seller_id=\"" + this.payConfigStorage.getSeller() + "\"";
orderInfo = orderInfo + "&out_trade_no=\"" + order.getOutTradeNo() + "\"";
orderInfo = orderInfo + "&subject=\"" + order.getSubject() + "\"";
@@ -190,7 +190,7 @@ public class AliPayService extends BasePayService {
private Map<String, Object> getOrder(PayOrder order) {
Map<String, Object> orderInfo = new TreeMap<>();
// 签约合作者身份ID
orderInfo.put("partner", payConfigStorage.getPartner());
orderInfo.put("partner", payConfigStorage.getPid());
// 签约卖家支付宝账号
orderInfo.put("seller_id", payConfigStorage.getSeller());
// 商户网站唯一订单号

View File

@@ -22,13 +22,41 @@ import com.egzosn.pay.common.bean.TransactionType;
*/
@Deprecated
public enum AliTransactionType implements TransactionType {
//即时到帐 //移动支付 //手机网站支付
DIRECT("create_direct_pay_by_user"),APP("mobile.securitypay.pay"),WAP("alipay.wap.create.direct.pay.by.user"),
//交易辅助接口
QUERY("alipay.trade.query"),CLOSE("alipay.trade.close"),REFUND("alipay.trade.refund"),REFUNDQUERY("alipay.trade.fastpay.refund.query"),DOWNLOADBILL("alipay.data.dataservice.bill.downloadurl.query")
/**
* 即时到帐
*/
DIRECT("create_direct_pay_by_user"),
/**
* 移动支付
*/
APP("mobile.securitypay.pay"),
/**
* 手机网站支付
*/
WAP("alipay.wap.create.direct.pay.by.user"),
//不知道交易类型,主要用于回调通知,回调后不清楚交易类型,以此定义
,UNAWARE("UNAWARE")
//交易辅助接口
/**
* 交易订单查询
*/
QUERY("alipay.trade.query"),
/**
* 交易订单关闭
*/
CLOSE("alipay.trade.close"),
/**
* 退款
*/
REFUND("alipay.trade.refund"),
/**
* 退款查询
*/
REFUNDQUERY("alipay.trade.fastpay.refund.query"),
/**
* 下载对账单
*/
DOWNLOADBILL("alipay.data.dataservice.bill.downloadurl.query")
;
private String method;