public static PayNotificationReturnDTO ToPayNotificationReturnDTO(this PayNotification notification) { return(new PayNotificationReturnDTO { Id = notification.Id, PayerUsername = notification.Payer.Username, DebtDescription = notification.Debt.Description, isMoney = notification.Debt.IsMoney, Value = notification.Value, Currency = notification.Debt.Currency?.CurrencySymbol, Message = notification.Message, DebtName = notification.Debt.Name, RowVersion = notification.RowVersion, }); }
public static PaymentDTO ToPaymentDTO(this PayNotification notification, long id) { return(new PaymentDTO { CurrencyId = notification.Debt.Currency?.Id, Value = notification.Value, Date = notification.Created.Date, DebtName = notification.Debt.Name, IsOwnerPay = notification.Payer.Id == id, AvatarUrl = notification.Payer.Id == id ? notification.UserToPay.AratarUrl : notification.Payer.AratarUrl, Username = notification.Payer.Id == id ? notification.UserToPay.Username : notification.Payer.Username, }); }
public void TodoPayNotify(PayNotification notification) { Logger.Info(notification.SerializeToJson()); Guard.ArgumentNotNull(notification, "notification"); if (notification.ResultCode.Value.Equals("SUCCESS")) { var trade = this.weChatPayService.GetTradeByTradeId(notification.OutTradeNo.Value); Guard.ArgumentNotNull(trade, "trade"); if (trade.Money != notification.TotalFee) ////P1 TODO: need change to sign verify. { throw new WeChatPayException("There is a error happend on transaction to verify.(pay money)"); } //if ( (trade.TradeState & TradeStates.HavePay) != TradeStates.HavePay ) // throw new WeChatPayException("Only HavePay status pay order can be modify."); //if ( (trade.TradeState & TradeStates.AckPay) == TradeStates.AckPay ) { // throw new WeChatPayException("No need to confirm payment duplicated."); //} var pyarmid = (ISharedPyramid)null; string cardid = string.Empty; string usercode = string.Empty; if (trade.TradeType == TradeTypes.Recharge) { var attach = trade.Attach.DeserializeToObject <WxPayAttach>(); var mchid = sharingHostService.MerchantDetails.First(o => o.MCode.Equals(attach.MCode)).Id; pyarmid = this.GetSharedPyramid(new WxUserKey() { Id = trade.WxUserId, MerchantId = mchid }) ?? new SharedPyramid() { Id = trade.WxUserId, MchId = mchid }; cardid = attach.CardId; usercode = attach.UserCode; } else if (trade.TradeType == TradeTypes.Consume) { var context = trade.Attach.DeserializeToObject <OrderContext>(); pyarmid = this.GetSharedPyramid(new WxUserKey() { Id = context.Id, MerchantId = context.MerchantId }) ?? new SharedPyramid() { Id = context.Id, MchId = context.MerchantId }; var executeSqlString = @"[dbo].[spPaymentConfirmforConsume]"; using (var database = this.databaseFactory.GenerateDatabase(isWriteOnly: true)) { var parameters = new List <IDbDataParameter>() { new SqlParameter("@id", trade.Id), new SqlParameter("@mchid", trade.MerchantId), new SqlParameter("@wxUserId", trade.WxUserId), new SqlParameter("@rewardTo", (pyarmid?.Parent?.Id) ?? -1), new SqlParameter("@rewardMoney", (pyarmid?.Parent?.Id) == null?0:trade.RealMoney *configuration.GetRewardSettings().Limit), new SqlParameter("@rewardIntegral", trade.RealMoney / 10), new SqlParameter("@confirmTime", DateTime.UtcNow.ToUnixStampDateTime()), new SqlParameter("@state", (int)TradeStates.AckPay), new SqlParameter("@_rewardMoneyLimit", configuration.GetRewardSettings().Limit) }; database.Execute(executeSqlString, parameters.ToArray(), System.Data.CommandType.StoredProcedure); cmqclient.Push(new OnlineOrder[] { trade.Attach.DeserializeToObject <OrderContext>().Convert(trade.TradeId, trade.TradeCode, TradeStates.AckPay) }); } } } }