Esempio n. 1
0
        /// <summary>
        /// 订单查询
        /// </summary>
        /// <param name="outTradeNo">商户平台业务流水号</param>
        /// <returns>返回响应参数 SortedDictionary</returns>
        public PayCenterData paycenterQueryOrder(string outTradeNo)
        {
            Log.Info(this.GetType().ToString(), "===========查询订单请求开始============");
            //易票联网关订单类地址
            string url     = Resource.ORDER_URL;
            string httpUrl = url + "?";
            //1、实例化支付请求实体类,并设置需要的参数--------
            PayCenterData data = new PayCenterData();

            data.SetValue("partner", Resource.PARTNER);
            data.SetValue("trans_type", "query");
            data.SetValue("out_trade_no", outTradeNo);
            data.SetValue("version", Resource.VERSION.ToString());
            //2、签名
            string sign = data.MakeSign();
            //3、请求实体类自动签名并得到支付参数--------------
            string requestStr = data.ToRequestUrl() + "&sign=" + HttpUtility.UrlEncode(sign, Encoding.GetEncoding("GBK"));

            httpUrl += requestStr;
            Log.Info(this.GetType().ToString(), "请求地址:" + httpUrl);
            //4、发起请求并得到响应
            String responseXml = HttpUtil.HttpPost(httpUrl, requestStr);

            Log.Info(this.GetType().ToString(), "响应xml:" + responseXml);
            PayCenterData responseData           = new PayCenterData();
            SortedDictionary <string, object> sd = responseData.FromXml(responseXml);

            return(responseData);
        }
Esempio n. 2
0
        /// <summary>
        /// 订单支付
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void pay_Click(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "============支付请求开始=========");
            //易票联网关支付地址
            //1、获取商品信息参数-----------------------------
            string currencyType = T_currencyType.Text;
            string totalFee     = T_amount.Text;
            string remark       = T_remark.Text;
            //2、生成订单流水号-------------------------------
            string outTradeNo = DateTime.Now.Ticks + "";

            System.Diagnostics.Debug.Write(outTradeNo);
            //3、实例化支付请求实体类,并设置需要的参数--------
            PayCenterData data = new PayCenterData();

            data.SetValue("partner", Resource.PARTNER);
            data.SetValue("out_trade_no", outTradeNo);
            data.SetValue("total_fee", totalFee);
            data.SetValue("currency_type", currencyType);
            data.SetValue("return_url", "http://172.20.16.194/Paycenter_sdk/PayResponse.aspx");
            data.SetValue("notify_url", "http://172.20.16.194/Paycenter_sdk/Paycenter_sdk/NotifyPayResponse.aspx");
            data.SetValue("submission_type", "00");
            //中文要base64转码
            data.SetValue("base64_memo", Convert.ToBase64String(Encoding.Default.GetBytes(remark)));
            //data.SetValue("notify_url","zhaohang");//直连招商银行
            //4、传递参数调用sdk发起支付请求
            PaycenterService ps = new PaycenterService();

            ps.paycenterPayRequest(data, Response);
        }
