/// <summary> /// 创建生成支付通知 /// </summary> /// <param name="reqModel"></param> /// <returns></returns> public override SxfPayReturn Build(SxfPayNotifyRequest reqModel) { TradeOrder tradeOrder = null; var tradeResult = new TradeResult(reqModel); //保存通知结果并更改TradeOrder状态 var isSucc = PaySvc.SaveMchTradeResult(tradeResult, out tradeOrder); if (!isSucc) { return(SxfPayReturn.Fail(msg: "数据接收失败")); } else { try { var payNotify = new NotifyPayRequest(tradeOrder, tradeResult); var payNotifyDic = PaySignHelper.ToASCIIDictionary(payNotify); return(SendPost(PayConst.QCTTRADE_NOTIFY_PAY, payNotifyDic, tradeOrder.CID, tradeOrder.PayNotifyUrl)); } catch (Exception ex) { LogEngine.WriteError(string.Format("发起支付后台通知请求异常:商户ID:{0},门店ID:{1},返回参数:{2}", reqModel.MerchantId, reqModel.ShopId, reqModel.ToJson()), null, LogModule.支付交易); return(SxfPayReturn.Fail(msg: "数据接收失败")); } } }
/// <summary> /// 创建生成退款通知 /// </summary> /// <param name="reqModel"></param> /// <returns></returns> public override SxfPayReturn Build(SxfRefundNotifyRequest reqModel) { TradeOrder tradeOrder = null; var rfdTradeResult = new TradeResult(reqModel); //保存通知结果并更改TradeOrder状态 var success = PaySvc.SaveMchTradeResult(rfdTradeResult, out tradeOrder); if (!success) { return(SxfPayReturn.Fail(msg: "数据接收失败")); } else { var rfdNotify = new NotifyRefundRequest(tradeOrder, rfdTradeResult); var rfdNotifyDic = PaySignHelper.ToASCIIDictionary(rfdNotify); return(SendPost(PayConst.QCTTRADE_NOTIFY_REFUND, rfdNotifyDic, tradeOrder.CID, tradeOrder.RfdNotifyUrl)); } }