Example #1
0
        internal string GetPrepay_id(PayDictionary dict, string sign)
        {
            dict.Add("sign", sign);
            string value = SignHelper.BuildQuery(dict, false);
            string text  = SignHelper.BuildXml(dict, false);
            string text2 = "";

            text2 = PayClient.PostData(PayClient.prepay_id_Url, text);
            try
            {
                DataTable dataTable = new DataTable();
                dataTable.TableName = "log";
                dataTable.Columns.Add(new DataColumn("OperTime"));
                dataTable.Columns.Add(new DataColumn("Info"));
                dataTable.Columns.Add(new DataColumn("param"));
                dataTable.Columns.Add(new DataColumn("query"));
                DataRow dataRow = dataTable.NewRow();
                dataRow["OperTime"] = DateTime.Now.ToString();
                dataRow["Info"]     = text2;
                dataRow["param"]    = text;
                dataRow["query"]    = value;
                dataTable.Rows.Add(dataRow);
                dataTable.WriteXml(HttpContext.Current.Request.MapPath("/PrepayID.xml"));
            }
            catch (Exception ex)
            {
                PayClient.writeLog(dict, sign, "", ex.Message + "-PrepayId获取错误");
            }
            return(text2);
        }
Example #2
0
        internal string BuildPackage(PackageInfo package)
        {
            PayDictionary payDictionary = new PayDictionary();

            payDictionary.Add("appid", this._payAccount.AppId);
            payDictionary.Add("mch_id", this._payAccount.PartnerId);
            if (this._payAccount.EnableSP)
            {
                payDictionary.Add("sub_appid", this._payAccount.Sub_appid);
                payDictionary.Add("sub_mch_id", this._payAccount.Sub_mch_id);
                payDictionary.Add("sub_openid", package.OpenId);
            }
            else
            {
                payDictionary.Add("openid", package.OpenId);
            }
            payDictionary.Add("device_info", "");
            payDictionary.Add("nonce_str", Utils.CreateNoncestr());
            payDictionary.Add("body", package.Body);
            payDictionary.Add("attach", "");
            payDictionary.Add("out_trade_no", package.OutTradeNo);
            payDictionary.Add("total_fee", (int)package.TotalFee);
            payDictionary.Add("spbill_create_ip", package.SpbillCreateIp);
            payDictionary.Add("time_start", package.TimeExpire);
            payDictionary.Add("time_expire", "");
            payDictionary.Add("goods_tag", package.GoodsTag);
            payDictionary.Add("notify_url", package.NotifyUrl);
            payDictionary.Add("trade_type", "JSAPI");
            payDictionary.Add("product_id", "");
            string sign = SignHelper.SignPackage(payDictionary, this._payAccount.PartnerKey);

            PayClient.writeLog(payDictionary, sign, "", "");
            string text = this.GetPrepay_id(payDictionary, sign);

            if (text.Length > 64)
            {
                text = "";
            }
            return(string.Format("prepay_id=" + text, new object[0]));
        }