示例#1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        payEntity pe = new payEntity();

        pe.orderNo     = "201705110100000005";
        pe.aMount      = "500.00";
        pe.companyID   = "1";
        pe.description = "1司|2科|人1";
        string result = PayRender.GetPayUrl(pe);

        //result:返回结果

        payEntity.payResult pr = Newtonsoft.Json.JsonConvert.DeserializeObject <payEntity.payResult>(result);

        //{"data":{"url":"https://order.duolabao.cn/active/c?state=201705110000000005%7C10011014944661863281447%7C500.00%7C1%7CAPI"},"result":"success"}
        //{"error":{"errorCode":"tokenError","errorMsg":"5AE4281756E85161"},"result":"fail"}
        //自己解析
    }
示例#2
0
文件: PayRender.cs 项目: yaogdu/dlb
    /// <summary>
    /// TODO:1:构造参数
    /// </summary>
    /// <param name="orderNo"></param>
    /// <returns></returns>
    public static string GetPayUrl(payEntity pe)
    {
        TimeSpan ts = DateTime.Now.Subtract(DateTime.Parse("1970-01-01 00:00:00"));

        string timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
        //StringBuilder sb = new StringBuilder();
        StringBuilder jsonSb = new StringBuilder("{");//string.Format("appId={0}", model.appid)

        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "customerNum", PayConfig.customerNum);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "shopNum", PayConfig.shopNum);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "machineNum", PayConfig.machineNum);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "requestNum", pe.orderNo);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "amount", pe.aMount);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "source", "API");
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "tableNum", pe.companyID);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "callbackUrl", PayConfig.callbackUrl);
        jsonSb.AppendFormat("\"{0}\":\"{1}\",", "extraInfo", pe.description);

        string param  = jsonSb.ToString().TrimEnd(',') + "}";
        string param1 = string.Format("secretKey={0}&timestamp={1}&path={2}&body={3}"
                                      , PayConfig.secretKey, timestamp, "/v1/customer/order/payurl/create", param);

        string token = FormsAuthentication.HashPasswordForStoringInConfigFile(param1, "SHA1");


        //LogHelper.Log(string.Format("【代理商创建支付生成的param】{0}", param));

        //sb.AppendFormat("&key={0}", ConfigurationManager.AppSettings["WXPaySecret"]);
        string result = DoRequest.PostWebRequest(string.Format("{0}/v1/customer/order/payurl/create", PayConfig.url), token, param, timestamp);

        //LogHelper.Log(string.Format("【代理商创建支付生成的token】{0}", token));
        //LogHelper.Log(string.Format("【代理商创建支付链接】{0}", result));
        //var resultModel = jss.Deserialize<PayResponse>(result);
        //if (model != null)
        //{
        //    return model.errcode == "0";
        //}
        return(result);
    }