Esempio n. 1
0
        /// <summary>
        /// 创建PC支付链接串(航旅版)
        /// </summary>
        /// <param name="directInfo">支付信息</param>
        /// <param name="config">config</param>
        /// <returns>请求连接</returns>
        public static string CreateDirectGetPcPayByUser(DirectInfo directInfo, Config config)
        {
            var    partner   = config.GetPid();
            Submit submit    = new Submit(config);
            var    sParaTemp = new SortedDictionary <string, string>
            {
                { "service", "create_direct_pay_by_user" },
                { "partner", partner },
                { "_input_charset", Config.InputCharset.ToLower() },
                { "payment_type", "1" },
                { "notify_url", directInfo.Notify },
                { "return_url", directInfo.Return },
                { "out_trade_no", directInfo.OutTradeNo },
                { "subject", directInfo.Subject },
                { "total_fee", directInfo.TotalFee.ToString("0.00") },
                { "show_url", directInfo.ShowUrl },
                { "seller_email", Config.SellerEmail },
            };
            string responseResult = submit.BuildRequest(sParaTemp);

            return(responseResult);
        }
Esempio n. 2
0
        /// <summary>
        /// 创建Wap支付链接串(航旅版)
        /// </summary>
        /// <param name="directInfo">支付信息</param>
        /// <param name="config">config</param>
        /// <returns>请求连接</returns>
        public static string CreateDirectWapPayByUser(DirectInfo directInfo, Config config)
        {
            var    partner   = config.GetPid();
            Submit submit    = new Submit(config);
            var    sParaTemp = new SortedDictionary <string, string>
            {
                { "partner", partner },
                { "seller_id", partner },
                { "_input_charset", Config.InputCharset.ToLower() },
                { "service", "alipay.wap.create.direct.pay.by.user" },
                { "payment_type", "1" },
                { "notify_url", directInfo.Notify },
                { "return_url", directInfo.Return },
                { "out_trade_no", directInfo.OutTradeNo },
                { "subject", directInfo.Subject },
                { "total_fee", directInfo.TotalFee.ToString("0.00") },
                { "show_url", directInfo.ShowUrl },
                { "body", directInfo.ExtraCommonParam }
            };
            string responseResult = submit.BuildRequest(sParaTemp, "post", "确认");

            return(responseResult);
        }
Esempio n. 3
0
        /// <summary>
        /// 退款查询(航旅版)
        /// </summary>
        /// <param name="request">请求查询</param>
        /// <returns>结果</returns>
        public static RefundQueryResult QueryRefund(RefundQueryRequest request)
        {
            RefundQueryResult refundQueryResult = new RefundQueryResult();
            var    config = request.Config;
            Submit submit = new Submit(config);
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>
            {
                { "partner", config.GetPid() },
                { "_input_charset", Config.InputCharset.ToLower() },
                { "service", "refund_fastpay_query" }
            };

            if (!string.IsNullOrWhiteSpace(request.BatchNo))
            {
                sParaTemp.Add("batch_no", request.BatchNo);
            }
            else
            {
                sParaTemp.Add("trade_no", request.TradeNo);
            }
            string requestStr;
            var    responseStr = submit.BuildRequest(sParaTemp, out requestStr);

            refundQueryResult.RequestStr  = requestStr;
            refundQueryResult.ResponseStr = responseStr;

            var dic = Core.UrlToData(responseStr);

            try
            {
                if (dic.ContainsKey("is_success"))
                {
                    string isSuccess = dic["is_success"];
                    if (isSuccess == "T")
                    {
                        if (dic.ContainsKey("result_details"))
                        {
                            refundQueryResult.IsSuccess     = true;
                            refundQueryResult.ResultDetails = new RefundResultDetails(dic["result_details"]);
                        }
                        else
                        {
                            refundQueryResult.Message = "result_details参数为空";
                        }
                        return(refundQueryResult);
                    }
                    else
                    {
                        if (dic.ContainsKey("error"))
                        {
                            refundQueryResult.Message = dic["error"];
                            return(refundQueryResult);
                        }
                        else
                        {
                            refundQueryResult.Message = "error参数为空";
                            return(refundQueryResult);
                        }
                    }
                }
                else
                {
                    refundQueryResult.Message = "is_success参数为空";
                    return(refundQueryResult);
                }
            }
            catch (Exception exp)
            {
                refundQueryResult.Message = exp.Message;
                return(refundQueryResult);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 退款(航旅版)
        /// </summary>
        /// <param name="request">退款请求参数</param>
        /// <returns>退款申请结果</returns>
        public static RefundResult Refund(RefundRequest request)
        {
            RefundResult refundResult = new RefundResult();
            var          config       = request.Config;
            Submit       submit       = new Submit(config);
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>
            {
                { "partner", config.GetPid() },
                { "_input_charset", Config.InputCharset.ToLower() },
                { "service", "refund_fastpay_by_platform_nopwd" },
                { "notify_url", request.NotifyUrl },
                { "batch_no", request.BatchNo },
                { "refund_date", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") },
                { "batch_num", request.BatchNum.ToString() },
                { "detail_data", request.ToString() }
            };

            string requestStr;
            var    responseStr = submit.BuildRequest(sParaTemp, out requestStr);

            refundResult.RequestStr  = requestStr;
            refundResult.ResponseStr = responseStr;
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(responseStr);
                var selectSingleNode = xmlDoc.SelectSingleNode("/alipay/is_success");
                if (selectSingleNode != null)
                {
                    string strXmlResponse = selectSingleNode.InnerText;
                    refundResult.IsSuccess = strXmlResponse;
                    if (strXmlResponse == "T")
                    {
                        return(refundResult);
                    }
                    else
                    {
                        var singleNode = xmlDoc.SelectSingleNode("/alipay/error");
                        if (singleNode != null)
                        {
                            refundResult.Message = singleNode.InnerText;
                            return(refundResult);
                        }
                        else
                        {
                            refundResult.Message = "/alipay/error节点为空";
                            return(refundResult);
                        }
                    }
                }
                else
                {
                    refundResult.Message = "/alipay/is_success节点为空";
                    return(refundResult);
                }
            }
            catch (Exception exp)
            {
                refundResult.Message = exp.Message;
                return(refundResult);
            }
        }