예제 #1
0
        public override Task <UnifiedorderReturn> Unifiedorder(string OrderId, string Paytype, decimal Totalfee, string Ip, string Body, string Attach)
        {
            UnifiedorderReturn           unifiedorderReturn = new UnifiedorderReturn();
            IDictionary <string, string> dic = new Dictionary <string, string>();
            string channel = "1000";

            switch (Paytype)
            {
            case "1":    //B2C網銀
                channel = "5000";
                break;

            case "2":    //支付宝H5
                channel = "1000";
                break;

            case "3":    //微信H5
                channel = "2000";
                break;

            default:
                channel = "1000";
                break;
            }
            dic.Add("P_UserId", this.MchID);
            dic.Add("P_OrderId", OrderId);
            dic.Add("P_CardId", "");
            dic.Add("P_CardPass", "");
            dic.Add("P_FaceValue", Totalfee.ToString("F2"));
            dic.Add("P_ChannelId", channel);

            string signstr = PayHelper.GetParamSrc2(dic, "|");
            string sign    = PayHelper.MD5Hash1(signstr + this.MchKey).ToLower();

            dic.Add("P_PostKey", sign);
            dic.Add("P_Subject", "");
            dic.Add("P_Price", "0");
            dic.Add("P_Quantity", "0");
            dic.Add("P_Description", "");
            dic.Add("P_Notic", "");
            dic.Add("P_Result_URL", this.CallbackUrl);
            dic.Add("P_Notify_URL", this.NotifyUrl);
            dic.Add("ResultType", "1");
            string  response = HttpHelper.Post(this.Plat.Pay_gateway, PayHelper.GetParamSrc(dic));
            dynamic jo       = JsonConvert.DeserializeObject(response);
            string  resCode  = jo["Result_code"];

            if (resCode == "0")
            {
                string url = jo["PayUrl"];
                unifiedorderReturn.Type         = PayReturnType.Url;
                unifiedorderReturn.Content      = url;
                unifiedorderReturn.OrderNumber  = OrderId;
                unifiedorderReturn.SerialNumber = OrderId;
                unifiedorderReturn.RealPrice    = Totalfee.ToString("F2");
            }
            else
            {
                unifiedorderReturn.Type         = PayReturnType.Err;
                unifiedorderReturn.Content      = "第三方下单失败";
                unifiedorderReturn.OrderNumber  = OrderId;
                unifiedorderReturn.SerialNumber = OrderId;
                unifiedorderReturn.RealPrice    = Totalfee.ToString("F2");
            }
            //return new Task<UnifiedorderReturn>(() => unifiedorderReturn);
            return(Task.FromResult <UnifiedorderReturn>(unifiedorderReturn));
        }