|
@@ -3,9 +3,7 @@ package common.utils.wechat;
|
|
|
import com.wechat.pay.java.core.notification.NotificationConfig;
|
|
import com.wechat.pay.java.core.notification.NotificationConfig;
|
|
|
import com.wechat.pay.java.core.notification.NotificationParser;
|
|
import com.wechat.pay.java.core.notification.NotificationParser;
|
|
|
import com.wechat.pay.java.core.notification.RequestParam;
|
|
import com.wechat.pay.java.core.notification.RequestParam;
|
|
|
-import com.wechat.pay.java.service.payments.h5.model.Amount;
|
|
|
|
|
-import com.wechat.pay.java.service.payments.h5.model.PrepayRequest;
|
|
|
|
|
-import com.wechat.pay.java.service.payments.h5.model.PrepayResponse;
|
|
|
|
|
|
|
+import com.wechat.pay.java.service.payments.h5.model.*;
|
|
|
import com.wechat.pay.java.service.payments.h5.H5Service;
|
|
import com.wechat.pay.java.service.payments.h5.H5Service;
|
|
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
|
|
|
|
|
|
@@ -20,7 +18,7 @@ public class WeChatService {
|
|
|
* @param notifyUrl 支付通知url
|
|
* @param notifyUrl 支付通知url
|
|
|
* @return 结果,主要是H5Url
|
|
* @return 结果,主要是H5Url
|
|
|
*/
|
|
*/
|
|
|
- public static PrepayResponse prepay(Integer amount, String outTradeNo, String notifyUrl) {
|
|
|
|
|
|
|
+ public static PrepayResponse prepay(Integer amount, String outTradeNo, String notifyUrl, SceneInfo sceneInfo) {
|
|
|
PrepayRequest request = new PrepayRequest();
|
|
PrepayRequest request = new PrepayRequest();
|
|
|
|
|
|
|
|
// 交易数量
|
|
// 交易数量
|
|
@@ -34,6 +32,7 @@ public class WeChatService {
|
|
|
request.setDescription("购买ID:" + outTradeNo);
|
|
request.setDescription("购买ID:" + outTradeNo);
|
|
|
request.setNotifyUrl(notifyUrl);
|
|
request.setNotifyUrl(notifyUrl);
|
|
|
request.setOutTradeNo(outTradeNo);
|
|
request.setOutTradeNo(outTradeNo);
|
|
|
|
|
+ request.setSceneInfo(sceneInfo);
|
|
|
|
|
|
|
|
// 调用接口
|
|
// 调用接口
|
|
|
return h5Service.prepay(request);
|
|
return h5Service.prepay(request);
|
|
@@ -63,4 +62,22 @@ public class WeChatService {
|
|
|
// 直接返回tx
|
|
// 直接返回tx
|
|
|
return parser.parse(requestParam, Transaction.class);
|
|
return parser.parse(requestParam, Transaction.class);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 测试支付
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
|
+ // String notifyUrl = System.getenv("URL_BASE") + "/deposit/deposited/";
|
|
|
|
|
+ String notifyUrl = "https://api.dlsh-nft.com.cn" + "/deposit/deposited/";
|
|
|
|
|
+ String outTradeNo = "DLTBH_WX_" + System.currentTimeMillis();
|
|
|
|
|
+ Integer amount = 100;
|
|
|
|
|
+
|
|
|
|
|
+ // 场景信息
|
|
|
|
|
+ H5Info h5Info = new H5Info();
|
|
|
|
|
+ h5Info.setType("Wrp"); // 使用H5支付的场景:Wap、iOS、Android
|
|
|
|
|
+
|
|
|
|
|
+ SceneInfo sceneInfo = new SceneInfo();
|
|
|
|
|
+ sceneInfo.setPayerClientIp("163.53.18.23");
|
|
|
|
|
+ sceneInfo.setH5Info(h5Info);
|
|
|
|
|
+
|
|
|
|
|
+ prepay(amount, outTradeNo, notifyUrl, sceneInfo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|