Example #1
0
 public static Charge MapCharge(ChargeDto charge)
 {
     return(new Charge()
     {
         Amount = charge.Amount,
         IdEvent = charge.IdEvent
     });
 }
Example #2
0
        public Task <bool> RequestPaymentAsync(int amount, string sourceId, string currency, string description)
        {
            var dto = new ChargeDto
            {
                Amount       = amount,
                CardSourceId = sourceId,
                Currency     = currency,
                Description  = description
            };
            var request = new PostCreateChargeRequest(_jsonSerializer, dto, _stripeConfig);

            return(_restHttpClient.TrySendAsync(request, _logger));
        }
Example #3
0
        public ActionResult Create(ChargeDto chargeDto)
        {
            try
            {
                var charge = ChargeModel.MapCharge(chargeDto);
                var ep     = new ChargeProcess();
                var lista  = ep.Add(chargeDto.IdUser, charge);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #4
0
        /// <summary>
        /// 调用ue支付
        /// </summary>
        /// <param name="regInfo"></param>
        /// <param name="Price"></param>
        /// <returns></returns>
        private bool ChargeVDian_DosUEPrepare(TnetReginfo regInfo, decimal Price)
        {
            TpcnUepayconfig ueConfig = db.TpcnUepayconfigSet.FirstOrDefault(a => a.Typeid == 2);

            if (ueConfig == null || ueConfig.Id <= 0)
            {
                Alert("获取UE支付配置失败");
                return(false);
            }
            //获取配置DOS兑换V点比例
            TappConfig config     = db.TappConfigSet.FirstOrDefault(a => a.Propertyname == "chargerate");
            decimal    chargerate = config == null ? 0.01M : decimal.Parse(config.Propertyvalue);
            decimal    amount     = decimal.Parse(Price.ToString()) * chargerate;

            if (amount < 0.01M)
            {
                amount = 0.01M;
            }
            Currency     currency = new Currency(CurrencyType.DOS_矿沙, amount);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis {
                Typeid = 20001, Nodeid = regInfo.Nodeid, BusinessParams = Price.ToString(), Amount = total, Unit = unit, Freezeids = "", Createtime = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            if (db.SaveChanges() <= 0)
            {
                Alert("生成UE订单失败");
                return(false);
            }
            ChargeUE = new ChargeDto
            {
                businesstypeid = 20001,
                amount         = total,
                unit           = unit,
                body           = "充值V点",
                subject        = "充值V点",
                orderno        = uePayHis.Id.ToString(),
                paycode        = ueConfig.Paycode,
                noticeurl      = Helper.DomainUrl + "/UENotice/Success",
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss")
            };
            return(true);
        }
Example #5
0
        /// <summary>
        /// 调用ue支付
        /// </summary>
        public bool OctoberActivityDosUEPrepare(OctoberActivityDosUEPrepareReq req)
        {
            log.Info($"十月送手机活动支付服务费,nodeid={req.Nodeid},服务费={req.Price}");
            var activity = db.TpxinActivitySet.FirstOrDefault(p => p.Id == req.ActivityId);

            if (activity == null)
            {
                Alert("找不到活动信息,请重试");
                return(false);
            }
            DateTime now = DateTime.Now;

            if (AppConfig.IsUseSms && !(now >= activity.PayStarttime && now <= activity.PayEndtime))
            {
                Alert("缴费时间已过期");
                return(false);
            }
            string[] ids = req.DataId.Split('_');
            if (req.PayType == 2)
            {
                if (ids.Length != 1)
                {
                    Alert("只能支付一个");
                    return(false);
                }
                var cnt = db.TpxinOctoberActivitySet.Count(x => x.Nodeid == req.Nodeid && x.Transferids != null && x.ActivityId == req.ActivityId);
                if (cnt > 0)
                {
                    Alert("已经存在缴过费的记录,只能支付一个");
                    return(false);
                }
            }
            foreach (string sid in ids)
            {
                int tid    = Convert.ToInt32(sid);
                var entity = db.TpxinOctoberActivitySet.FirstOrDefault(x => x.Id == tid);
                if (req.PayType == 1)
                {
                    if (!string.IsNullOrEmpty(entity.Ptransferids))
                    {
                        Alert("不能选中已缴费的记录,请重新打开当前页面");
                        return(false);
                    }
                }
                if (req.PayType == 2)
                {
                    if (!string.IsNullOrEmpty(entity.Transferids))
                    {
                        Alert("不能选中已缴费的记录,请重新打开当前页面");
                        return(false);
                    }
                }
            }

            TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid);

            TpcnUepayconfig ueConfig = db.TpcnUepayconfigSet.FirstOrDefault(a => a.Typeid == 1);

            if (ueConfig == null || ueConfig.Id <= 0)
            {
                Alert("获取UE支付配置失败");
                return(false);
            }
            Currency     currency = new Currency(CurrencyType.DOS_矿沙, req.Price);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis
            {
                Typeid         = 20008,
                Nodeid         = regInfo.Nodeid,
                BusinessParams = 10 + "|" + req.DataId + "|" + req.PayType + "|" + req.Nodeid + "|" + req.Price.ToString(),
                Amount         = total,
                Unit           = unit,
                Freezeids      = "",
                Createtime     = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            if (db.SaveChanges() <= 0)
            {
                Alert("生成UE订单失败");
                return(false);
            }
            var charge = new ChargeDto
            {
                businesstypeid = 20008,
                amount         = total,
                unit           = unit,
                body           = "十月送手机活动支付服务费",
                subject        = "十月送手机活动支付服务费",
                orderno        = uePayHis.Id.ToString(),
                paycode        = ueConfig.Paycode,
                noticeurl      = Helper.DomainUrl + "/UENotice/Success",
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss")
            };

            UEPayCallDto         = new UePayCallDto();
            UEPayCallDto.Charge  = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(charge)));
            UEPayCallDto.sign    = Md5.SignString(UEPayCallDto.Charge + AppConfig.AppSecurityString);
            UEPayCallDto.orderno = uePayHis.Id.ToString();
            return(true);
        }
Example #6
0
        /// <summary>
        /// ue支付(调用ue客户端时使用)
        /// </summary>
        /// <param name="db">数据库上下文</param>
        /// <param name="userInfo">支付用户</param>
        /// <param name="uePayConfigTypeId">业务类型</param>
        /// <param name="currencyType">货币类型</param>
        /// <param name="amount">支付金额</param>
        /// <param name="uePayHisTypeId">业务类型</param>
        /// <param name="businessParams">业务相关参数</param>
        /// <param name="body">商品描述</param>
        /// <param name="subject">商品名称</param>
        /// <param name="freezeids">冻结ID列</param>
        /// <param name="pNodeId">父NodeId(eg:经销商支付时就需要要获取它的上级专营商的NodeId)</param>
        /// <returns></returns>
        public static async Task <DosWithUePayDto> DosWithUePay(
            PXinContext db, TnetReginfo userInfo,
            int uePayConfigTypeId, CurrencyType currencyType, decimal amount, int uePayHisTypeId, string businessParams,
            string body, string subject,
            string freezeids = "", int pNodeId = 0)
        {
            var ueConfig = await db.TpcnUepayconfigSet.FirstOrDefaultAsync(p => p.Typeid == uePayConfigTypeId);

            if (ueConfig == null)
            {
                log.Info("获取UE支付配置失败");
                return(new DosWithUePayDto()
                {
                    IsSuccess = false, Message = "获取UE支付配置失败"
                });
            }
            Currency     currency = new Currency(currencyType, amount);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis {
                Typeid = uePayHisTypeId, Nodeid = userInfo.Nodeid, BusinessParams = businessParams, Amount = total, Unit = unit, Freezeids = freezeids, Createtime = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            var falg = await db.SaveChangesAsync() > 0;

            if (!falg)
            {
                log.Info("生成UE订单失败,NodeId=:" + uePayHis.Nodeid);
                return(new DosWithUePayDto()
                {
                    IsSuccess = false, Message = "生成UE订单失败"
                });
            }
            var recvNodeCode = "";

            if (pNodeId > 0)//代理人支付时,获取充值商帐号(收钱帐号),向它支付
            {
                var parentUserInfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    RegInfoKey = pNodeId.ToString()
                });
                if (parentUserInfo == null)
                {
                    log.Info("获取上级用户信息失败,NodeId=:" + uePayHis.Nodeid);
                    return(new DosWithUePayDto()
                    {
                        IsSuccess = false, Message = "获取上级用户信息失败"
                    });
                }
                recvNodeCode = parentUserInfo.Nodecode;
            }
            var chargeDto = new ChargeDto
            {
                businesstypeid = uePayHisTypeId,
                amount         = total,
                unit           = unit,
                body           = body,
                subject        = subject,
                orderno        = uePayHis.Id.ToString(),
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss"),
                paycode        = ueConfig.Paycode,
                recvfromid     = pNodeId > 0 ? 6 : 0,
                recvaccount    = recvNodeCode,
                noticeurl      = Common.Facade.Helper.DomainUrl + "/UENotice/Success"
            };
            var chargeStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(chargeDto)));

            return(new DosWithUePayDto()
            {
                IsSuccess = true, ChargeStr = chargeStr, OrderNo = chargeDto.orderno
            });
        }