Esempio n. 3
0
        /// <summary>
        /// 支付请求获取同步消息返回
        /// </summary>
        /// <param name="page">Page</param>
        /// <returns>返回响应参数 SortedDictionary</returns>
        public PayCenterData acceptResponse(Page page)
        {
            PayCenterData       data = new PayCenterData();
            NameValueCollection nvc  = page.Request.QueryString;

            if (nvc.Count != 0)
            {
                for (int i = 0; i < nvc.Count; i++)
                {
                    data.SetValue(nvc.GetKey(i), nvc.GetValues(i)[0]);
                }
            }
            else
            {
                Log.Info(this.GetType().ToString(), "没有收到传递的参数值");
            }

            //2、验证签名
            if (data.CheckSign())
            {
                Log.Info(this.GetType().ToString(), "签名验证成功");
                return(data);
            }
            else
            {
                Log.Error(this.GetType().ToString(), "PayCenterData签名验证错误!");
                throw new PayCenterException("PayCenterData签名验证错误!");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 退款请求
        /// </summary>
        /// <param name="outTradeNo">商户平台业务流水号</param>
        /// <param name="outRefundNo">商户平台退款单号</param>
        /// <param name="totalAmount">订单总金额</param>
        /// <param name="refundAmount">退款金额</param>
        /// <returns>返回响应参数 SortedDictionary</returns>
        public PayCenterData paycenterRefundRequest(string outTradeNo, string outRefundNo, string totalAmount, string refundAmount)
        {
            Log.Info(this.GetType().ToString(), "===========退款请求开始============");
            //易票联网关订单类地址
            string url     = Resource.ORDER_URL;
            string httpUrl = url + "?";
            //1、实例化支付请求实体类,并设置需要的参数--------
            PayCenterData data = new PayCenterData();

            data.SetValue("partner", Resource.PARTNER);
            data.SetValue("trans_type", "refund");
            data.SetValue("sign_type", "SHA256withRSA");
            data.SetValue("out_trade_no", outTradeNo);
            data.SetValue("out_refund_no", outRefundNo);
            data.SetValue("total_amount", totalAmount);
            data.SetValue("refund_amount", refundAmount);
            //2、签名
            string sign = data.MakeSign();
            //3、请求实体类自动签名并得到支付参数--------------
            string requestStr = data.ToRequestUrl() + "&sign=" + HttpUtility.UrlEncode(sign, Encoding.GetEncoding("GBK"));

            httpUrl += requestStr;
            Log.Info(this.GetType().ToString(), "请求地址:" + httpUrl);
            //4、发起请求并得到响应
            String responseXml = HttpUtil.HttpPost(httpUrl, requestStr);

            Log.Info(this.GetType().ToString(), "响应xml:" + responseXml);
            PayCenterData responseData           = new PayCenterData();
            SortedDictionary <string, object> sd = responseData.FromXml(responseXml);

            return(responseData);
        }
Esempio n. 5
0
        /// <summary>
        /// 海关电子订单支付
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void customsPay_Click(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "============海关支付请求开始=========");
            //易票联网关支付地址

            //1、获取商品信息参数-----------------------------
            string currencyType    = Tc_currencyType.Text;
            string totalFee        = Tc_amount.Text;
            string remark          = Tc_remark.Text;
            string goodsAmount     = T_goodsAmount.Text;
            string goodsAmountCurr = T_goodsAmountCurr.Text;
            string taxAmount       = T_taxAmount.Text;
            string taxAmountCurr   = T_taxAmountCurr.Text;
            string freight         = T_freight.Text;
            string freightCurr     = T_freightCurr.Text;
            string bankAccount     = T_bankAccount.Text;
            string bankAccType     = T_bankAccType.Text;
            string userId          = T_userId.Text;
            string userName        = T_userName.Text;
            string certType        = T_cert_type.Text;
            string certNo          = T_cert_no.Text;
            string userMobile      = T_userMobile.Text;

            //2、生成订单流水号-------------------------------
            string outTradeNo = DateTime.Now.Ticks + "";

            System.Diagnostics.Debug.Write(outTradeNo);
            //3、实例化支付请求实体类,并设置需要的参数--------
            PayCenterData data = new PayCenterData();

            data.SetValue("partner", Resource.PARTNER);
            data.SetValue("out_trade_no", outTradeNo);
            data.SetValue("total_fee", totalFee);
            data.SetValue("currency_type", currencyType);
            data.SetValue("return_url", "http://localhost:57212/PayResponse.aspx");
            data.SetValue("notify_url", "http://localhost:57212/NotifyPayResponse.aspx");
            //中文要base64转码
            data.SetValue("base64_memo", Convert.ToBase64String(Encoding.Default.GetBytes(remark)));
            //海关电子网关支付特有参数
            data.SetValue("submission_type", "01");
            data.SetValue("goods_amount", goodsAmount);
            data.SetValue("goods_amount_curr", goodsAmountCurr);
            data.SetValue("tax_amount", taxAmount);
            data.SetValue("tax_amount_curr", taxAmountCurr);
            data.SetValue("freight", freight);
            data.SetValue("freight_curr", freightCurr);
            String userInfo = "bank_account=" + bankAccount + "&bank_acc_type=" + bankAccType + "&user_id=" + userId + "&user_name=" + userName +
                              "&user_cert_type=" + certType + "&user_cert_no=" + certNo + "&user_mobile=" + userMobile;//根据接口文档中拼接base64_user_info

            //data.SetValue("notify_url","zhaohang");//直连招商银行
            data.SetValue("base64_user_info", Convert.ToBase64String(Encoding.Default.GetBytes(userInfo)));
            //4、传递参数调用sdk发起支付请求
            PaycenterService ps = new PaycenterService();

            ps.paycenterPayRequest(data, Response);
        }
Esempio n. 6
0
        protected void order_query_Click(object sender, EventArgs e)
        {
            //----参数--由接入者实际接入时填写---
            string outTradeNo = "1447208747438"; //设置商户交易流水号
            //----参数end
            PaycenterService ps = new PaycenterService();
            PayCenterData    pd = ps.paycenterQueryOrder(outTradeNo);

            Log.Info(this.GetType().ToString(), "返回结果:" + pd.GetValue("resp_desc"));
        }
Esempio n. 7
0
        /// <summary>
        /// 支付请求获取异步消息返回
        /// </summary>
        /// <param name="page">Page</param>
        /// <returns>返回响应参数 SortedDictionary</returns>
        public PayCenterData acceptNotifyResponse(Page page)
        {
            //实例化异步通知处理类
            Notify notify = new Notify(page);
            //得到异步响应参数
            PayCenterData data = notify.GetNotifyData();

            //返回
            return(data);
        }
Esempio n. 8
0
        protected void refund_query_Click(object sender, EventArgs e)
        {
            //----参数--由接入者实际接入时填写---
            string outTradeNo  = "1447208747438"; //设置商户交易流水号
            string outRefundNo = "TK144720874743802";
            string refundId    = "1988";
            //----参数end
            PaycenterService ps = new PaycenterService();
            PayCenterData    pd = ps.paycenterRefundQuery(outTradeNo, refundId, outRefundNo);

            Log.Info(this.GetType().ToString(), "返回结果:" + pd.GetValue("resp_desc"));
        }
Esempio n. 9
0
        protected void refund_request_Click(object sender, EventArgs e)
        {
            //----参数--由接入者实际接入时填写---
            string outTradeNo   = "1447208747438"; //设置商户交易流水号
            string outRefundNo  = "TK144720874743802";
            string totalAmount  = "0.05";
            string refundAmount = "0.01";
            //----参数end
            PaycenterService ps = new PaycenterService();
            PayCenterData    pd = ps.paycenterRefundRequest(outTradeNo, outRefundNo, totalAmount, refundAmount);

            Log.Info(this.GetType().ToString(), "返回结果:" + pd.GetValue("resp_desc"));
            Log.Info(this.GetType().ToString(), "易票联退款流水号:" + pd.GetValue("refund_id"));
        }
Esempio n. 10
0
        /// <summary>
        /// 发起支付请求
        /// </summary>
        /// <param name="data">支付请求参数</param>
        /// <param name="response">HttpResponse</param>
        public void paycenterPayRequest(PayCenterData data, HttpResponse response)
        {
            data.SetValue("version", Resource.VERSION.ToString());
            string url     = Resource.PAY_URL;
            string httpUrl = url + "?";
            string sign    = data.MakeSign();
            //请求实体类自动签名并得到支付参数--------------
            string requestStr = data.ToRequestUrl() + "&sign=" + HttpUtility.UrlEncode(sign, Encoding.GetEncoding("GBK"));

            httpUrl += requestStr;
            Log.Info(this.GetType().ToString(), "请求url:" + httpUrl);
            //发起请求-------------------------------------
            response.Redirect(httpUrl);
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "===========支付请求同步通知============");
            PaycenterService ps   = new PaycenterService();
            PayCenterData    data = ps.acceptResponse(Page);

            if ("1".Equals(data.GetValue("pay_result")))
            {
                Label1.Text = "支付成功";
                //支付成功业务处理

                //支付成功业务处理
            }
            else
            {
                //支付失败业务处理

                //支付失败业务处理
                Label1.Text = "支付失败";
            }
        }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "===========支付请求异步通知============");
            //调用sdk得到异步通知参数
            PaycenterService ps   = new PaycenterService();
            PayCenterData    data = ps.acceptNotifyResponse(Page);

            if ("1".Equals(data.GetValue("pay_result")))
            {
                Log.Info(this.GetType().ToString(), "支付成功");
                //支付成功业务处理

                //支付成功业务处理
            }
            else
            {
                Log.Info(this.GetType().ToString(), "支付失败");
                //支付失败业务处理

                //支付失败业务处理
            }
        }