|
@@ -30,8 +30,8 @@ import org.apache.http.util.EntityUtils;
|
|
* 银联商务H5支付
|
|
* 银联商务H5支付
|
|
*/
|
|
*/
|
|
public class 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 timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
static String nonce = UUID.randomUUID().toString().replace("-", "");
|
|
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 {
|
|
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);
|
|
String bodyDigest = DigestUtils.sha256Hex(content);
|
|
- System.out.println(bodyDigest);
|
|
|
|
String str1_C = appId + timestamp + nonce + bodyDigest;
|
|
String str1_C = appId + timestamp + nonce + bodyDigest;
|
|
byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
|
|
byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
|
|
return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "×tamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(Base64.encodeBase64String(localSignature), "UTF-8"));
|
|
return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "×tamp=" + 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();
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
json.put("instMid", "H5DEFAULT");
|
|
json.put("instMid", "H5DEFAULT");
|
|
- json.put("mid", "898460107420248");
|
|
|
|
|
|
+ json.put("mid", "898310148160568");
|
|
json.put("tid", "88880001");
|
|
json.put("tid", "88880001");
|
|
json.put("totalAmount", 20000);
|
|
json.put("totalAmount", 20000);
|
|
|
|
|
|
- json.put("orderDesc", "345");
|
|
|
|
|
|
+ json.put("orderDesc", "大雅乐盟培训课程");
|
|
// json.put("bizType", "B2B");
|
|
// json.put("bizType", "B2B");
|
|
json.put("merOrderId", "1017" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + RandomStringUtils.randomNumeric(7));
|
|
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("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());
|
|
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);
|
|
// GetOpenBodySig.sendGet("http://58.247.0.18:29015/v1/netpay/webpay/pay?"+param);
|
|
System.out.println(json.toString());
|
|
System.out.println(json.toString());
|
|
}
|
|
}
|