Exemplo n.º 1
0
        public void TestPreOrder()
        {
            UnionPayChannel channel = new UnionPayChannel()
            {
                CertificateFilePassword = "******", CertificateFilePath = "D:/cer/630056832596.pfx", MerchantID = "630056832596", PacketEncryptKey = "654321"
            };
            PreOrderRequest req = new PreOrderRequest();

            req.SendTime          = DateTime.Now;
            req.SendSeqID         = Guid.NewGuid().ToString("N");
            req.FrontUrl          = "http://www.jitmarketing.cn:8090/TranNotification.ashx";
            req.MerchantOrderDesc = "呵呵";
            req.Misc = string.Empty;
            //req.GatewayType = GatewayTypes.WAP;
            req.TransTimeout          = DateTime.Now.AddHours(1);
            req.BackUrl               = "http://www.jitmarketing.cn:8090/TranNotification.ashx";
            req.MerchantOrderCurrency = Currencys.RMB;
            req.MerchantOrderAmt      = 1;
            req.MerchantID            = "630056832596";
            req.MerchantOrderTime     = DateTime.Now.AddMinutes(-5);
            req.MerchantOrderID       = Guid.NewGuid().ToString("N");
            req.MerchantUserID        = string.Empty;
            req.MobileNum             = "15388157741";
            req.CarNum = string.Empty;

            var rsp = WapGateway.PreOrder(channel, req);

            Assert.IsTrue(rsp.IsSuccess);
        }
Exemplo n.º 2
0
        private void btnOrder_Click(object sender, EventArgs e)
        {
            //创建支付通道
            UnionPayChannel channel = new UnionPayChannel()
            {
                CertificateFilePassword = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePassword"]
                ,
                CertificateFilePath = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePath"]
                ,
                MerchantID = ConfigurationManager.AppSettings["WAPMerchantID"]
                ,
                PacketEncryptKey = "654321"
            };
            //下订单
            PreOrderRequest req = new PreOrderRequest();

            req.SendTime          = DateTime.Now;
            req.SendSeqID         = Guid.NewGuid().ToString("N");
            req.FrontUrl          = ConfigurationManager.AppSettings["WAPFrontUrl"]; //商户平台的页面,用户支付完毕后跳转的页面
            req.MerchantOrderDesc = "呵呵";
            req.Misc                  = string.Empty;
            req.TransTimeout          = DateTime.Now.AddHours(1);
            req.BackUrl               = ConfigurationManager.AppSettings["WAPBackUrl"]; //当用户支付完成后,支付平台回调的交易通知的页面
            req.MerchantOrderCurrency = Currencys.RMB;
            req.MerchantOrderAmt      = 1;
            req.MerchantID            = channel.MerchantID;
            req.MerchantOrderTime     = DateTime.Now.AddMinutes(-5);
            req.MerchantOrderID       = Guid.NewGuid().ToString("N");
            req.MerchantUserID        = string.Empty;
            req.MobileNum             = this.txtMobileNO.Text; //消费者的手机号,支付平台会将验证码发送到该手机
            req.CarNum                = string.Empty;
            //记录支付请求日志
            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("[Wap]PreOrder Request={0}", req.GetContent())
            });
            //支付平台成功接收
            var rsp = WapGateway.PreOrder(channel, req);

            //重定向到支付页面
            if (rsp.IsSuccess)
            {
                //
                this.Session["MerchantOrderID"]   = rsp.MerchantOrderID;
                this.Session["MerchantOrderTime"] = rsp.MerchantOrderTime;
                //
                this.ltGotoPay.Text = string.Format("<a href=\"{0}\">去支付</>", rsp.RedirectURL);
                this.ltGotoPay.Mode = LiteralMode.PassThrough;
            }
        }
