|
|
@@ -2,6 +2,7 @@ package com.fs.app.controller.store;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.config.FSSysConfig;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
@@ -10,7 +11,11 @@ import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.hisStore.service.*;
|
|
|
import com.fs.huifuPay.domain.HuiFuResult;
|
|
|
+import com.fs.huifuPay.sdk.opps.core.BasePay;
|
|
|
+import com.fs.huifuPay.sdk.opps.core.sign.JsonUtils;
|
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
|
+import com.fs.huifuPay.sdk.opps.core.utils.RsaUtils;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.live.service.ILiveOrderService;
|
|
|
import com.fs.ybPay.domain.OrderCallback;
|
|
|
import com.fs.ybPay.domain.OrderResult;
|
|
|
@@ -74,7 +79,23 @@ public class PayScrmController {
|
|
|
@ApiOperation("汇付第三方支付回调")
|
|
|
@PostMapping(value="/hfPayNotify")
|
|
|
public String hfPayNotify(@RequestParam String resp_desc, @RequestParam String resp_code, @RequestParam String sign, @RequestParam String resp_data) throws Exception {
|
|
|
- //验证
|
|
|
+ // 先验签,防止伪造支付成功回调
|
|
|
+ if (StringUtils.isEmpty(sign) || StringUtils.isEmpty(resp_data)) {
|
|
|
+ logger.error("汇付回调缺少签名或业务数据");
|
|
|
+ return "fail";
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ JSONObject data = JSON.parseObject(resp_data);
|
|
|
+ String sortedData = JsonUtils.sort4JsonString(JSONObject.toJSONString(data), 5);
|
|
|
+ String publicKey = BasePay.HUIFU_DEFAULT_PUBLIC_KEY;
|
|
|
+ if (!RsaUtils.verify(sortedData, publicKey, sign)) {
|
|
|
+ logger.error("汇付回调验签失败, resp_data={}", resp_data);
|
|
|
+ return "fail";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("汇付回调验签异常", e);
|
|
|
+ return "fail";
|
|
|
+ }
|
|
|
HuiFuResult o = JSON.parseObject(resp_data, HuiFuResult.class);
|
|
|
logger.info("汇付支付回调:"+o);
|
|
|
if(o.getResp_code().equals("00000000") && o.getNotify_type().equals("1")){
|