Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PayConfig payConfig = new PayConfig();

            merchant_id.Value = payConfig.MerchantID;           ///商户编号
            string merchant_key = payConfig.MerchantKey;        ///商户密钥
            string action       = RequestHelper.GetQueryString <string>("Action");
            int    userID       = Cookies.User.GetUserID(true);

            switch (action)
            {
            case "Apply":
                int applyID = RequestHelper.GetQueryString <int>("ApplyID");
                UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRecharge(applyID, userID);
                orderid.Value        = userRecharge.Number;           ///订单编号
                amount.Value         = userRecharge.Money.ToString(); ///订单金额
                commodity_info.Value = "网上冲值:" + userRecharge.Number; ///商品信息,如果含中文请通过System.Web.HttpUtility.UrlEncode()编码
                break;

            case "PayOrder":
                int       orderID = RequestHelper.GetQueryString <int>("OrderID");
                OrderInfo order   = OrderBLL.ReadOrder(orderID, userID);
                orderid.Value        = order.OrderNumber;                                                                                                                   ///订单编号
                amount.Value         = (order.ProductMoney - order.FavorableMoney + order.ShippingMoney + order.OtherMoney - order.Balance - order.CouponMoney).ToString(); ///订单金额
                commodity_info.Value = "在线支付:" + order.OrderNumber;                                                                                                         ///商品信息,如果含中文请通过System.Web.HttpUtility.UrlEncode()编码
                break;

            default:
                break;
            }
            currency.Value       = "1";                                                                                   ///货币类型,1为人民币
            isSupportDES.Value   = "2";                                                                                   ///是否安全校验,2为必校验,推荐
            merchant_url.Value   = "http://" + Request.ServerVariables["Http_Host"] + "/Plugins/Pay/BillPay/Return.aspx"; ///支付结果返回地址
            pname.Value          = "";                                                                                    ///支付人姓名,如果含中文请通过System.Web.HttpUtility.UrlEncode()编码
            merchant_param.Value = "";                                                                                    ///商户私有参数
            pemail.Value         = "";                                                                                    ///传递email到快钱网关页面
            pid.Value            = "";                                                                                    ///代理/合作伙伴商户编号

            ///生成加密串,注意顺序
            String ScrtStr = "merchant_id=" + merchant_id.Value + "&orderid=" + orderid.Value + "&amount=" + amount.Value + "&merchant_url=" + merchant_url.Value + "&merchant_key=" + merchant_key;

            mac.Value = FormsAuthentication.HashPasswordForStoringInConfigFile(ScrtStr, "MD5");
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PayConfig payConfig      = new PayConfig();
            string    merchant_key   = payConfig.MerchantKey;                ///商户密钥
            string    merchant_id    = Request["merchant_id"].ToString();    ///获取商户编号
            string    orderid        = Request["orderid"].ToString();        ///获取订单编号
            string    amount         = Request["amount"].ToString();         ///获取订单金额
            string    dealdate       = Request["date"].ToString();           ///获取交易日期
            string    succeed        = Request["succeed"].ToString();        ///获取交易结果,Y成功,N失败
            string    mac            = Request["mac"].ToString();            ///获取安全加密串
            string    merchant_param = Request["merchant_param"].ToString(); ///获取商户私有参数

            string couponid    = Request["couponid"].ToString();             ///获取优惠券编码
            string couponvalue = Request["couponvalue"].ToString();          ///获取优惠券面额

            ///生成加密串,注意顺序
            string SrctStr = "merchant_id=" + merchant_id + "&orderid=" + orderid + "&amount=" + amount + "&date=" + dealdate + "&succeed=" + succeed + "&merchant_key=" + merchant_key;
            string mymac   = FormsAuthentication.HashPasswordForStoringInConfigFile(SrctStr, "MD5");


            if (mac == mymac)
            {
                if (succeed == "Y")
                {
                    //更新数据库的订单语句
                    message = "成功付款";
                    string    orderNumber = orderid;
                    OrderInfo order       = OrderBLL.ReadOrderByNumber(orderNumber, 0);
                    if (order.ID > 0)
                    {
                        if (order.OrderStatus == (int)OrderStatus.WaitPay)
                        {
                            order.OrderStatus = (int)OrderStatus.WaitCheck;
                            OrderBLL.UpdateOrder(order);
                            //增加操作记录
                            OrderActionInfo orderAction = new OrderActionInfo();
                            orderAction.OrderID          = order.ID;
                            orderAction.OrderOperate     = (int)OrderOperate.Pay;
                            orderAction.StartOrderStatus = (int)OrderStatus.WaitPay;
                            orderAction.EndOrderStatus   = (int)OrderStatus.WaitCheck;
                            orderAction.Note             = "客户快钱在线支付";
                            orderAction.IP        = ClientHelper.IP;
                            orderAction.Date      = RequestHelper.DateNow;
                            orderAction.AdminID   = 0;
                            orderAction.AdminName = string.Empty;
                            OrderActionBLL.AddOrderAction(orderAction);

                            message = "您已经成功支付订单:" + orderNumber;
                        }
                    }
                    else
                    {
                        UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRechargeByNumber(orderNumber, 0);
                        if (userRecharge.ID > 0 && userRecharge.IsFinish == (int)BoolType.False)
                        {
                            userRecharge.IsFinish = (int)BoolType.True;
                            UserRechargeBLL.UpdateUserRecharge(userRecharge);
                            //账户记录
                            string note = "快钱在线冲值:" + userRecharge.Number;
                            UserAccountRecordBLL.AddUserAccountRecord(userRecharge.Money, 0, note, userRecharge.UserID, userRecharge.UserName);

                            message = "您的冲值已经成功完成";
                        }
                    }
                }
                else
                {
                    message = "支付订单失败";
                }
            }
            else
            {
                message = "签名错误";
            }
        }