Exemplo n.º 3
0
        public void TestQueryOrder()
        {
            //先发预订单请求
            UnionPayChannel channel = new UnionPayChannel()
            {
                CertificateFilePassword = "******", CertificateFilePath = "D:/cer/630056832596.pfx", MerchantID = "630056832596", PacketEncryptKey = "654321"
            };
            PreOrderRequest req = new PreOrderRequest();

            req.SendTime          = DateTime.Now;
            req.SendSeqID         = Guid.NewGuid().ToString("N");
            req.FrontUrl          = "http://www.jitmarketing.cn:8090/TranNotification.ashx";
            req.MerchantOrderDesc = "呵呵";
            req.Misc = string.Empty;
            //req.GatewayType = GatewayTypes.WAP;
            req.TransTimeout          = DateTime.Now.AddHours(1);
            req.BackUrl               = "http://www.jitmarketing.cn:8090/TranNotification.ashx";
            req.MerchantOrderCurrency = Currencys.RMB;
            req.MerchantOrderAmt      = 1;
            req.MerchantID            = "630056832596";
            req.MerchantOrderTime     = DateTime.Now.AddMinutes(-5);
            req.MerchantOrderID       = Guid.NewGuid().ToString("N");
            req.MerchantUserID        = string.Empty;
            req.MobileNum             = "15388157741";
            req.CarNum = string.Empty;

            var rsp = WapGateway.PreOrder(channel, req);

            Assert.IsTrue(rsp.IsSuccess);
            //跳转到支付平台页面
            WebClient wc          = new WebClient();
            string    strResponse = wc.UploadString(rsp.RedirectURL, string.Empty);
            //在查询
            QueryOrderRequest req2 = new QueryOrderRequest();

            req2.SendTime          = DateTime.Now;
            req2.SendSeqID         = Guid.NewGuid().ToString("N");
            req2.TransType         = WapTransTypes.PreAuthorization;
            req2.MerchantID        = "630056832596";
            req2.MerchantOrderID   = req.MerchantOrderID;
            req2.MerchantOrderTime = req.MerchantOrderTime;

            var rsp2 = WapGateway.QueryOrder(channel, req2);

            Assert.IsTrue(rsp2.IsSuccess);
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string strRequest = context.Request.Params["ReqContent"];
                //if (string.IsNullOrEmpty(strRequest))
                //{
                //    strRequest = "{\"Token\":\"\",\"CityID\":21,\"UserID\":\"FBEE2CFA-500C-4756-BFAA-000014308165\",\"Locale\":1,\"Parameters\":{\"OrderAmount\":1,\"OrderDesc\":\"测试支付\",\"OrderTime\":\"2013-12-30 16:24:33 367\",\"OrderID\":\"57F2DB3A51EB472AED32E413AA986854\",\"MobileNO\":\"13817218367\",\"PayType\":1}}";
                //}
                var request = strRequest.DeserializeJSONTo <ALDRequest <PayOrderRequest> >();
                switch (request.Parameters.PayType.Value)
                {
                case 1:
                    #region WAP 下单
                {
                    //创建支付通道
                    UnionPayChannel channel = new UnionPayChannel()
                    {
                        CertificateFilePassword = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePassword"]
                        ,
                        CertificateFilePath = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePath"]
                        ,
                        MerchantID = ConfigurationManager.AppSettings["WAPMerchantID"]
                        ,
                        PacketEncryptKey = "654321"
                    };
                    //下订单
                    WAPRequest.PreOrderRequest req = new WAPRequest.PreOrderRequest();
                    req.SendTime          = DateTime.Now;
                    req.SendSeqID         = Guid.NewGuid().ToString("N");
                    req.FrontUrl          = ConfigurationManager.AppSettings["WAPFrontUrl"];   //商户平台的页面,用户支付完毕后跳转的页面
                    req.MerchantOrderDesc = request.Parameters.OrderDesc;
                    req.Misc                  = string.Empty;
                    req.TransTimeout          = DateTime.Now.AddHours(1);
                    req.BackUrl               = ConfigurationManager.AppSettings["WAPBackUrl"]; //当用户支付完成后,支付平台回调的交易通知的页面
                    req.MerchantOrderCurrency = Currencys.RMB;
                    req.MerchantOrderAmt      = request.Parameters.OrderAmount;
                    req.MerchantID            = channel.MerchantID;
                    req.MerchantOrderTime     = DateTime.ParseExact(request.Parameters.OrderTime, "yyyy-MM-dd HH:mm:ss fff", null);
                    req.MerchantOrderID       = request.Parameters.OrderID;
                    req.MerchantUserID        = string.Empty;
                    req.MobileNum             = request.Parameters.MobileNO;  //消费者的手机号,支付平台会将验证码发送到该手机
                    req.CarNum                = string.Empty;
                    //记录支付请求日志
                    Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("[Wap]PreOrder Request={0}", req.GetContent())
                        });
                    //支付平台成功接收
                    var rsp = WapGateway.PreOrder(channel, req);
                    if (rsp.IsSuccess)
                    {
                        context.Response.Write(rsp.RedirectURL);
                    }
                }
                    #endregion
                    break;

                case 2:
                    #region 语音下单
                {
                    //创建支付通道
                    UnionPayChannel channel = new UnionPayChannel()
                    {
                        CertificateFilePassword = ConfigurationManager.AppSettings["IVREncryptCertificateFilePassword"]
                        ,
                        CertificateFilePath = ConfigurationManager.AppSettings["IVREncryptCertificateFilePath"]
                        ,
                        MerchantID = ConfigurationManager.AppSettings["IVRMerchantID"]
                        ,
                        PacketEncryptKey = "654321"
                    };
                    //下订单
                    IVRRequest.PreOrderRequest req = new IVRRequest.PreOrderRequest();
                    req.SendTime          = DateTime.Now;
                    req.SendSeqID         = Guid.NewGuid().ToString("N");
                    req.FrontUrl          = ConfigurationManager.AppSettings["IVRFrontUrl"];   //商户平台的页面,用户支付完毕后跳转的页面
                    req.MerchantOrderDesc = request.Parameters.OrderDesc;
                    req.Misc                  = string.Empty;
                    req.Mode                  = IVRValueObject.IVRModes.Callback;
                    req.TransTimeout          = DateTime.Now.AddHours(1);
                    req.BackUrl               = ConfigurationManager.AppSettings["IVRBackUrl"]; //当用户支付完成后,支付平台回调的交易通知的页面
                    req.MerchantOrderCurrency = Currencys.RMB;
                    req.MerchantOrderAmt      = request.Parameters.OrderAmount;
                    req.MerchantID            = channel.MerchantID;
                    req.MerchantOrderTime     = DateTime.ParseExact(request.Parameters.OrderTime, "yyyy-MM-dd HH:mm:ss fff", null);
                    req.MerchantOrderID       = request.Parameters.OrderID;
                    req.MerchantUserID        = string.Empty;
                    req.MobileNum             = request.Parameters.MobileNO;  //消费者的手机号,支付前置会将验证码发送到该手机
                    req.CarNum                = string.Empty;
                    //记录支付请求日志
                    Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("[IVR]PreOrder Request={0}", req.GetContent())
                        });
                    //支付平台成功接收
                    var rsp = IVRGateway.PreOrder(channel, req);
                    //
                    if (rsp.IsSuccess)
                    {
                        context.Response.Write("OK");
                    }
                    else
                    {
                        context.Response.Write("Failed");
                    }
                }
                    #endregion
                    break;
                }
            }
            catch (Exception ex)
            {
                JIT.Utility.Log.Loggers.Exception(new ExceptionLogInfo(ex));
                throw ex;
            }
        }