|
|
@@ -3,6 +3,7 @@ package common.utils.wechat;
|
|
|
import com.wechat.pay.java.core.notification.NotificationConfig;
|
|
|
import com.wechat.pay.java.core.notification.NotificationParser;
|
|
|
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.H5Service;
|
|
|
@@ -11,10 +12,29 @@ import com.wechat.pay.java.service.payments.model.Transaction;
|
|
|
public class WeChatService {
|
|
|
static H5Service h5Service = WeChatConfig.getService();
|
|
|
|
|
|
- /** H5支付下单 */
|
|
|
- public static PrepayResponse prepay() {
|
|
|
+ /**
|
|
|
+ * H5支付下单
|
|
|
+ *
|
|
|
+ * @param amount 订单数量
|
|
|
+ * @param outTradeNo 内部订单号
|
|
|
+ * @param notifyUrl 支付通知url
|
|
|
+ * @return 结果,主要是H5Url
|
|
|
+ */
|
|
|
+ public static PrepayResponse prepay(Integer amount, String outTradeNo, String notifyUrl) {
|
|
|
PrepayRequest request = new PrepayRequest();
|
|
|
- // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
|
|
+
|
|
|
+ // 交易数量
|
|
|
+ Amount amountM = new Amount();
|
|
|
+ amountM.setTotal(amount);
|
|
|
+
|
|
|
+ // 参数配置
|
|
|
+ request.setAmount(amountM);
|
|
|
+ request.setAppid(WeChatConfig.appId);
|
|
|
+ request.setMchid(WeChatConfig.merchantId);
|
|
|
+ request.setDescription("购买ID:" + outTradeNo);
|
|
|
+ request.setNotifyUrl(notifyUrl);
|
|
|
+ request.setOutTradeNo(outTradeNo);
|
|
|
+
|
|
|
// 调用接口
|
|
|
return h5Service.prepay(request);
|
|
|
}
|