|
@@ -36,20 +36,41 @@ public class WeixinPayController extends Controller {
|
|
|
String origin = this.getRequest().getHeader("Origin");
|
|
|
this.getResponse().setHeader("Access-Control-Allow-Origin", origin);
|
|
|
this.getResponse().setHeader("Access-Control-Allow-Credentials", Boolean.TRUE.toString());
|
|
|
- String asString = this.getPara("out_trade_no");
|
|
|
- String bbString = this.getPara("appId");
|
|
|
- String ccString = this.getPara("openid");
|
|
|
+ String out_trade_no = this.getPara("out_trade_no");
|
|
|
+ if (out_trade_no == null) {
|
|
|
+ renderText("need out_trade_no");
|
|
|
+ }
|
|
|
+ String appId = this.getPara("appId");
|
|
|
+ if (appId == null) {
|
|
|
+ renderText("need appId");
|
|
|
+ }
|
|
|
+ String openid = this.getPara("openid");
|
|
|
+ if (openid == null) {
|
|
|
+ renderText("need openid");
|
|
|
+ }
|
|
|
+ String body = this.getPara("body");
|
|
|
+ if (body == null) {
|
|
|
+ renderText("need body");
|
|
|
+ }
|
|
|
+ String total_fee = this.getPara("total_fee");
|
|
|
+ if (total_fee == null) {
|
|
|
+ renderText("need total_fee");
|
|
|
+ }
|
|
|
+ String notify_url = this.getPara("notify_url");
|
|
|
+ if (notify_url == null) {
|
|
|
+ renderText("need notify_url");
|
|
|
+ }
|
|
|
|
|
|
- ApiConfigKit.setThreadLocalAppId(bbString);
|
|
|
+ ApiConfigKit.setThreadLocalAppId(appId);
|
|
|
|
|
|
// 统一下单文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("appid", appid);
|
|
|
params.put("mch_id", partner);
|
|
|
- params.put("body", "远程诊断收费测试");
|
|
|
- params.put("out_trade_no", asString);
|
|
|
- params.put("total_fee", "1");
|
|
|
+ params.put("body", body);
|
|
|
+ params.put("out_trade_no", out_trade_no);
|
|
|
+ params.put("total_fee", total_fee);
|
|
|
|
|
|
String ip = IpKit.getRealIp(getRequest());
|
|
|
if (StrKit.isBlank(ip)) {
|
|
@@ -60,7 +81,7 @@ public class WeixinPayController extends Controller {
|
|
|
params.put("trade_type", TradeType.JSAPI.name());
|
|
|
params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
|
|
|
params.put("notify_url", notify_url);
|
|
|
- params.put("openid", ccString);
|
|
|
+ params.put("openid", openid);
|
|
|
|
|
|
String sign = PaymentKit.createSign(params, paternerKey);
|
|
|
params.put("sign", sign);
|