Exemple #1
0
        public static HttpResponseMessage WxPayNotify()
        {
            var request    = Context.AuthenticatedRequest;
            var repository = new RecordRepository();

            var siteId  = request.GetQueryInt("siteId");
            var orderNo = request.GetQueryString("orderNo");

            var paymentApi = new PaymentApi(siteId);

            paymentApi.NotifyByWxPay(HttpContext.Current.Request, out var isPayed, out var responseXml);
            //var filePath = Path.Combine(Main.PhysicalApplicationPath, "log.txt");
            //File.WriteAllText(filePath, responseXml);
            if (isPayed)
            {
                repository.UpdateIsPayed(orderNo);
            }

            var response = new HttpResponseMessage {
                Content = new StringContent(responseXml)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");
            response.StatusCode = HttpStatusCode.OK;

            return(response);
        }