/// <summary> /// 订单支付成功商家异步 /// </summary> /// <param name="context"></param> /// <returns></returns> public LineResponsePara LinePayCallBack(HttpContext context) { var responseForm = context.Request.Form; string orderNumber = responseForm["outOrderId"].IsNull() ? string.Empty : responseForm["outOrderId"]; var response = new LineResponsePara() { isPaySuccess = false, orderNumber = orderNumber, paymentMoney = 0, resultMsg = string.Empty }; try { RSAOperate Rdaop = new RSAOperate(); //处理传输过来的流 Stream responseStream = context.Request.InputStream; StreamReader readStream = new StreamReader(responseStream, System.Text.Encoding.UTF8); string RequestStream = readStream.ReadToEnd(); readStream.Close(); if (!string.IsNullOrEmpty(RequestStream)) { string RSAChar = Rdaop.GetUrlParamString(RequestStream, RSASign.GetNoticeRSAParamSort()) + ProperConst.Key; if (Rdaop.GetIsSafty(Rdaop.GetjosnValue(RequestStream, "sign"), RSAChar)) //判断是否报文加密后能够匹配 { lock (lockobject) //此处建议使用lock锁机制,进行并发控制,防止重复数据混乱 { response.isPaySuccess = true; response.orderNumber = responseForm["orderNumber"].IsNull() ? string.Empty : responseForm["orderNumber"]; response.paymentMoney = responseForm["totalAmount"].IsNull() ? (decimal)0.00 : AlipayConfig.MoneyFormatDco(responseForm["totalAmount"]);; response.resultMsg = "支付成功"; } } else { response.resultMsg = "返回报文加密信息存在异常"; context.Response.Write("{\"code\":\"01\",\"msg\":\"返回报文加密信息存在异常\"}"); } } else { response.resultMsg = "返回报文为空存在异常"; context.Response.Write("{\"code\":\"02\",\"msg\":\"返回报文为空存在异常\"}"); } } catch (Exception ex) { response.resultMsg = "报文异常" + ex.Message; context.Response.Write("{\"code\":\"03\",\"msg\":\"报文异常\"}"); } return(response); }
/// <summary> /// 订单支付成功商家异步 /// </summary> /// <param name="context"></param> /// <returns></returns> public LineResponsePara LinePayCallBack(HttpContext context) { var responseForm = context.Request.Form; string orderNumber = responseForm["outOrderId"].IsNull() ? string.Empty : responseForm["outOrderId"]; var response = new LineResponsePara() { isPaySuccess = false, orderNumber = orderNumber, paymentMoney = 0, resultMsg = string.Empty }; try { RSAOperate Rdaop = new RSAOperate(); //处理传输过来的流 Stream responseStream = context.Request.InputStream; StreamReader readStream = new StreamReader(responseStream, System.Text.Encoding.UTF8); string RequestStream = readStream.ReadToEnd(); readStream.Close(); if (!string.IsNullOrEmpty(RequestStream)) { string RSAChar = Rdaop.GetUrlParamString(RequestStream, RSASign.GetNoticeRSAParamSort()) + ProperConst.Key; if (Rdaop.GetIsSafty(Rdaop.GetjosnValue(RequestStream, "sign"), RSAChar))//判断是否报文加密后能够匹配 { lock (lockobject)//此处建议使用lock锁机制,进行并发控制,防止重复数据混乱 { response.isPaySuccess = true; response.orderNumber = responseForm["orderNumber"].IsNull() ? string.Empty : responseForm["orderNumber"]; response.paymentMoney = responseForm["totalAmount"].IsNull() ? (decimal)0.00 : AlipayConfig.MoneyFormatDco(responseForm["totalAmount"]); ; response.resultMsg = "支付成功"; } } else { response.resultMsg = "返回报文加密信息存在异常"; context.Response.Write("{\"code\":\"01\",\"msg\":\"返回报文加密信息存在异常\"}"); } } else { response.resultMsg = "返回报文为空存在异常"; context.Response.Write("{\"code\":\"02\",\"msg\":\"返回报文为空存在异常\"}"); } } catch (Exception ex) { response.resultMsg = "报文异常" + ex.Message; context.Response.Write("{\"code\":\"03\",\"msg\":\"报文异常\"}"); } return response; }