添加pcpay 支付
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApppayReq implements Serializable {
|
||||
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
public ApppayReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.payType = payType;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class H5payReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
public H5payReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.payType = payType;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class JspayReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
|
||||
private String subAppid;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
public JspayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.payType = payType;
|
||||
this.subAppid = subAppid;
|
||||
this.userId = userId;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ScanpayReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
|
||||
|
||||
public ScanpayReq(String subject, String body, Long amount, String currency, String clientIp, String mchOrderNo, String storeId) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApppayResp implements Serializable {
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String liteInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class H5payResp implements Serializable {
|
||||
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class JspayResp implements Serializable {
|
||||
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ScanpayResp implements Serializable {
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -29,6 +29,13 @@ public class ThirdPayService {
|
||||
|
||||
private static String refund="/api/open/order/refund";
|
||||
|
||||
private static String scanpay="/api/open/payment/scanpay";
|
||||
|
||||
private static String h5pay="/api/open/payment/h5pay";
|
||||
|
||||
private static String jspay="/api/open/payment/jspay";
|
||||
|
||||
private static String apppay="/api/open/payment/apppay";
|
||||
/**
|
||||
* 被扫接口
|
||||
* @param url
|
||||
@@ -47,14 +54,14 @@ public class ThirdPayService {
|
||||
public PublicResp<MainScanResp> mainScan(String url,String appId, String subject, String body, Long amount, String subAppId, String authCode, String orderNo, String storeId, String notifyUrl,
|
||||
String key
|
||||
) {
|
||||
MainScanReq mainScanReq=null;
|
||||
if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
|
||||
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,1,"TA1824003985261588482",null);
|
||||
url="https://paymentweb.sxczgkj.cn";
|
||||
}else {
|
||||
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);
|
||||
}
|
||||
MainScanReq mainScanReq= new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);;
|
||||
// if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
//
|
||||
// mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,1,"TA1824003985261588482",null);
|
||||
// url="https://paymentweb.sxczgkj.cn";
|
||||
// }else {
|
||||
// mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -108,13 +115,13 @@ public class ThirdPayService {
|
||||
|
||||
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
|
||||
String key){
|
||||
WxScanPayReq scanPayReq=null;
|
||||
if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,1,null,"TA1824003985261588482",notifyUrl,returnUrl);
|
||||
url="https://paymentweb.sxczgkj.cn";
|
||||
}else {
|
||||
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
|
||||
}
|
||||
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
|
||||
// if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
// scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,1,null,"TA1824003985261588482",notifyUrl,returnUrl);
|
||||
// url="https://paymentweb.sxczgkj.cn";
|
||||
// }else {
|
||||
// scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
|
||||
// }
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
@@ -247,6 +254,177 @@ public class ThirdPayService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pc 扫码支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<ScanpayResp> pcscanpay(String url,String appId,String key,String subject, String body, Long amount, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl ){
|
||||
ScanpayReq scanpayReq=new ScanpayReq(subject, body, amount, "cny", clientIp, mchOrderNo, storeId);
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(scanpayReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(scanpay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<ScanpayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ScanpayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手机网页支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param payType
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<H5payResp> h5Pay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
H5payReq h5payReq=new H5payReq(subject, body, amount, "cny", payType, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(h5payReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(h5pay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<H5payResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),H5payResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号/生活号/银联js支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param payType
|
||||
* @param subAppid
|
||||
* @param userId
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<JspayResp> jspay(String url,String appId,String key,String subject, String body, Long amount, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
JspayReq jspayReq=new JspayReq(subject, body, amount, "cny", payType, subAppid, userId, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(jspayReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(jspay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<JspayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),JspayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* app 支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param payType
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
|
||||
public PublicResp<ApppayResp> apppay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
ApppayReq apppayReq=new ApppayReq(subject, body, amount, "cny", payType, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
|
||||
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(apppayReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(apppay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<ApppayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ApppayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user