public static string SendAlipayRefundRequest(OrderInfo order, decimal refundMoney, string refundOrderId, bool isRefund = true) { string result = "backnotify"; PaymentModeInfo alipayRefundPaymentMode = TradeHelper.GetAlipayRefundPaymentMode(); if (alipayRefundPaymentMode == null) { result = "ERROR"; Globals.AppendLog("未找到可支持原路返回的支付宝支付方式", "", "", "AlipayRefundError"); return(result); } refundMoney = ((refundMoney == decimal.Zero) ? order.GetTotal(false) : refundMoney); string text = "hishop.plugins.refund.alipaydirect.directrequest"; string arg = text.Replace(".", "_"); string returnUrl = $"http://{HttpContext.Current.Request.Url.Host}/pay/RefundReturn?HIGW={arg}"; string notifyUrl = $"http://{HttpContext.Current.Request.Url.Host}/pay/RefundNotify?HIGW={arg}"; string[] orderId = new string[1] { order.GatewayOrderId }; decimal[] amount = new decimal[1] { order.GetTotal(false) }; decimal[] refundaAmount = new decimal[1] { refundMoney }; string[] body = new string[1] { order.RefundRemark }; string value = DateTime.Now.ToString("yyyyMMdd"); if (!refundOrderId.StartsWith(value)) { string oldRefundOrderId = refundOrderId; refundOrderId = Globals.GetGenerateId(); if (isRefund) { TradeHelper.UpdateRefundOrderId(oldRefundOrderId, refundOrderId, order.OrderId); } else { TradeHelper.UpdateRefundOrderId_Return(oldRefundOrderId, refundOrderId, order.OrderId); } } try { string text2 = HiCryptographer.Decrypt(alipayRefundPaymentMode.Settings); if (alipayRefundPaymentMode.Gateway.ToLower() == "hishop.plugins.payment.ws_wappay.wswappayrequest") { text2 = text2.Replace("Seller_account_name", "SellerEmail"); } RefundRequest refundRequest = RefundRequest.CreateInstance(text, text2, orderId, refundOrderId, amount, refundaAmount, body, order.EmailAddress, DateTime.Now, returnUrl, notifyUrl, "退款"); ResponseResult responseResult = refundRequest.SendRequest_Ret(); if (responseResult.Status == ResponseStatus.Success) { result = ""; } else { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("Gateway", order.Gateway); dictionary.Add("refundMoney", refundMoney.F2ToString("f2")); dictionary.Add("RefundGateWay", text); dictionary.Add("PaySettings", text2); dictionary.Add("NotifyUrl", $"http://{HttpContext.Current.Request.Url.Host}/pay/RefundNotify?HIGW={arg}"); dictionary.Add("settings", HiCryptographer.Decrypt(alipayRefundPaymentMode.Settings)); dictionary.Add("GatewayOrderId", order.GatewayOrderId); dictionary.Add("OrderTotal", order.GetTotal(false).F2ToString("f2")); dictionary.Add("OrderId", order.OrderId); dictionary.Add("out_refund_no", refundOrderId); Globals.AppendLog(dictionary, JsonHelper.GetJson(responseResult), "", "", "SendAlipayRefundRequest"); result = responseResult.Msg; } } catch (Exception ex) { if (!(ex is ThreadAbortException)) { IDictionary <string, string> dictionary2 = new Dictionary <string, string>(); dictionary2.Add("Gateway", order.Gateway); dictionary2.Add("refundMoney", refundMoney.F2ToString("f2")); dictionary2.Add("RefundGateWay", text); dictionary2.Add("NotifyUrl", $"http://{HttpContext.Current.Request.Url.Host}/pay/RefundNotify?HIGW={arg}"); dictionary2.Add("settings", HiCryptographer.Decrypt(alipayRefundPaymentMode.Settings)); dictionary2.Add("GatewayOrderId", order.GatewayOrderId); dictionary2.Add("OrderTotal", order.GetTotal(false).F2ToString("f2")); dictionary2.Add("OrderId", order.OrderId); dictionary2.Add("out_refund_no", refundOrderId); Globals.WriteExceptionLog(ex, dictionary2, "alipayBackReturn"); result = "ERROR"; } } return(result); }