public async Task <IActionResult> PublicPayAsync() { //Resolve<IPayService>().Log("微信公众号支付,后台回调", LogsLevel.Warning); try { var config = Ioc.Resolve <IAutoConfigService>().GetValue <WeChatPaymentConfig>(); var _client = new WeChatPayNotifyClient(config.APISecretKey); var notify = await _client.ExecuteAsync <WeChatPayUnifiedOrderNotifyResponse>(Request); //Resolve<IPayService>().Log("微信公众号支付回调参数:" + notify.ToJson(), LogsLevel.Warning); if (notify.ReturnCode == "SUCCESS") { var payId = notify.Attach.ConvertToLong(0); // 通过支付宝获取订单Id参数 var pay = Resolve <IPayService>().GetSingle(payId); if (pay != null) { pay.ResponseTime = DateTime.Now; pay.Message = notify.ToJson(); pay.ResponseSerial = notify.Attach; pay.PayType = PayType.WeChatPayPublic; var res = Resolve <IPayService>().AfterPay(pay, true); Resolve <IBookingSignupService>().AfterPaySuccess(new List <object> { pay.PayExtension.TradeNo }); //Resolve<IPayService>().Log("微信公众号支付回调结果:" + res.ToJson(), LogsLevel.Warning); } if (notify.ResultCode == "SUCCESS") { return(Content("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>", "text/xml")); } } return(NoContent()); } catch (Exception ex) { Resolve <IPayService>().Log("微信公众号支付异常" + ex.Message, LogsLevel.Error); return(NoContent()); } }
public WeChatPayRefundNotifyController(WeChatPayNotifyClient client) { _client = client; }