|
@@ -29,6 +29,8 @@ public class PayWxV3Service {
|
|
|
@Value("${mta.wxpay.keyPathQinggu}")
|
|
|
private String keyPathQinggu;
|
|
|
|
|
|
+ private static String callbackWx = "/callback/wxpay/notify";
|
|
|
+
|
|
|
|
|
|
// 商户号
|
|
|
private static String mchidDongke = "1570392471";
|
|
@@ -54,8 +56,8 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public String pcDongke(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.pc(this.getConfigDongke(), appid, mchidDongke, paynum, money, body);
|
|
|
+ public String pcDongke(String appid, String pid, int money, String body) throws Exception {
|
|
|
+ return this.pc(this.getConfigDongke(), appid, mchidDongke, pid, money, body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -63,8 +65,8 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public String pcQinggu(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.pc(this.getConfigQinggu(), appid, mchidQinggu, paynum, money, body);
|
|
|
+ public String pcQinggu(String appid, String pid, int money, String body) throws Exception {
|
|
|
+ return this.pc(this.getConfigQinggu(), appid, mchidQinggu, pid, money, body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -73,7 +75,7 @@ public class PayWxV3Service {
|
|
|
* @return 返回用于生成二维码的url
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private String pc(Config config, String appid, String mchid, String paynum, int money, String body) throws Exception {
|
|
|
+ private String pc(Config config, String appid, String mchid, String pid, int money, String body) throws Exception {
|
|
|
com.wechat.pay.java.service.payments.nativepay.NativePayService service = new com.wechat.pay.java.service.payments.nativepay.NativePayService.Builder().config(config).build();
|
|
|
com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest request = new com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest();
|
|
|
com.wechat.pay.java.service.payments.nativepay.model.Amount amount = new com.wechat.pay.java.service.payments.nativepay.model.Amount();
|
|
@@ -82,8 +84,8 @@ public class PayWxV3Service {
|
|
|
request.setAppid(appid);
|
|
|
request.setMchid(mchid);
|
|
|
request.setDescription(body);
|
|
|
- request.setOutTradeNo(paynum);
|
|
|
- request.setNotifyUrl(domain+"/wxpay/notify");
|
|
|
+ request.setOutTradeNo(pid);
|
|
|
+ request.setNotifyUrl(domain + callbackWx);
|
|
|
try {
|
|
|
logger.debug("微信Native支付下单请求参数: {}", JsonUtil.toJson(request));
|
|
|
com.wechat.pay.java.service.payments.nativepay.model.PrepayResponse response = service.prepay(request);
|
|
@@ -101,8 +103,8 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public ApiPayWxAppResponseVo appDongke(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.app(this.getConfigDongke(), appid, mchidDongke, paynum, money, body);
|
|
|
+ public ApiPayWxAppResponseVo appDongke(String appid, String pid, int money, String body) throws Exception {
|
|
|
+ return this.app(this.getConfigDongke(), appid, mchidDongke, pid, money, body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -110,15 +112,15 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public ApiPayWxAppResponseVo appQinggu(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.app(this.getConfigQinggu(), appid, mchidQinggu, paynum, money, body);
|
|
|
+ public ApiPayWxAppResponseVo appQinggu(String appid, String pid, int money, String body) throws Exception {
|
|
|
+ return this.app(this.getConfigQinggu(), appid, mchidQinggu, pid, money, body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* App支付是指商户通过在移动端应用App中集成开放SDK调起微信支付模块来完成支付。目前微信支付支持手机系统有:IOS(苹果)、Android(安卓)和WP(Windows Phone)。
|
|
|
* @return
|
|
|
*/
|
|
|
- private ApiPayWxAppResponseVo app(Config config, String appid, String mchid, String paynum, int money, String body) {
|
|
|
+ private ApiPayWxAppResponseVo app(Config config, String appid, String mchid, String pid, int money, String body) {
|
|
|
com.wechat.pay.java.service.payments.app.AppServiceExtension service = new com.wechat.pay.java.service.payments.app.AppServiceExtension.Builder().config(config).build();
|
|
|
com.wechat.pay.java.service.payments.app.model.PrepayRequest request = new com.wechat.pay.java.service.payments.app.model.PrepayRequest();
|
|
|
com.wechat.pay.java.service.payments.app.model.Amount amount = new com.wechat.pay.java.service.payments.app.model.Amount();
|
|
@@ -127,8 +129,8 @@ public class PayWxV3Service {
|
|
|
request.setAppid(appid);
|
|
|
request.setMchid(mchid);
|
|
|
request.setDescription(body);
|
|
|
- request.setOutTradeNo(paynum);
|
|
|
- request.setNotifyUrl(domain+"/wxpay/notify");
|
|
|
+ request.setOutTradeNo(pid);
|
|
|
+ request.setNotifyUrl(domain + callbackWx);
|
|
|
try {
|
|
|
logger.debug("微信APP支付下单请求参数: {}", JsonUtil.toJson(request));
|
|
|
com.wechat.pay.java.service.payments.app.model.PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
|
@@ -148,8 +150,8 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public ApiPayWxJsApiResponseVo jsapiDongke(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.jsapi(this.getConfigDongke(), appid, mchidDongke, paynum, money, body);
|
|
|
+ public ApiPayWxJsApiResponseVo jsapiDongke(String appid, String pid, int money, String body) throws Exception {
|
|
|
+ return this.jsapi(this.getConfigDongke(), appid, mchidDongke, pid, money, body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -157,15 +159,15 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public ApiPayWxJsApiResponseVo jsapiQinggu(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.jsapi(this.getConfigQinggu(), appid, mchidQinggu, paynum, money, body);
|
|
|
+ public ApiPayWxJsApiResponseVo jsapiQinggu(String appid, String pid, int money, String body) throws Exception {
|
|
|
+ return this.jsapi(this.getConfigQinggu(), appid, mchidQinggu, pid, money, body);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* JSAPI支付是指商户通过调用微信支付提供的JSAPI接口,在支付场景中调起微信支付模块完成收款。
|
|
|
* @return
|
|
|
*/
|
|
|
- private ApiPayWxJsApiResponseVo jsapi(Config config, String appid, String mchid, String paynum, int money, String body) {
|
|
|
+ private ApiPayWxJsApiResponseVo jsapi(Config config, String appid, String mchid, String pid, int money, String body) {
|
|
|
com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension service = new com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension.Builder().config(config).build();
|
|
|
com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest request = new com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest();
|
|
|
com.wechat.pay.java.service.payments.jsapi.model.Amount amount = new com.wechat.pay.java.service.payments.jsapi.model.Amount();
|
|
@@ -174,8 +176,8 @@ public class PayWxV3Service {
|
|
|
request.setAppid(appid);
|
|
|
request.setMchid(mchid);
|
|
|
request.setDescription(body);
|
|
|
- request.setOutTradeNo(paynum);
|
|
|
- request.setNotifyUrl(domain+"/wxpay/notify");
|
|
|
+ request.setOutTradeNo(pid);
|
|
|
+ request.setNotifyUrl(domain + callbackWx);
|
|
|
try {
|
|
|
logger.debug("微信JSAPI支付下单请求参数: {}", JsonUtil.toJson(request));
|
|
|
com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
|
@@ -195,8 +197,8 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public boolean queryDongke(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.query(this.getConfigDongke(), mchidDongke, paynum);
|
|
|
+ public boolean queryDongke(String pid) throws Exception {
|
|
|
+ return this.query(this.getConfigDongke(), mchidDongke, pid);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -204,8 +206,8 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public boolean queryQinggu(String appid, String paynum, int money, String body) throws Exception {
|
|
|
- return this.query(this.getConfigQinggu(), mchidQinggu, paynum);
|
|
|
+ public boolean queryQinggu(String pid) throws Exception {
|
|
|
+ return this.query(this.getConfigQinggu(), mchidQinggu, pid);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -213,11 +215,11 @@ public class PayWxV3Service {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public boolean query(Config config, String mchid, String paynum) throws Exception {
|
|
|
+ public boolean query(Config config, String mchid, String pid) throws Exception {
|
|
|
com.wechat.pay.java.service.payments.nativepay.NativePayService service = new com.wechat.pay.java.service.payments.nativepay.NativePayService.Builder().config(config).build();
|
|
|
com.wechat.pay.java.service.payments.nativepay.model.QueryOrderByOutTradeNoRequest request = new com.wechat.pay.java.service.payments.nativepay.model.QueryOrderByOutTradeNoRequest();
|
|
|
request.setMchid(mchid);
|
|
|
- request.setOutTradeNo(paynum);
|
|
|
+ request.setOutTradeNo(pid);
|
|
|
try {
|
|
|
logger.debug("微信订单查询api请求参数: {}", JsonUtil.toJson(request));
|
|
|
com.wechat.pay.java.service.payments.model.Transaction transaction = service.queryOrderByOutTradeNo(request);
|