コード例 #1
0
ファイル: ZFNOTICE.aspx.cs プロジェクト: dmhai/dxpay
        /// <summary>
        /// 智付通知接口程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string jsonstr = "";
            int    pid     = 0;
            Dictionary <string, string> jsonlist = UrlStr.GetRequestfrom(HttpContext.Current, "智付通知接口");

            if (jsonlist != null)
            {
                jsonstr = JsonHelper.DictJsonstr(jsonlist);//把获取的参数转换成字符串
            }
            try
            {
                pid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? int.Parse(Request.QueryString["pid"]) : 0;
                var callbackVerify = new CallbackVerify();
                var form           = Request.Form.AllKeys.ToDictionary(key => key, key => Request.Form[key]);
                if (pid > 0 && jsonlist.Count > 0)
                {
                    //商户订单号
                    string out_trade_no = jsonlist["order_no"].Trim();
                    //智付交易号
                    string trade_no = jsonlist["trade_no"].Trim();
                    //交易状态
                    string trade_status = jsonlist["trade_status"].Trim();
                    //买家账号
                    string buyer_email = jsonlist["merchant_code"].Trim();
                    //买家付款时间
                    DateTime gmt_payment = Convert.ToDateTime(jsonlist["trade_time"].Trim());
                    //实际支付金额
                    decimal o_price = decimal.Parse(jsonlist["order_amount"].Trim());
                    if (callbackVerify.Verify(form) && jsonlist["trade_status"].Trim() == "SUCCESS")
                    {
                        JMALI.notice.notice notic = new notice.notice();
                        string message            = notic.PubNotice(out_trade_no, o_price, gmt_payment, trade_no, buyer_email, pid, "智付通知接口", jsonstr);
                        if (message == "ok")
                        {
                            Response.Write("SUCCESS");
                        }
                        else
                        {
                            Response.Write("FAILED");
                        }
                    }
                    else
                    {
                        Response.Write("FAILED");
                    }
                }
                else
                {
                    Response.Write("FAILED");
                }
            }
            catch (Exception ex)
            {
                PayApiDetailErrorLogger.UpstreamNotifyErrorLog("获取到的参数:" + jsonstr + ",错误信息:" + ex, summary: "智付通知接口错误", channelId: pid);
                Response.Write("FAILED");
            }
        }
コード例 #2
0
ファイル: index.aspx.cs プロジェクト: jansle/AntThirdLogin
 /// <summary>
 /// 链接
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     try
     {
         Response.Redirect(UrlStr.WXLoginUrl());
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
 // GET: Home
 public ActionResult Index()
 {
     try
     {
         ViewBag.QQLoginUrl = UrlStr.QQLoginUrl();
         return(View());
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #4
0
        /// <summary>
        /// 支付宝官方扫码H5通道
        /// </summary>
        /// <param name="apptype">应用类型子id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格(单位元)</param>
        /// <param name="orderid">订单id</param>
        /// <param name="ip">ip地址</param>
        /// <param name="infoTime">查询接口信息缓存时间</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse IAliPaySmH5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes)
        {
            InnerResponse inn = new InnerResponse();

            SelectInterface SeIn = new SelectInterface();

            try
            {
                string ZfbSmH5jkhc = "ZfbSmH5jkhc" + appid;//组装缓存key值
                SeIn = SelectUserInfo(ZfbSmH5jkhc, apptype, appid, infoTimes);
                if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }

                if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId))
                {
                    inn = inn.ToResponse(ErrorCode.Code101);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun))
                {
                    inn = inn.ToResponse(ErrorCode.Code8990);
                    return(inn);
                }
                if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum))
                {
                    inn = inn.ToResponse(ErrorCode.Code8989);
                    return(inn);
                }

                //公共请求参数
                Dictionary <string, string> List = new Dictionary <string, string>();
                List.Add("app_id", SeIn.UserId);                                                                                       //支付宝应用ID
                List.Add("method", "alipay.trade.precreate");                                                                          //接口名称(请求类型)
                List.Add("charset", "utf-8");                                                                                          //请求使用的编码格式
                List.Add("sign_type", "RSA");                                                                                          //商户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用RSA2
                List.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));                                                   //发送请求的时间
                List.Add("version", "1.0");                                                                                            //调用的接口版本
                List.Add("notify_url", ConfigurationManager.AppSettings["TokenUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //异步通知地址。
                //请求参数
                Dictionary <string, string> Orlist = new Dictionary <string, string>();
                Orlist.Add("out_trade_no", code);             //商户订单号
                Orlist.Add("total_amount", price.ToString()); //订单总金额,单位为元,精确到小数点后两位,
                Orlist.Add("subject", goodsname);             //订单标题
                Orlist.Add("body", goodsname);                //对交易或商品的描述
                string overtime = (int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()) / 60) + "m";
                Orlist.Add("timeout_express", overtime);      //该笔订单允许的最晚付款时间,逾期将关闭交易。

                string biz_content = JsonHelper.DictJsonstr(Orlist);
                List.Add("biz_content", biz_content);

                string SignStr = UrlStr.AzGetStr(List);
                //签名
                string Sign = RSAFromPkcs8.sign(SignStr, SeIn.UserKey, "utf-8");
                //签名 注释:get请求时必须采用url编码方式(HttpUtility.UrlEncode)
                List.Add("sign", HttpUtility.UrlEncode(Sign));
                //请求地址
                string url    = ConfigurationManager.AppSettings["AliPaySmUrl"].ToString();
                string Urlstr = url + UrlStr.AzGetStr(List);

                HttpWebRequest  request        = (HttpWebRequest)HttpWebRequest.Create(Urlstr); //创建一个请求示例
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse();        //获取响应,即发送请求
                Stream          responseStream = response.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream, Encoding.UTF8);
                string          srcString      = streamReader.ReadToEnd();

                Root root = new Root();
                //对返回参数转换格式
                root = JsonHelper.Deserializes <Root>(srcString);

                if (root != null && root.alipay_trade_precreate_response.code == "10000" && root.alipay_trade_precreate_response.msg == "Success")
                {
                    string qurl      = root.alipay_trade_precreate_response.qr_code + "," + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",1"; //组装二维码地址
                    string ImgQRcode = ConfigurationManager.AppSettings["ImgQRcode"].ToString() + "?QRcode=" + Encrypt.IndexEncrypt(qurl);       //二维码图片展示地址
                    string codeurl   = ConfigurationManager.AppSettings["QRcode"].ToString() + "?QRcode=" + Encrypt.IndexEncrypt(qurl);          //二维码展示地址
                    inn           = inn.ToResponse(ErrorCode.Code100);
                    inn.ExtraData = new { ImgQRcode = ImgQRcode, codeurl = codeurl };                                                            //http提交方式;
                }
                else
                {
                    string error = "支付宝官方扫码支付错误代码:" + srcString + ",商户号:" + SeIn.UserId;
                    PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + error, summary: "支付宝官方扫码支付接口错误信息", channelId: SeIn.PayId);
                    inn = inn.ToResponse(ErrorCode.Code104);
                }
            }
            catch (Exception ex)
            {
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.ToString(), summary: "支付官方宝扫码接口错误信息", channelId: SeIn.PayId);
                inn = inn.ToResponse(ErrorCode.Code104);
            }

            return(inn);
        }