|
|
@@ -33,14 +33,16 @@ public class SybPayService {
|
|
|
* @param goods_tag 单品优惠信息
|
|
|
* @param chnlstoreid
|
|
|
* @param subbranch
|
|
|
- * @param extendparams具体见接口文档
|
|
|
+ * @param extendparams 具体见接口文档
|
|
|
* @param cusip 限云闪付JS支付业务
|
|
|
* @param fqnum 限支付宝分期业务
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Map<String, String> pay(long trxamt, String reqsn, String paytype, String body, String remark, String acct, String validtime, String notify_url, String limit_pay,
|
|
|
- String idno, String truename, String asinfo, String sub_appid, String goods_tag, String benefitdetail, String chnlstoreid, String subbranch, String extendparams, String cusip, String fqnum) throws Exception {
|
|
|
+ String idno, String truename, String asinfo, String sub_appid, String goods_tag, String benefitdetail, String chnlstoreid, String subbranch,
|
|
|
+ String extendparams, String cusip, String fqnum, String cusId, String appId, String orgid, String transactionType, String sybMdAppkey,
|
|
|
+ String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey) throws Exception {
|
|
|
|
|
|
|
|
|
TreeMap<String, String> params = new TreeMap<String, String>();
|
|
|
@@ -50,14 +52,16 @@ public class SybPayService {
|
|
|
params.put("appid", SybConstants.SYB_APPID_TEST);
|
|
|
url = SybConstants.SYB_APIURL_TEST;
|
|
|
} else {*/
|
|
|
- params.put("cusid", SybConstants.SYB_CUSID);
|
|
|
- params.put("appid", SybConstants.SYB_APPID);
|
|
|
+ //params.put("cusid", SybConstants.SYB_CUSID);
|
|
|
+ //params.put("appid", SybConstants.SYB_APPID);
|
|
|
+ params.put("cusid", cusId);
|
|
|
+ params.put("appid", appId);
|
|
|
url = SybConstants.SYB_APIURL;
|
|
|
/*}*/
|
|
|
HttpConnectionUtil http = new HttpConnectionUtil(url + "/pay");
|
|
|
http.init();
|
|
|
- if (!SybUtil.isEmpty(SybConstants.SYB_ORGID))
|
|
|
- params.put("orgid", SybConstants.SYB_ORGID);
|
|
|
+ if (!SybUtil.isEmpty(orgid))
|
|
|
+ params.put("orgid", orgid);
|
|
|
params.put("version", "11");
|
|
|
params.put("trxamt", String.valueOf(trxamt));
|
|
|
params.put("reqsn", reqsn);
|
|
|
@@ -92,22 +96,25 @@ public class SybPayService {
|
|
|
appkey = SybConstants.SYB_MD5_APPKEY_TEST;
|
|
|
params.put("sign", SybUtil.unionSign(params, appkey, SybConstants.SIGN_TYPE_TEST));
|
|
|
} else {*/
|
|
|
- params.put("signtype", SybConstants.SIGN_TYPE);
|
|
|
+ params.put("signtype", transactionType);
|
|
|
String appkey = "";
|
|
|
- if (SybConstants.SIGN_TYPE.equals("RSA"))
|
|
|
- appkey = SybConstants.SYB_RSACUSPRIKEY;
|
|
|
- else if (SybConstants.SIGN_TYPE.equals("SM2"))
|
|
|
- appkey = SybConstants.SYB_SM2PPRIVATEKEY;
|
|
|
+ if (transactionType.equals("RSA"))
|
|
|
+ //appkey = SybConstants.SYB_RSACUSPRIKEY;
|
|
|
+ appkey =sybRsacusprikey;
|
|
|
+ else if (transactionType.equals("SM2"))
|
|
|
+ //appkey = SybConstants.SYB_SM2PPRIVATEKEY;
|
|
|
+ appkey = sybSmpprivatekey;
|
|
|
else
|
|
|
- appkey = SybConstants.SYB_MD5_APPKEY;
|
|
|
- params.put("sign", SybUtil.unionSign(params, appkey, SybConstants.SIGN_TYPE));
|
|
|
+ //appkey = SybConstants.SYB_MD5_APPKEY;
|
|
|
+ appkey = sybMdAppkey;
|
|
|
+ params.put("sign", SybUtil.unionSign(params, appkey, transactionType));
|
|
|
// }
|
|
|
System.out.println("请求数据===" + params);
|
|
|
byte[] bys = http.postParams(params, true);
|
|
|
System.out.println("第二步===" + bys);
|
|
|
String result = new String(bys, "UTF-8");
|
|
|
System.out.println("第三步===" + result);
|
|
|
- Map<String, String> map = handleResult(result);
|
|
|
+ Map<String, String> map = handleResult(result, transactionType, sybRsacusprikey, sybSmpprivatekey, sybMdAppkey);
|
|
|
System.out.println("第四步===" + map);
|
|
|
return map;
|
|
|
|
|
|
@@ -158,17 +165,18 @@ public class SybPayService {
|
|
|
// }
|
|
|
byte[] bys = http.postParams(params, true);
|
|
|
String result = new String(bys, "UTF-8");
|
|
|
- Map<String, String> map = handleResult(result);
|
|
|
+ Map<String, String> map = handleResult(result, SybConstants.SIGN_TYPE, SybConstants.SYB_RSACUSPRIKEY, SybConstants.SYB_SM2PPRIVATEKEY, SybConstants.SYB_MD5_APPKEY);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public Map<String, String> refund(long trxamt, String reqsn, String oldtrxid, String oldreqsn) throws Exception {
|
|
|
+ public Map<String, String> refund(long trxamt, String reqsn, String oldtrxid, String oldreqsn, String cusId, String appId, String orgid, String transactionType, String sybMdAppkey,
|
|
|
+ String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey) throws Exception {
|
|
|
TreeMap<String, String> params = new TreeMap<String, String>();
|
|
|
- if (!SybUtil.isEmpty(SybConstants.SYB_ORGID))
|
|
|
- params.put("orgid", SybConstants.SYB_ORGID);
|
|
|
+ if (!SybUtil.isEmpty(orgid))
|
|
|
+ params.put("orgid", orgid);
|
|
|
String url = "";
|
|
|
- params.put("cusid", SybConstants.SYB_CUSID);
|
|
|
- params.put("appid", SybConstants.SYB_APPID);
|
|
|
+ params.put("cusid", cusId);
|
|
|
+ params.put("appid", appId);
|
|
|
url = SybConstants.SYB_APIURL;
|
|
|
HttpConnectionUtil http = new HttpConnectionUtil(url + "/refund");
|
|
|
http.init();
|
|
|
@@ -178,11 +186,11 @@ public class SybPayService {
|
|
|
params.put("oldreqsn", oldreqsn);
|
|
|
params.put("oldtrxid", oldtrxid);
|
|
|
params.put("randomstr", SybUtil.getValidatecode(8));
|
|
|
- params.put("signtype", SybConstants.SIGN_TYPE);
|
|
|
- params.put("sign", SybUtil.unionSign(params, SybConstants.SYB_MD5_APPKEY, SybConstants.SIGN_TYPE));
|
|
|
+ params.put("signtype", transactionType);
|
|
|
+ params.put("sign", SybUtil.unionSign(params, sybMdAppkey, transactionType));
|
|
|
byte[] bys = http.postParams(params, true);
|
|
|
String result = new String(bys, "UTF-8");
|
|
|
- Map<String, String> map = handleResult(result);
|
|
|
+ Map<String, String> map = handleResult(result, transactionType, sybRsacusprikey, sybSmpprivatekey, sybMdAppkey);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
@@ -229,13 +237,13 @@ public class SybPayService {
|
|
|
// }
|
|
|
byte[] bys = http.postParams(params, true);
|
|
|
String result = new String(bys, "UTF-8");
|
|
|
- Map<String, String> map = handleResult(result);
|
|
|
+ Map<String, String> map = handleResult(result, SybConstants.SIGN_TYPE, SybConstants.SYB_RSACUSPRIKEY, SybConstants.SYB_SM2PPRIVATEKEY, SybConstants.SYB_MD5_APPKEY);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
|
|
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
- public static Map<String, String> handleResult(String result) throws Exception {
|
|
|
+ public static Map<String, String> handleResult(String result, String transactionType, String sybRsacusprikey, String sybSmpprivatekey, String sybMdAppkey) throws Exception {
|
|
|
System.out.println("ret:" + result);
|
|
|
Map map = SybUtil.json2Obj(result, Map.class);
|
|
|
if (map == null) {
|
|
|
@@ -245,13 +253,13 @@ public class SybPayService {
|
|
|
TreeMap tmap = new TreeMap();
|
|
|
tmap.putAll(map);
|
|
|
String appkey = "";
|
|
|
- if (SybConstants.SIGN_TYPE.equals("RSA"))
|
|
|
- appkey = SybConstants.SYB_RSATLPUBKEY;
|
|
|
- else if (SybConstants.SIGN_TYPE.equals("SM2"))
|
|
|
- appkey = SybConstants.SYB_SM2TLPUBKEY;
|
|
|
+ if (transactionType.equals("RSA"))
|
|
|
+ appkey = sybRsacusprikey;
|
|
|
+ else if (transactionType.equals("SM2"))
|
|
|
+ appkey = sybSmpprivatekey;
|
|
|
else
|
|
|
- appkey = SybConstants.SYB_MD5_APPKEY;
|
|
|
- if (SybUtil.validSign(tmap, appkey, SybConstants.SIGN_TYPE)) {
|
|
|
+ appkey = sybMdAppkey;
|
|
|
+ if (SybUtil.validSign(tmap, appkey, transactionType)) {
|
|
|
System.out.println("签名成功");
|
|
|
return map;
|
|
|
} else {
|
|
|
@@ -313,7 +321,7 @@ public class SybPayService {
|
|
|
// }
|
|
|
byte[] bys = http.postParams(params, true);
|
|
|
String result = new String(bys, "UTF-8");
|
|
|
- Map<String, String> map = handleResult(result);
|
|
|
+ Map<String, String> map = handleResult(result, SybConstants.SIGN_TYPE, SybConstants.SYB_RSACUSPRIKEY, SybConstants.SYB_SM2PPRIVATEKEY, SybConstants.SYB_MD5_APPKEY);
|
|
|
return map;
|
|
|
}
|
|
|
|