微信支付结果回调不通,不知道为啥,有经验的帮我瞅瞅
问题遇到的现象和发生背景以前微信支付结果通知是用aspx接收的,现在要改为webapi接收,现在测试下来,接收不到,我想问一下,代码是不是有啥问题的public dynamic ReceiveFromWctPayResult()
{
try
{
string strXML = string.Empty;
using (StreamReader sr = new StreamReader(Request.Body, Encoding.UTF8))
{
strXML = sr.ReadToEndAsync().Result;
}
STM_Applet applet = uow.Query<STM_Applet>().FirstOrDefault();
if (applet != null)
{
WctPayEntity receiveWctPayEntity = new WctPayEntity();
if (!string.IsNullOrEmpty(strXML) && receiveWctPayEntity.FromXml(strXML, true, applet.ApiKey) && receiveWctPayEntity.GetValue("return_code").ToString() == "SUCCESS")
{
WctAttachEntity wctAttachEntity = JsonHelper.Deserialize<WctAttachEntity>(distributedCache.GetString(receiveWctPayEntity.GetValue("attach").ToString()));
if (wctAttachEntity != null)
{
Order currentOrder = uow.Query<Order>().Where(x => x.OrderNo == receiveWctPayEntity.GetValue("out_trade_no").ToString()).FirstOrDefault();
#region 更新订单状态
currentOrder.OrderStatus = currentOrder.OrderGoodsType == Order.OrderGoodsTypeEnum.商品 ? OrderStatus.待发货 : OrderStatus.待预约;
#endregion 更新订单状态
#region 更新支付流水
List<Order_Payment> currentOrderPayments = uow.Query<Order_Payment>().Where(x => x.OrderPayNo == currentOrder.OrderNo).ToList();
for (int i = 0; i < currentOrderPayments.Count; i++)
{
currentOrderPayments.ConfirmStatus = Order_Payment.ConfirmStatusEnum.已确认;
currentOrderPayments.ConfirmTime = DateTime.Now;
currentOrderPayments.PayStatus = Order_Payment.PayStatusEnum.已支付;
currentOrderPayments.ModifyTime = DateTime.Now;
currentOrderPayments.PayTime = Convert.ToDateTime(receiveWctPayEntity.GetValue("time_end").ToString());
if (currentOrderPayments.PayType == Order_Payment.PayTypeEnum.微信)
{
currentOrderPayments.PayMentTradeNo = receiveWctPayEntity.GetValue("transaction_id").ToString();
}
else
{
#region 卡冻结操作记录(冻结)
BMS_PrepaidCard_Public currentPrepaidCardPublic = uow.FindObject<BMS_PrepaidCard_Public>(CriteriaOperator.Parse("CardCode='" + currentOrderPayments.PayMentTradeNo + "'"));
if (currentPrepaidCardPublic != null)
{
currentPrepaidCardPublic.FreezeMoney += currentOrderPayments.PayMoney;
BMS_PrepaidCard_Frozen currentPrepaidCardFrozen = new BMS_PrepaidCard_Frozen(uow);
currentPrepaidCardFrozen.BeforeMoney = currentPrepaidCardPublic.CardMoney;
currentPrepaidCardFrozen.CardCode = currentPrepaidCardPublic.CardCode;
currentPrepaidCardFrozen.ChipCode = currentPrepaidCardPublic.ChipCode;
currentPrepaidCardFrozen.CurrentMoney = 0;
currentPrepaidCardFrozen.FrozenMoney = currentOrderPayments.PayMoney;
currentPrepaidCardFrozen.FrozenStatus = 0;
currentPrepaidCardFrozen.FrozenSource = "1";
currentPrepaidCardFrozen.OperateType = 1;
currentPrepaidCardFrozen.OrderID = currentOrder.Oid.ToString();
currentPrepaidCardFrozen.PublicID = currentPrepaidCardPublic.Oid.ToString();
currentPrepaidCardFrozen.Remark = "平台冻结金额";
}
#endregion 卡冻结操作记录(冻结)
}
}
#endregion 更新支付流水
#region 创建订单明细
if (currentOrder.OrderGoodsType != Order.OrderGoodsTypeEnum.商品)
{
for (int i = 0; i < currentOrder.Details.Count; i++)
{
for (int j = 0; j < currentOrder.Details.BuyCount; j++)
{
Order_Credentials currentCredentials = new Order_Credentials(uow);
currentCredentials.CredentialNo = "不知道咋生成的";
currentCredentials.CredentialsType = string.IsNullOrEmpty(currentOrder.Details.UnionCode) ? 1 : 0;
currentCredentials.CardExpiredDate = DateTime.Now.AddMonths(3);
currentCredentials.OrderId = currentOrder.Oid;
currentCredentials.OrderNo = currentOrder.OrderNo;
currentCredentials.OrderPackageID = currentOrder.Details.OrderPackageId;
currentCredentials.PackageTitle = currentOrder.OrderGoodsType == Order.OrderGoodsTypeEnum.套餐 ? currentOrder.Details.Title : currentOrder.Details.Title + "自定义";
currentCredentials.Price = currentOrder.Details.Price;
currentCredentials.Status = Order_Credentials.StatusEnum.待预约;
currentCredentials.UnionCode = currentOrder.Details.UnionCode;
currentCredentials.UnionID = currentOrder.Details.UnionId;
currentCredentials.UnionName = currentOrder.Details.UnionName;
currentCredentials.UserID = currentOrder.UserID.Oid;
currentCredentials.CreateTime = DateTime.Now;
currentCredentials.CreateTrueName = "平台";
currentCredentials.ModifyTime = DateTime.Now;
currentCredentials.ModifyTrueName = "平台";
}
}
}
#endregion 创建订单明细
uow.CommitChanges();
}
WctPayEntity responseWctPayEntity = new WctPayEntity();
responseWctPayEntity.SetValue("return_code", "!]");
responseWctPayEntity.SetValue("return_msg", "!] ");
return responseWctPayEntity.ToXml();
}
}
}
catch (Exception)
{
}
return null;
}
先单个调试自己的接口,如果没有问题,那可能是自己接口调用微信接口的之间有问题 这个需要具体的测试环境进行测试 超时?还是没反应
页:
[1]