package com.nq.pay;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
import org.apache.commons.codec.binary.Hex;
|
|
|
import java.io.UnsupportedEncodingException;
|
import java.security.MessageDigest;
|
import java.security.NoSuchAlgorithmException;
|
import java.util.*;
|
|
public class PayUtil {
|
|
public static String url = "https://order.8ae.one/";
|
|
|
/**
|
* 交易下单接口 通道 1
|
* */
|
public static String PAY_DOWN_ORDER_TOP1 = "https://payment.qeaepay.com/pay/web";
|
public static String PAY_TRANSFER_ORDER_TOP1 = "https://payment.qeaepay.com/pay/transfer";
|
public static String DOWN_TOKEN_TPO1 = "91a54921d9a843848c4e1bb39d90bf67";
|
public static String DF_TOKEN_TOP1 = "DJIIQPJ0VISENUCGJIXIY7EXAJIW8UIO";
|
|
public static String MCH_ID_TOP1 = "400019556";
|
|
|
/**
|
* 交易下单接口 通道 2 wow
|
* */
|
public static String PAY_DOWN_ORDER_TOP4= "https://apis.xdpay168.com/client/collect/create";
|
public static String PAY_TRANSFER_ORDER_TOP4 = "https://payment.qeaepay.com/pay/transfer";
|
public static String DOWN_TOKEN_TPO4 = "caaf82c2beb044a8a599767d8933cdac";
|
public static String DF_TOKEN_TOP4 = "2KPHYUQIA9IQTPUTQDSG7ONPCXYUBEQK";
|
public static String MCH_ID_TOP4= "400019556";
|
|
|
/**
|
* 交易下单接口 通道 3 dz
|
* */
|
public static String PAY_DOWN_ORDER_TOP3= "https://payment.dzxum.com/pay/web";
|
public static String PAY_TRANSFER_ORDER_TOP3 = "https://payment.dzxum.com/pay/transfer";
|
public static String DOWN_TOKEN_TPO3 = "741852f693ae4f40919fbc9090972a18";
|
// public static String DOWN_TOKEN_TPO3 = "imzdixz6zub3jc2whtcw47wxhsluuy5y";
|
|
public static String DF_TOKEN_TOP3 = "WLJXJB3HFE3D95P3TFV8CJXQTIGBV5P0";
|
|
// public static String DF_TOKEN_TOP3 = "4AZQ1RE1ZPNJTHO0ZG3T8M6MKV16II0U";
|
|
public static String MCH_ID_TOP3= "100098228";
|
|
// public static String MCH_ID_TOP3= "100999002";
|
|
/**
|
* 交易下单接口 通道 2
|
* */
|
public static String PAY_DOWN_ORDER_TOP2= "https://pay6de1c7.wowpayglb.com/pay/web";
|
public static String PAY_TRANSFER_ORDER_TOP2 = "https://pay6de1c7.wowpayglb.com/pay/transfer";
|
public static String DOWN_TOKEN_TPO2= "7e33aae9032a4bc5bdfaf2f8fb790c32";
|
// public static String DOWN_TOKEN_TPO2= "TZLMQ1QWJCUSFLH02LAYRZBJ1WK7IHSG";
|
|
public static String DF_TOKEN_TOP2 = "2KPHYUQIA9IQTPUTQDSG7ONPCXYUBEQK";
|
|
// public static String DF_TOKEN_TOP2 = "MZBG89MDIBEDWJOJQYEZVSNP8EEVMSPM";
|
public static String MCH_ID_TOP2= "777777388";
|
|
// public static String MCH_ID_TOP2= "222887002";
|
public static String appid = "658563675da8a";
|
|
// public static String DOWN_TOKEN = "91a54921d9a843848c4e1bb39d90bf67";
|
|
|
|
public static String ascii(Map<String, Object> param, String token, String separator, Boolean empty,String tokenType) {
|
StringBuffer sb = new StringBuffer();
|
List<String> keys = keyAscii(param);
|
for (String key : keys) {
|
if (empty) {
|
sb.append(key).append("=").append(param.get(key)).append(separator);
|
} else {
|
if (!ObjectUtils.isEmpty(param.get(key))) {
|
sb.append(key).append("=").append(param.get(key)).append(separator);
|
}
|
}
|
}
|
if (!ObjectUtils.isEmpty(tokenType)) {
|
sb.append(tokenType).append("=").append(token);
|
} else {
|
sb = sb.deleteCharAt(sb.length() - 1);
|
sb.append(token);
|
}
|
return sb.toString();
|
}
|
|
|
public static List<String> keyAscii(Map<String, Object> parm) {
|
Collection<String> keySet = parm.keySet();
|
List<String> list = new ArrayList<>(keySet);
|
Collections.sort(list);
|
return list;
|
}
|
|
|
public static String sha256(String str) {
|
MessageDigest messageDigest;
|
String encdeStr = "";
|
try {
|
messageDigest = MessageDigest.getInstance("SHA-256");
|
byte[] hash = messageDigest.digest(str.getBytes("UTF-8"));
|
encdeStr = Hex.encodeHexString(hash);
|
} catch (NoSuchAlgorithmException e) {
|
e.printStackTrace();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
}
|
return encdeStr;
|
}
|
|
// public static String getMd5Spring(String key) {
|
// return md5DigestAsHex(key.getBytes());
|
// }
|
//
|
// private static String md5DigestAsHex(byte[] bytes) {
|
// char[] hexDigest = digestAsHexChars("MD5", bytes);
|
// return new String(hexDigest);
|
// }
|
//
|
// private static char[] digestAsHexChars(String algorithm, byte[] bytes) {
|
// byte[] digest = digest(algorithm, bytes);
|
// return encodeHex(digest);
|
// }
|
//
|
// private static char[] encodeHex(byte[] bytes) {
|
// char[] chars = new char[32];
|
// for (int i = 0; i < chars.length; i = i + 2) {
|
// byte b = bytes[i / 2];
|
// chars[i] = HEX_CHARS[(b >>> 0x4) & 0xf];
|
// chars[i + 1] = HEX_CHARS[b & 0xf];
|
// }
|
// return chars;
|
// }
|
|
private static byte[] digest(String algorithm, byte[] bytes) {
|
return getDigest(algorithm).digest(bytes);
|
}
|
|
private static MessageDigest getDigest(String algorithm) {
|
try {
|
return MessageDigest.getInstance(algorithm);
|
} catch (NoSuchAlgorithmException ex) {
|
throw new IllegalStateException("Could not find MessageDigest with algorithm \"" + algorithm + "\"", ex);
|
}
|
|
|
}
|
}
|