Exemplo n.º 1
0
        public PayResult Pay(PayInfo info)
        {
            var url = "http://pay.dkg88.com/api/pay";

            Dictionary <string, string> nvc = new Dictionary <string, string>();

            nvc["account"] = this.appid;
            nvc["order"]   = info.OrderNo;
            nvc["paytype"] = "wxwap"; //微信WAP
            //nvc["type"] = "";
            nvc["money"] = ((decimal)(info.Amount) * 0.01m).ToString();
            //nvc["body"] = "";
            nvc["ext"]      = Base64Helper.Base64Encode(info.Attach);
            nvc["notify"]   = this.notifyUrl;
            nvc["callback"] = info.ReturnUrl;

            nvc["ip"] = info.IP;

            nvc["sign"] = getSign(nvc);


            string ps = CreateParams(nvc);


            var resultString = PostWebRequest(url, ps, Encoding.GetEncoding("utf-8"));
            var result       = new PayResult();

            result.Status = ResultStatus.Fail;

            if (!string.IsNullOrEmpty(resultString))
            {
                dynamic obj = JsonConvert.DeserializeObject <dynamic>(resultString);
                if (obj != null)
                {
                    int code = obj.code;
                    if (code == 1)
                    {
                        string payurl = obj.payurl;
                        result.ResultType = PayResultType.Url;
                        result.ResultData = payurl;
                        result.Status     = ResultStatus.Succ;
                    }
                }
            }


            return(result);
        }