|
|
@@ -22,19 +22,19 @@ public class AllinpaySDK {
|
|
|
// 商户配置信息
|
|
|
private static final String VERSION = "12";
|
|
|
private static final String SIGN_TYPE = "SM2";
|
|
|
- private static final String APP_ID = "00000051";
|
|
|
- private static final String CUS_ID = "990581007426001";
|
|
|
+ private static final String APP_ID = "00375513";
|
|
|
+ private static final String CUS_ID = "660222053994DLK";
|
|
|
|
|
|
// SM2密钥对
|
|
|
- private static final String SM2_PRIVATE_KEY = "";
|
|
|
+ private static final String SM2_PRIVATE_KEY = System.getenv("TL_SM2_PRIVATE_KEY");
|
|
|
|
|
|
// 通联公钥(用于验签,实际使用时需要从通联获取)
|
|
|
- private static final String ALLINPAY_PUBLIC_KEY = "";
|
|
|
+ private static final String ALLINPAY_PUBLIC_KEY = System.getenv("TL_SM2_PUBLIC_KEY");
|
|
|
|
|
|
// 生产环境配置
|
|
|
private static final String BASE_URL = "https://syb.allinpay.com";
|
|
|
private static final String H5_PAY_URL = BASE_URL + "/apiweb/h5unionpay/unionorder";
|
|
|
- private static final String QUERY_URL = "https://syb.allinpay.com/apiweb/unitorder/query";
|
|
|
+ private static final String QUERY_URL = BASE_URL + "/apiweb/unitorder/query";
|
|
|
|
|
|
private static final SM2 sm2 = SmUtil.sm2(SM2_PRIVATE_KEY, ALLINPAY_PUBLIC_KEY);
|
|
|
|
|
|
@@ -60,16 +60,16 @@ public class AllinpaySDK {
|
|
|
try {
|
|
|
// 1. 构建请求参数
|
|
|
Map<String, String> params = new TreeMap<>();
|
|
|
- params.put("appid", APP_ID);
|
|
|
params.put("cusid", CUS_ID);
|
|
|
+ params.put("appid", APP_ID);
|
|
|
params.put("version", VERSION);
|
|
|
+ params.put("trxamt", String.valueOf(trxamt));
|
|
|
params.put("signtype", SIGN_TYPE);
|
|
|
params.put("randomstr", RandomUtil.randomString(8));
|
|
|
- params.put("trxamt", String.valueOf(trxamt));
|
|
|
params.put("reqsn", reqsn);
|
|
|
params.put("body", body);
|
|
|
params.put("remark", remark);
|
|
|
- params.put("notify_url", notify_url);
|
|
|
+ params.put("returl", returl);
|
|
|
|
|
|
// 添加可选参数
|
|
|
if (StrKit.notBlank(returl)) params.put("returl", returl);
|
|
|
@@ -234,9 +234,11 @@ public class AllinpaySDK {
|
|
|
// 设置请求头
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
+
|
|
|
+ String finalUrl = url + "?" + formData;
|
|
|
|
|
|
// 使用JFinal的HttpKit发送请求
|
|
|
- String response = HttpKit.post(url, null, formData.toString(), headers);
|
|
|
+ String response = HttpKit.post(finalUrl, null, null, headers);
|
|
|
|
|
|
if (StrKit.isBlank(response)) {
|
|
|
throw new RuntimeException("API响应为空");
|
|
|
@@ -498,7 +500,7 @@ public class AllinpaySDK {
|
|
|
String reqsn = "TEST" + System.currentTimeMillis(); // 商户订单号
|
|
|
String body = "book";
|
|
|
String remark = "SDKbook";
|
|
|
- String notify_url = "https://your-domain.com/api/payment/callback";
|
|
|
+ String notify_url = "https://dlsh-nft.com.cn/api/hello/";
|
|
|
|
|
|
System.out.println("测试订单号: " + reqsn);
|
|
|
System.out.println("交易金额: " + trxamt + "分");
|
|
|
@@ -506,7 +508,7 @@ public class AllinpaySDK {
|
|
|
// 测试1: H5收银台支付
|
|
|
System.out.println("\n=== 测试H5收银台支付 ===");
|
|
|
PaymentResult payResult = h5Pay(trxamt, reqsn, body, remark, notify_url,
|
|
|
- "https://your-domain.com/return", "UTF-8",
|
|
|
+ "https://dlsh-nft.com.cn", "UTF-8",
|
|
|
30, null, null, null);
|
|
|
System.out.println("支付结果: " + payResult);
|
|
|
|