添加pcpay 支付
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ChrpayReq implements Serializable {
|
||||
|
||||
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
private String payType;
|
||||
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
public ChrpayReq(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,51 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ChrpayResp 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;
|
||||
}
|
||||
@@ -36,6 +36,8 @@ public class ThirdPayService {
|
||||
private static String jspay="/api/open/payment/jspay";
|
||||
|
||||
private static String apppay="/api/open/payment/apppay";
|
||||
|
||||
private static String chrpay="/api/open/payment/chrpay";
|
||||
/**
|
||||
* 被扫接口
|
||||
* @param url
|
||||
@@ -420,6 +422,47 @@ public class ThirdPayService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 聚合收银台
|
||||
* @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<ChrpayResp> chrpay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
ChrpayReq chrpayReq=new ChrpayReq(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(chrpayReq));
|
||||
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(chrpay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<ChrpayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ChrpayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user