Browse Source

增加银联接口

周箭河 5 years ago
parent
commit
6d3108a41c

+ 6 - 8
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/union/H5.java

@@ -30,8 +30,8 @@ import org.apache.http.util.EntityUtils;
  * 银联商务H5支付
  */
 public class H5 {
-    static String appId = "10037e6f66f2d0f901672aa27d690006";
-    static String appKey = "47ace12ae3b348fe93ab46cee97c6fde";
+    static String appId = "10037e6f6a4e6da4016a670fd4530012";
+    static String appKey = "f7a74b6c02ae4e1e94aaba311c04acf2";
     static String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
     static String nonce = UUID.randomUUID().toString().replace("-", "");
 
@@ -43,9 +43,7 @@ public class H5 {
     }
 
     public static String getOpenBodySigForNetpay(String appId, String appKey, String timestamp, String nonce, String content) throws Exception {
-        //String bodyDigest = DigestUtils.sha256Hex(URLDecoder.decode(content, "UTF-8"));
         String bodyDigest = DigestUtils.sha256Hex(content);
-        System.out.println(bodyDigest);
         String str1_C = appId + timestamp + nonce + bodyDigest;
         byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
         return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(Base64.encodeBase64String(localSignature), "UTF-8"));
@@ -55,19 +53,19 @@ public class H5 {
         JSONObject json = new JSONObject();
 
         json.put("instMid", "H5DEFAULT");
-        json.put("mid", "898460107420248");
+        json.put("mid", "898310148160568");
         json.put("tid", "88880001");
         json.put("totalAmount", 20000);
 
-        json.put("orderDesc", "345");
+        json.put("orderDesc", "大雅乐盟培训课程");
         // json.put("bizType", "B2B");
         json.put("merOrderId", "1017" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + RandomStringUtils.randomNumeric(7));
         json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
-        json.put("returnUrl","http://dev.dayaedu.com");
+        json.put("returnUrl", "http://dev.dayaedu.com");
 
 
         String param = getOpenBodySigForNetpay(appId, appKey, timestamp, nonce, json.toString());
-        System.out.println("http://58.247.0.18:29015/v1/netpay/webpay/pay?" + param);
+        System.out.println("http://58.247.0.18:29015/v1/netpay/trade/h5-pay?" + param);
 //        GetOpenBodySig.sendGet("http://58.247.0.18:29015/v1/netpay/webpay/pay?"+param);
         System.out.println(json.toString());
     }

+ 5 - 7
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/union/Mp.java

@@ -19,8 +19,8 @@ import java.util.UUID;
  * 银联商务公众号支付
  */
 public class Mp {
-    static String appId = "10037e6f66f2d0f901672aa27d690006";
-    static String appKey = "47ace12ae3b348fe93ab46cee97c6fde";
+    static String appId = "10037e6f6a4e6da4016a62a47e51000c";
+    static String appKey = "b4b70d123a724972bc21f445b0b9f75c";
     static String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
     static String nonce = UUID.randomUUID().toString().replace("-", "");
 
@@ -32,9 +32,7 @@ public class Mp {
     }
 
     public static String getOpenBodySigForNetpay(String appId, String appKey, String timestamp, String nonce, String content) throws Exception {
-        //String bodyDigest = DigestUtils.sha256Hex(URLDecoder.decode(content, "UTF-8"));
         String bodyDigest = DigestUtils.sha256Hex(content);
-        System.out.println(bodyDigest);
         String str1_C = appId + timestamp + nonce + bodyDigest;
         byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
         return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(Base64.encodeBase64String(localSignature), "UTF-8"));
@@ -45,10 +43,10 @@ public class Mp {
 
         json.put("instMid", "YUEDANDEFAULT");
         json.put("mid", "898460107420248");
-        json.put("tid", "88880001");
-        json.put("totalAmount", 20000);
+        json.put("tid", "00000001");
+        json.put("totalAmount", 4000);
 
-        json.put("orderDesc", "345");
+        json.put("orderDesc", "大雅乐盟培训订单");
         // json.put("bizType", "B2B");
         json.put("merOrderId", "1017" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + RandomStringUtils.randomNumeric(7));
         json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));