public ActionResult AllinpayRefund(string appId, string appSecret, string orderId) { if (appSecret != AppCache.GetAppSecret(appId)) { return(Json(new { msg = "非法appSecret" })); } var resultInfo = PayResultDAL.GetValidPayResult(orderId, AppEnum.PayType.Allinpay); if (resultInfo == null || resultInfo.SysNo <= 0) { return(Json(new { msg = "订单无支付记录" })); } var requestInfo = PayRequestDAL.GetPayRequest(resultInfo.RequestSysNo); var orderTime = JsonHelper.Deserialize <PayOrderInfo>(requestInfo.RequestData).OrderTime; RefundOrderInfo info = new RefundOrderInfo() { OrderId = orderId, OrderTime = orderTime ?? DateTime.Now.ToString("yyyyMMddHHmmss"), TradeNo = resultInfo.TradeNo, PaymentAmt = resultInfo.PaymentAmt.ToString(), RefundOrderId = DateTime.Now.ToString("yyyyMMddHHmmssfff"), RefundAmt = resultInfo.PaymentAmt.ToString(), NotifyUrl = string.Format("http://{0}/Test/RefundNotify?type=0", AppConfig.Global.Domain), }; var setting = JsonHelper.GetDefaultSettings(); setting.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; string data = JsonHelper.Serialize(info, setting); string sign = SignManager.CreateSign(appId, data).Data; ViewBag.AppId = appId; ViewBag.Sign = sign; ViewBag.Data = data; ViewBag.Title = "通联支付退款(测试)"; ViewBag.Url = "/allinpay/syncrefund"; return(View("Pay")); }
/// <summary> /// 生成签名 /// </summary> /// <param name="data">生成签名的数据</param> /// <param name="appId">业务系统ID</param> /// <returns></returns> public static ExecuteResult <string> CreateSign(string appId, string data) { var result = new ExecuteResult <string>(); if (string.IsNullOrWhiteSpace(appId)) { result.Message = "appId参数不能为空"; result.Status = ResultStatus.Failure; return(result); } if (string.IsNullOrWhiteSpace(data)) { result.Message = "data参数不能为空"; result.Status = ResultStatus.Failure; return(result); } if (!data.IsJsonString()) { result.Message = "data参数必须为json格式"; result.Status = ResultStatus.Failure; return(result); } string appSecret = AppCache.GetAppSecret(appId); if (string.IsNullOrWhiteSpace(appSecret)) { result.Message = "appId不存在"; result.Status = ResultStatus.Failure; return(result); } result.Data = CryptoHelper.SignEncrypt(data, appSecret); result.Status = ResultStatus.Success; return(result); }